|
| 1 | +# FigureQA |
| 2 | + |
| 3 | +Code to generate the FigureQA dataset, see https://datasets.maluuba.com/FigureQA. |
| 4 | + |
| 5 | +## Data Generation |
| 6 | + |
| 7 | +Data generation consists of 3 parts: |
| 8 | + |
| 9 | +1. Generate the source numerical data, styles, and question-answer pairs for the figures. |
| 10 | +1. Generate the figure images and bounding box annotatations. |
| 11 | +1. Aggregrate the figure images, questions & answers, annotations, and source data. |
| 12 | + |
| 13 | +### Code Map |
| 14 | + |
| 15 | +All data generation source code lives in the `figureqa/generation` subpackage: |
| 16 | + |
| 17 | +- `questions` subpackage contains code to generate questions |
| 18 | + |
| 19 | + - `categorical.py` for questions for bar graphs and pie charts. |
| 20 | + - `lines.py` for line plots. |
| 21 | + - `utils.py` for balancing and question encoding augmentation. |
| 22 | + |
| 23 | +- `source_data_generation.py` to generate source data, questions, and answers. |
| 24 | + |
| 25 | +- `figure_generation.py` to generate figure images and bounding boxes. |
| 26 | + |
| 27 | +- `json_combiner.py` aggregates the generated data into the documented format. Allows for generating a data split in multiple batches. |
| 28 | + |
| 29 | +- `data_utils.py` has misc. utilities for reconciling data formats, placing legends, etc. |
| 30 | + |
| 31 | +- `figure.py` defines the figure objects in Bokeh. |
| 32 | + |
| 33 | +- `generate_dataset.py` generates a whole dataset end-to-end. |
| 34 | + |
| 35 | +- `show_bounding_boxes.py` generates images with bounding boxes visualized. |
| 36 | + |
| 37 | +Each runnable module (script) can have its command line arguments displayed with `--help`. |
| 38 | + |
| 39 | +There are some additional files used for data generation in these directories: |
| 40 | + |
| 41 | +- `config` contains `.yaml` files that configure visual apsects, source data parameters, color splits, and dataset generation. |
| 42 | + |
| 43 | +- `resources` contains the colors and other misc. resources for data generation. |
| 44 | + |
| 45 | +And `docs` contains additional documentation on annotations, question format, and file formats. |
| 46 | + |
| 47 | +### Prerequisites |
| 48 | + |
| 49 | +1. Install the FigureQA fork of Bokeh from https://www.github.com/Maluuba/bokeh. |
| 50 | +1. `pip install -r requirements.txt`. |
| 51 | +1. Make sure you have enough space. The whole dataset unzipped is > 6GB, plus you need room for intermediate data. |
| 52 | + |
| 53 | +### Generate a whole dataset |
| 54 | + |
| 55 | +#### Using a single script |
| 56 | + |
| 57 | +This is done with the end-to-end script `generate_dataset.py`. It does the source data synthesis, figure generation, and aggregation. |
| 58 | + |
| 59 | +This script must be run from the root directory, `FigureQA`. |
| 60 | + |
| 61 | +The config for the actual dataset is in `config/figureqa_generation_config.yaml`. |
| 62 | +A sample config is provided in `config/sample_figureqa_generation_config.yaml`. |
| 63 | + |
| 64 | +Note that this does not generate the test sets. |
| 65 | + |
| 66 | +#### With individual scripts |
| 67 | + |
| 68 | +1. `cd FigureQA` |
| 69 | +1. `python figureqa/generation/source_data_generation.py CONFIG_FILE.yaml SOURCE_DATA.json --<figure_type> <N_figures> ...` |
| 70 | +1. `python figureqa/generation/figure_generation.py SOURCE_DATA.json RAW_GENERATED_DIR` |
| 71 | +1. `python figureqa/generation/json_combiner.py FINAL_AGGREGATE_DIR RAW_GENERATED_DIR1 RAW_GENERATED_DIR2 ...` |
0 commit comments