KHUjongseo commited on
Commit
643613f
·
verified ·
1 Parent(s): 0b281a7

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +73 -0
  2. close_ended.json +0 -0
  3. making_json.py +107 -0
  4. open_ended.json +0 -0
README.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ configs:
3
+ - config_name: close_ended
4
+ data_files:
5
+ - split: val
6
+ path: close_ended.json
7
+ - config_name: open_ended
8
+ data_files:
9
+ - split: val
10
+ path: open_ended.json
11
+ license: mit
12
+ task_categories:
13
+ - visual-question-answering
14
+ language:
15
+ - en
16
+ tags:
17
+ - spatial-reasoning
18
+ - object-location
19
+ - direction
20
+ ---
21
+
22
+ # Object Location 4-Class (Subset 1 of 5)
23
+
24
+ A visual question answering dataset for evaluating spatial reasoning — specifically, identifying the location of an object (Up / Down / Left / Right) from the viewer's perspective.
25
+
26
+ ## Dataset Configurations
27
+
28
+ ### `close_ended`
29
+ Multiple-choice format with 4 fixed options (A: Up, B: Down, C: Left, D: Right).
30
+
31
+ ### `open_ended`
32
+ Free-form answer format. The model is expected to respond with one of: Up, Down, Left, Right.
33
+
34
+ ## Usage
35
+
36
+ ```python
37
+ from datasets import load_dataset
38
+
39
+ # Close-ended (multiple choice)
40
+ ds_close = load_dataset("YOUR_HF_ID/object_location_4class", name="close_ended", split="val")
41
+
42
+ # Open-ended (free-form)
43
+ ds_open = load_dataset("YOUR_HF_ID/object_location_4class", name="open_ended", split="val")
44
+ ```
45
+
46
+ ## Data Fields
47
+
48
+ ### Close-ended
49
+ | Field | Type | Description |
50
+ |-------|------|-------------|
51
+ | `id` | int | Sample index |
52
+ | `image` | string | Image filename (e.g., `rectangle_yellow_123.png`) |
53
+ | `question` | string | Question text |
54
+ | `options` | list[string] | `["Up", "Down", "Left", "Right"]` |
55
+ | `answer` | string | Correct option letter (`A`/`B`/`C`/`D`) |
56
+ | `answer_text` | string | Correct answer in text (`Up`/`Down`/`Left`/`Right`) |
57
+ | `category` | string | Ground truth direction folder (`up`/`down`/`left`/`right`) |
58
+
59
+ ### Open-ended
60
+ | Field | Type | Description |
61
+ |-------|------|-------------|
62
+ | `id` | int | Sample index |
63
+ | `image` | string | Image filename (e.g., `rectangle_yellow_123.png`) |
64
+ | `question` | string | Question text |
65
+ | `answer` | string | Correct answer (`Up`/`Down`/`Left`/`Right`) |
66
+ | `category` | string | Ground truth direction folder (`up`/`down`/`left`/`right`) |
67
+
68
+ ## Notes
69
+
70
+ - Images are **not** included in this repository. They should be stored locally and loaded via the `category` and `image` fields to reconstruct the full path:
71
+ ```
72
+ {DATA_ROOT}/{category}/{image}
73
+ ```
close_ended.json ADDED
The diff for this file is too large to render. See raw diff
 
making_json.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 로컬 이미지 디렉토리에서 lmms-eval용 JSON 데이터셋 2종 생성
3
+ - close_ended.json : 4지선다 (A/B/C/D)
4
+ - open_ended.json : 자유 응답 (Up/Down/Left/Right)
5
+ """
6
+
7
+ import os
8
+ import json
9
+ import glob
10
+
11
+ # ============================================================
12
+ # 설정
13
+ # ============================================================
14
+ DATA_ROOT = "/data/dataset/vlm_direction/object_location_4_class_subset_1of5/val"
15
+ OUTPUT_DIR = "./"
16
+
17
+ # 폴더명 → 영어 레이블 매핑
18
+ LABEL_MAP = {
19
+ "up": "Up",
20
+ "down": "Down",
21
+ "left": "Left",
22
+ "right": "Right",
23
+ }
24
+
25
+ # Close-ended 선택지 (고정 순서)
26
+ OPTIONS = ["Up", "Down", "Left", "Right"]
27
+ OPTION_LETTERS = ["A", "B", "C", "D"]
28
+
29
+ # ============================================================
30
+ # 데이터 수집
31
+ # ============================================================
32
+ close_ended_data = []
33
+ open_ended_data = []
34
+
35
+ idx = 0
36
+ for folder_name, eng_label in LABEL_MAP.items():
37
+ folder_path = os.path.join(DATA_ROOT, folder_name)
38
+ if not os.path.isdir(folder_path):
39
+ print(f"[WARNING] 폴더 없음: {folder_path}")
40
+ continue
41
+
42
+ image_files = sorted(
43
+ glob.glob(os.path.join(folder_path, "*.png"))
44
+ + glob.glob(os.path.join(folder_path, "*.jpg"))
45
+ + glob.glob(os.path.join(folder_path, "*.jpeg"))
46
+ )
47
+ print(f"[INFO] {folder_name}: {len(image_files)} images found")
48
+
49
+ for img_path in image_files:
50
+ # abs_path = os.path.abspath(img_path)
51
+ filename = os.path.basename(img_path)
52
+
53
+ # 정답 옵션 letter (A/B/C/D)
54
+ answer_idx = OPTIONS.index(eng_label)
55
+ answer_letter = OPTION_LETTERS[answer_idx]
56
+
57
+ # --------------------------------------------------
58
+ # 1) Close-ended (4지선다)
59
+ # --------------------------------------------------
60
+ close_ended_data.append({
61
+ "id": idx,
62
+ "image": filename,
63
+ "question": "From the viewer's perspective, where is the object located in the image?",
64
+ "options": OPTIONS, # ["Up", "Down", "Left", "Right"]
65
+ "answer": answer_letter, # "A" / "B" / "C" / "D"
66
+ "answer_text": eng_label, # "Up" / "Down" / "Left" / "Right"
67
+ "category": folder_name,
68
+ })
69
+
70
+ # --------------------------------------------------
71
+ # 2) Open-ended (자유 응답)
72
+ # --------------------------------------------------
73
+ open_ended_data.append({
74
+ "id": idx,
75
+ "image": filename,
76
+ "question": "From the viewer's perspective, where is the object located in the image? Answer with one of: Up, Down, Left, Right.",
77
+ "answer": eng_label, # "Up" / "Down" / "Left" / "Right"
78
+ "category": folder_name,
79
+ })
80
+
81
+ idx += 1
82
+
83
+ # ============================================================
84
+ # JSON 저장
85
+ # ============================================================
86
+ os.makedirs(OUTPUT_DIR, exist_ok=True)
87
+
88
+ close_path = os.path.join(OUTPUT_DIR, "close_ended.json")
89
+ open_path = os.path.join(OUTPUT_DIR, "open_ended.json")
90
+
91
+ with open(close_path, "w", encoding="utf-8") as f:
92
+ json.dump(close_ended_data, f, ensure_ascii=False, indent=2)
93
+
94
+ with open(open_path, "w", encoding="utf-8") as f:
95
+ json.dump(open_ended_data, f, ensure_ascii=False, indent=2)
96
+
97
+ print(f"\n{'='*60}")
98
+ print(f"Total {idx} samples processed")
99
+ print(f"Close-ended → {close_path} ({len(close_ended_data)} samples)")
100
+ print(f"Open-ended → {open_path} ({len(open_ended_data)} samples)")
101
+ print(f"{'='*60}")
102
+
103
+ # 샘플 출력
104
+ print("\n[Sample] Close-ended:")
105
+ print(json.dumps(close_ended_data[0], ensure_ascii=False, indent=2))
106
+ print("\n[Sample] Open-ended:")
107
+ print(json.dumps(open_ended_data[0], ensure_ascii=False, indent=2))
open_ended.json ADDED
The diff for this file is too large to render. See raw diff