task_categories:visual-question-answering language:en license:mit size_categories:1K<n<10K format:parquet modality:image modality:text library:datasets library:pandas library:mlcroissant library:polars region:us
---
dataset_info:
  features:
  - name: images
    sequence: image
  - name: problem
    dtype: string
  - name: answer
    dtype: string
  - name: id
    dtype: int64
  - name: choices
    sequence: string
  - name: ground_truth
    dtype: string
  splits:
  - name: train
    num_bytes: 43191899.912
    num_examples: 2101
  - name: validation
    num_bytes: 6009916.0
    num_examples: 300
  - name: test
    num_bytes: 12234557.0
    num_examples: 601
  download_size: 59201452
  dataset_size: 61436372.912
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
  - split: validation
    path: data/validation-*
  - split: test
    path: data/test-*
license: mit
task_categories:
- visual-question-answering
language:
- en
size_categories:
- 1K<n<10K
---

This dataset was converted from [https://github.com/lupantech/InterGPS](https://github.com/lupantech/InterGPS) using the following script.

```python
import os
import json
from PIL import Image
from datasets import Dataset, DatasetDict, Sequence
from datasets import Image as ImageData


MAPPING = {"A": 0, "B": 1, "C": 2, "D": 3}


def generate_data(data_path: str):
    for folder in os.listdir(data_path):
        folder_path = os.path.join(data_path, folder)
        image = Image.open(os.path.join(folder_path, "img_diagram.png"), "r")
        with open(os.path.join(folder_path, "data.json"), "r", encoding="utf-8") as f:
            data = json.load(f)
            yield {
                "images": [image],
                "problem": "<image>" + data["annotat_text"],
                "answer": data["choices"][MAPPING[data["answer"]]],
                "id": data["id"],
                "choices": data["choices"],
                "ground_truth": data["answer"],
            }


def main():
    trainset = Dataset.from_generator(generate_data, gen_kwargs={"data_path": os.path.join("data", "geometry3k", "train")})
    valset = Dataset.from_generator(generate_data, gen_kwargs={"data_path": os.path.join("data", "geometry3k", "val")})
    testset = Dataset.from_generator(generate_data, gen_kwargs={"data_path": os.path.join("data", "geometry3k", "test")})
    dataset = DatasetDict({"train": trainset, "validation": valset, "test": testset}).cast_column("images", Sequence(ImageData()))
    dataset.push_to_hub("hiyouga/geometry3k")


if __name__ == "__main__":
    main()
```
