Datasets:
Tasks:
Image Segmentation
Sub-tasks:
semantic-segmentation
Languages:
English
Size:
1K<n<10K
License:
Srushti Hirve commited on
Commit ·
aba1895
1
Parent(s): 042e479
Rename and add demo.py for dataset loading
Browse files
demo.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import datasets
|
| 3 |
+
|
| 4 |
+
class VisionReasonerDataset(datasets.GeneratorBasedBuilder):
|
| 5 |
+
def _info(self):
|
| 6 |
+
return datasets.DatasetInfo(
|
| 7 |
+
features=datasets.Features({
|
| 8 |
+
"id": datasets.Value("string"),
|
| 9 |
+
"problem": datasets.Value("string"),
|
| 10 |
+
"solution": datasets.Value("string"),
|
| 11 |
+
"image": datasets.Image(), # Enables image previews
|
| 12 |
+
"img_height": datasets.Value("int32"),
|
| 13 |
+
}),
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
def _split_generators(self, dl_manager):
|
| 17 |
+
parquet_path = os.path.join(dl_manager.manual_dir, "visionreasoner_dataset.parquet")
|
| 18 |
+
return [
|
| 19 |
+
datasets.SplitGenerator(
|
| 20 |
+
name=datasets.Split.TRAIN,
|
| 21 |
+
gen_kwargs={"filepath": parquet_path}
|
| 22 |
+
),
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
def _generate_examples(self, filepath):
|
| 26 |
+
import pandas as pd
|
| 27 |
+
df = pd.read_parquet(filepath)
|
| 28 |
+
for idx, row in df.iterrows():
|
| 29 |
+
yield idx, {
|
| 30 |
+
"id": row["id"],
|
| 31 |
+
"problem": row["problem"],
|
| 32 |
+
"solution": row["solution"],
|
| 33 |
+
"image": row["image"]["path"],
|
| 34 |
+
"img_height": row["img_height"],
|
| 35 |
+
}
|
| 36 |
+
|