Download dataset_creation.py from kirchik47/ocr_task: direct link, hf CLI and curl.
- Browser
- Download file 504 Bytes
-
https://huggingface.co/spaces/kirchik47/ocr_task/resolve/main/dataset_creation.py
- Command line
-
hf download hf://spaces/kirchik47/ocr_task/dataset_creation.py
-
curl -L -o dataset_creation.py https://huggingface.co/spaces/kirchik47/ocr_task/resolve/main/dataset_creation.py
504 Bytes
| import pandas as pd | |
| import json | |
| import os | |
| dataset = pd.read_csv('data_80k/data.csv') | |
| labels = dataset['image_file'] | |
| text = dataset['text'] | |
| json_data = [] | |
| images_path = '/kaggle/input/hindi-english-images/data_80k/output_images/' | |
| for i in range(len(labels)): | |
| json_data.append( | |
| { | |
| "query": "<image>", | |
| "response": text[i], | |
| "images": [os.path.join(images_path, labels[i])], | |
| } | |
| ) | |
| with open('dataset.json', 'w') as f: | |
| json.dump(json_data, f) | |