Datasets:
File size: 2,376 Bytes
5a0f54c 97b8cb4 5a0f54c 1f29cb2 5a0f54c 1f29cb2 5a0f54c 1f29cb2 5a0f54c 1f29cb2 5a0f54c 58a3d1e 5a0f54c 58a3d1e 37e4933 58a3d1e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
---
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()
```
|