Datasets:
Update README.md
Browse files
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 |
-
|
|
|
|
| 60 |
|
| 61 |
output_dir = "./images"
|
| 62 |
os.makedirs(output_dir, exist_ok=True)
|
| 63 |
|
| 64 |
-
for
|
| 65 |
-
index_val =
|
| 66 |
-
images =
|
| 67 |
-
question =
|
| 68 |
-
answer =
|
| 69 |
-
annotation_color =
|
| 70 |
-
category =
|
| 71 |
-
task =
|
| 72 |
|
| 73 |
image_paths = []
|
| 74 |
if images is not None:
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
| 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}")
|