cyang203912 commited on
Commit
7e6b0b9
·
verified ·
1 Parent(s): 47a8a10

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +16 -23
README.md CHANGED
@@ -46,39 +46,32 @@ SSI-Bench is constructed from **complex real-world 3D structures**, where feasib
46
  ## Load Dataset
47
  ```
48
  from datasets import load_dataset
49
-
50
- dataset = load_dataset("cyang203912/SSI-Bench")
51
- print(dataset)
52
- ```
53
-
54
- After downloading the parquet file, read each record, decode images from binary, and save them as JPG files.
55
- ```
56
- import pandas as pd
57
  import os
58
 
59
- df = pd.read_parquet("SSI_Bench.parquet")
 
60
 
61
  output_dir = "./images"
62
  os.makedirs(output_dir, exist_ok=True)
63
 
64
- for _, row in df.iterrows():
65
- index_val = row["index"]
66
- images = row["image"]
67
- question = row["question"]
68
- answer = row["answer"]
69
- annotation_color = row["annotation_color"]
70
- category = row["category"]
71
- task = row["task"]
72
 
73
  image_paths = []
74
  if images is not None:
75
- for n, img_data in enumerate(images):
76
- image_path = f"{output_dir}/{index_val}_{n}.jpg"
77
- with open(image_path, "wb") as f:
78
- f.write(img_data)
 
 
79
  image_paths.append(image_path)
80
- else:
81
- image_paths = []
82
 
83
  print(f"index: {index_val}")
84
  print(f"image: {image_paths}")
 
46
  ## Load Dataset
47
  ```
48
  from datasets import load_dataset
 
 
 
 
 
 
 
 
49
  import os
50
 
51
+ ds = load_dataset("cyang203912/SSI-Bench")["test"]
52
+ print(ds)
53
 
54
  output_dir = "./images"
55
  os.makedirs(output_dir, exist_ok=True)
56
 
57
+ for ex in ds:
58
+ index_val = ex["index"]
59
+ images = ex["image"]
60
+ question = ex["question"]
61
+ answer = ex["answer"]
62
+ annotation_color = ex["annotation_color"]
63
+ category = ex["category"]
64
+ task = ex["task"]
65
 
66
  image_paths = []
67
  if images is not None:
68
+ if not isinstance(images, list):
69
+ images = [images]
70
+
71
+ for n, img in enumerate(images):
72
+ image_path = os.path.join(output_dir, f"{index_val}_{n}.jpg")
73
+ img.save(image_path)
74
  image_paths.append(image_path)
 
 
75
 
76
  print(f"index: {index_val}")
77
  print(f"image: {image_paths}")