Srushti Hirve commited on
Commit
157df53
·
1 Parent(s): a8ce9b7

Fix dataset structure and paths

Browse files
Files changed (1) hide show
  1. demo.py +4 -7
demo.py CHANGED
@@ -1,5 +1,5 @@
1
- import os
2
  import datasets
 
3
 
4
  class Demo(datasets.GeneratorBasedBuilder):
5
  def _info(self):
@@ -8,30 +8,27 @@ class Demo(datasets.GeneratorBasedBuilder):
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
- # Access the file directly from the root of the repo
18
- parquet_path = "visionreasoner_dataset.parquet"
19
  return [
20
  datasets.SplitGenerator(
21
  name=datasets.Split.TRAIN,
22
- gen_kwargs={"filepath": parquet_path}
23
  ),
24
  ]
25
 
26
  def _generate_examples(self, filepath):
27
  import pandas as pd
28
-
29
  df = pd.read_parquet(filepath)
30
  for idx, row in df.iterrows():
31
  yield idx, {
32
  "id": row["id"],
33
  "problem": row["problem"],
34
  "solution": row["solution"],
35
- "image": row["image"]["path"], # assuming this is already like "images/xyz.webp"
36
  "img_height": row["img_height"],
37
  }
 
 
1
  import datasets
2
+ import os
3
 
4
  class Demo(datasets.GeneratorBasedBuilder):
5
  def _info(self):
 
8
  "id": datasets.Value("string"),
9
  "problem": datasets.Value("string"),
10
  "solution": datasets.Value("string"),
11
+ "image": datasets.Image(),
12
  "img_height": datasets.Value("int32"),
13
  }),
14
  )
15
 
16
  def _split_generators(self, dl_manager):
 
 
17
  return [
18
  datasets.SplitGenerator(
19
  name=datasets.Split.TRAIN,
20
+ gen_kwargs={"filepath": "visionreasoner_dataset.parquet"},
21
  ),
22
  ]
23
 
24
  def _generate_examples(self, filepath):
25
  import pandas as pd
 
26
  df = pd.read_parquet(filepath)
27
  for idx, row in df.iterrows():
28
  yield idx, {
29
  "id": row["id"],
30
  "problem": row["problem"],
31
  "solution": row["solution"],
32
+ "image": row["image"]["path"], # e.g., images/ui_img_10.webp
33
  "img_height": row["img_height"],
34
  }