File size: 15,223 Bytes
adca95f
 
 
 
 
7eb583c
adca95f
 
 
 
 
 
 
 
7eb583c
adca95f
7eb583c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
adca95f
7eb583c
adca95f
 
 
 
 
 
 
 
 
 
7eb583c
adca95f
 
 
 
7eb583c
adca95f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# VLM 3R Data Processing


## 04.09 更新 数据说明

04.09 处理了scannet数据集中关于scene0000_00的metadata。获取图像和voxel之后,直接拿VLM-3R-DATA中的数据筛选了关于scene0000_00对应的QA,QA种类很多。


### 数据结构

#### 图像/视频数据
视频数据:`data/processed_data/ScanNet/videos/train`


图像数据(经过一定的过滤):`data/processed_data/ScanNet/color/train/scene0000_00`

#### QA
`data/scannet`下
其中有两个训练数据集,VSIBench 和 VSDRBench的核心区别在于对时间动态性和空间参考系的侧重不同。

简单来说:VSIBench 考察的是“场景本身的静态物理属性”,而 VSDRBench 考察的是“由相机运动(观察者)带来的动态时空关系”。

以下是具体的对比总结:
1. VSIBench (Video Scene Instance Benchmark)
核心定位:静态场景理解 (Static scene understanding)。

参考系:主要基于世界坐标系或物体中心参考系(Object-centric)。

考察能力:假设时间静止(或将视频单纯视为多视角图像集合),模型能否理解场景的内在几何与物理属性。

典型任务:

存在与属性:算一算有几个物体(get_obj_count),估算物体的绝对尺寸(get_obj_size)或房间的面积(get_room_size)。

物体间绝对/相对空间:计算物体 A 和物体 B 的绝对距离(get_obj_abs_distance),判断谁离目标物体更近(get_obj_rel_distance),或者物体间的相对方位(前后左右,get_obj_rel_direction)。

2. VSDRBench (Video Scene Dynamic Reasoning Benchmark)
核心定位:视频场景动态推理 (Video Scene Dynamic Reasoning)。

参考系:强烈依赖相机/第一人称参考系(Camera-centric / Egocentric)。
考察能力:模型能否理解随着时间的推移和视角的移动,空间关系是如何发生变化的。它要求模型不仅懂三维空间,还要懂相机的运动轨迹(Odometry/Egomotion)。

典型任务:

相机运动感知:估算相机在两帧之间移动了多远(get_camera_displacement),判断相机是在平移(前后左右上下,get_cam_motion_trans)还是在旋转(俯仰/偏航/滚转,get_cam_motion_rot)。

相机与物体的动态关系:特定帧中物体距离相机多远(get_cam_obj_abs_dist),随时间推移距离如何变化(变远还是变近,get_cam_obj_dist_change),物体在相机视野的哪个方向(get_cam_obj_rel_dir),以及谁离相机最近。

视角依赖的物理现象:判断在特定视角下,哪个物体被另一个物体遮挡了(get_occlusion)。



#### voxel的数据 
 
 在/data/processed_data/ScanNet/point_cloud/train下

`scene0000_00_voxel_0.1.ply`后面的数据对应不同的voxel_size 
voxel的结构:

- 这 N 行数据中,每一行代表一个体素块(Voxel)。由于我们做了 np.hstack 拼接,每一行的 8 个数值分别代表:

- [:, 0:3] (X, Y, Z): 这是体素的空间坐标。经过前面的处理(通常是除以 voxel_size 后向下取整),这些坐标通常已经变成了离散的整数索引。你可以把它理解为 3D 空间中网格的行、列、层号(比如 [10, 5, -2]),而不是真实的物理米数。

- [:, 3:6] (R, G, B): 颜色通道。也就是这个体素块呈现的颜色(通常是 0-255 的整数)。如果一个体素格子里原本包含了多个真实点,由于前面我们使用了 np.unique(..., return_index=True),这里保留的是第一个落入该格子的点的颜色。

- [:, 6] (Label): 语义标签(Semantic ID)。比如 3 代表椅子,4 代表桌子。用于语义分割任务。对应的种类在`VLM-3R/vlm_3r_data_process/datasets/ScanNet200/scannet200_constants.py`(最下面有补充)


- [:, 7] (Instance): 实例 ID(Instance ID)。用于区分同类物体的不同个体。比如场景里有两把椅子,它们的 Label 都是 3,但 Instance ID 可能是 101 和 102。

##### 读取voxel

```python

def read_custom_ply(filepath):
    """
    第一步:读取包含自定义 label 和 instance_id 的 PLY 文件
    """
    print(f"正在读取文件: {filepath}")
    with open(filepath, 'rb') as f:
        plydata = PlyData.read(f)
    
    vertex_data = plydata['vertex'].data
    
    # 提取各个字段
    x = vertex_data['x']
    y = vertex_data['y']
    z = vertex_data['z']
    r = vertex_data['red']
    g = vertex_data['green']
    b = vertex_data['blue']
    label = vertex_data['label']
    instance = vertex_data['instance_id']
    
    # 拼装回 N x 8 的矩阵
    voxel_pc = np.vstack((x, y, z, r, g, b, label, instance)).T
    return voxel_pc

```
可视化可以运行
```bash
python vis_data_my.py
```
![voxel_rgb.png](assert/voxel_rgb.png)

![semantic.png](assert/semantic.png)



如果这些都不符合要求执行修改voxel_size.
```bash
python datasets/ScanNet200/preprocess_scannet200.py \
        --dataset_root ./data/raw_data/scannet/scans \
        --output_root ./data/processed_data/ScanNet/point_cloud \
        --label_map_file ./data/raw_data/scannet/scannetv2-labels.combined.tsv \
        --train_val_splits_path datasets/ScanNet200/Tasks \
        --num_workers 4 \
        --voxel_size 0.1
```



#### scannet200_constants.py

```python
### ScanNet Benchmark constants ###
VALID_CLASS_IDS_20 = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 24, 28, 33, 34, 36, 39)

CLASS_LABELS_20 = ('wall', 'floor', 'cabinet', 'bed', 'chair', 'sofa', 'table', 'door', 'window',
                   'bookshelf', 'picture', 'counter', 'desk', 'curtain', 'refrigerator',
                   'shower curtain', 'toilet', 'sink', 'bathtub', 'otherfurniture')

SCANNET_COLOR_MAP_20 = {
    0: (0., 0., 0.),
    1: (174., 199., 232.),
    2: (152., 223., 138.),
    3: (31., 119., 180.),
    4: (255., 187., 120.),
    5: (188., 189., 34.),
    6: (140., 86., 75.),
    7: (255., 152., 150.),
    8: (214., 39., 40.),
    9: (197., 176., 213.),
    10: (148., 103., 189.),
    11: (196., 156., 148.),
    12: (23., 190., 207.),
    14: (247., 182., 210.),
    15: (66., 188., 102.),
    16: (219., 219., 141.),
    17: (140., 57., 197.),
    18: (202., 185., 52.),
    19: (51., 176., 203.),
    20: (200., 54., 131.),
    21: (92., 193., 61.),
    22: (78., 71., 183.),
    23: (172., 114., 82.),
    24: (255., 127., 14.),
    25: (91., 163., 138.),
    26: (153., 98., 156.),
    27: (140., 153., 101.),
    28: (158., 218., 229.),
    29: (100., 125., 154.),
    30: (178., 127., 135.),
    32: (146., 111., 194.),
    33: (44., 160., 44.),
    34: (112., 128., 144.),
    35: (96., 207., 209.),
    36: (227., 119., 194.),
    37: (213., 92., 176.),
    38: (94., 106., 211.),
    39: (82., 84., 163.),
    40: (100., 85., 144.),
}

### ScanNet200 Benchmark constants ###
VALID_CLASS_IDS_200 = (
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 84, 86, 87, 88, 89, 90, 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 110, 112, 115, 116, 118, 120, 121, 122, 125, 128, 130, 131, 132, 134, 136, 138, 139, 140, 141, 145, 148, 154,
155, 156, 157, 159, 161, 163, 165, 166, 168, 169, 170, 177, 180, 185, 188, 191, 193, 195, 202, 208, 213, 214, 221, 229, 230, 232, 233, 242, 250, 261, 264, 276, 283, 286, 300, 304, 312, 323, 325, 331, 342, 356, 370, 392, 395, 399, 408, 417,
488, 540, 562, 570, 572, 581, 609, 748, 776, 1156, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191)

CLASS_LABELS_200 = (
'wall', 'chair', 'floor', 'table', 'door', 'couch', 'cabinet', 'shelf', 'desk', 'office chair', 'bed', 'pillow', 'sink', 'picture', 'window', 'toilet', 'bookshelf', 'monitor', 'curtain', 'book', 'armchair', 'coffee table', 'box',
'refrigerator', 'lamp', 'kitchen cabinet', 'towel', 'clothes', 'tv', 'nightstand', 'counter', 'dresser', 'stool', 'cushion', 'plant', 'ceiling', 'bathtub', 'end table', 'dining table', 'keyboard', 'bag', 'backpack', 'toilet paper',
'printer', 'tv stand', 'whiteboard', 'blanket', 'shower curtain', 'trash can', 'closet', 'stairs', 'microwave', 'stove', 'shoe', 'computer tower', 'bottle', 'bin', 'ottoman', 'bench', 'board', 'washing machine', 'mirror', 'copier',
'basket', 'sofa chair', 'file cabinet', 'fan', 'laptop', 'shower', 'paper', 'person', 'paper towel dispenser', 'oven', 'blinds', 'rack', 'plate', 'blackboard', 'piano', 'suitcase', 'rail', 'radiator', 'recycling bin', 'container',
'wardrobe', 'soap dispenser', 'telephone', 'bucket', 'clock', 'stand', 'light', 'laundry basket', 'pipe', 'clothes dryer', 'guitar', 'toilet paper holder', 'seat', 'speaker', 'column', 'bicycle', 'ladder', 'bathroom stall', 'shower wall',
'cup', 'jacket', 'storage bin', 'coffee maker', 'dishwasher', 'paper towel roll', 'machine', 'mat', 'windowsill', 'bar', 'toaster', 'bulletin board', 'ironing board', 'fireplace', 'soap dish', 'kitchen counter', 'doorframe',
'toilet paper dispenser', 'mini fridge', 'fire extinguisher', 'ball', 'hat', 'shower curtain rod', 'water cooler', 'paper cutter', 'tray', 'shower door', 'pillar', 'ledge', 'toaster oven', 'mouse', 'toilet seat cover dispenser',
'furniture', 'cart', 'storage container', 'scale', 'tissue box', 'light switch', 'crate', 'power outlet', 'decoration', 'sign', 'projector', 'closet door', 'vacuum cleaner', 'candle', 'plunger', 'stuffed animal', 'headphones', 'dish rack',
'broom', 'guitar case', 'range hood', 'dustpan', 'hair dryer', 'water bottle', 'handicap bar', 'purse', 'vent', 'shower floor', 'water pitcher', 'mailbox', 'bowl', 'paper bag', 'alarm clock', 'music stand', 'projector screen', 'divider',
'laundry detergent', 'bathroom counter', 'object', 'bathroom vanity', 'closet wall', 'laundry hamper', 'bathroom stall door', 'ceiling light', 'trash bin', 'dumbbell', 'stair rail', 'tube', 'bathroom cabinet', 'cd case', 'closet rod',
'coffee kettle', 'structure', 'shower head', 'keyboard piano', 'case of water bottles', 'coat rack', 'storage organizer', 'folded chair', 'fire alarm', 'power strip', 'calendar', 'poster', 'potted plant', 'luggage', 'mattress')

SCANNET_COLOR_MAP_200 = {
0: (0., 0., 0.),
1: (174., 199., 232.),
2: (188., 189., 34.),
3: (152., 223., 138.),
4: (255., 152., 150.),
5: (214., 39., 40.),
6: (91., 135., 229.),
7: (31., 119., 180.),
8: (229., 91., 104.),
9: (247., 182., 210.),
10: (91., 229., 110.),
11: (255., 187., 120.),
13: (141., 91., 229.),
14: (112., 128., 144.),
15: (196., 156., 148.),
16: (197., 176., 213.),
17: (44., 160., 44.),
18: (148., 103., 189.),
19: (229., 91., 223.),
21: (219., 219., 141.),
22: (192., 229., 91.),
23: (88., 218., 137.),
24: (58., 98., 137.),
26: (177., 82., 239.),
27: (255., 127., 14.),
28: (237., 204., 37.),
29: (41., 206., 32.),
31: (62., 143., 148.),
32: (34., 14., 130.),
33: (143., 45., 115.),
34: (137., 63., 14.),
35: (23., 190., 207.),
36: (16., 212., 139.),
38: (90., 119., 201.),
39: (125., 30., 141.),
40: (150., 53., 56.),
41: (186., 197., 62.),
42: (227., 119., 194.),
44: (38., 100., 128.),
45: (120., 31., 243.),
46: (154., 59., 103.),
47: (169., 137., 78.),
48: (143., 245., 111.),
49: (37., 230., 205.),
50: (14., 16., 155.),
51: (196., 51., 182.),
52: (237., 80., 38.),
54: (138., 175., 62.),
55: (158., 218., 229.),
56: (38., 96., 167.),
57: (190., 77., 246.),
58: (208., 49., 84.),
59: (208., 193., 72.),
62: (55., 220., 57.),
63: (10., 125., 140.),
64: (76., 38., 202.),
65: (191., 28., 135.),
66: (211., 120., 42.),
67: (118., 174., 76.),
68: (17., 242., 171.),
69: (20., 65., 247.),
70: (208., 61., 222.),
71: (162., 62., 60.),
72: (210., 235., 62.),
73: (45., 152., 72.),
74: (35., 107., 149.),
75: (160., 89., 237.),
76: (227., 56., 125.),
77: (169., 143., 81.),
78: (42., 143., 20.),
79: (25., 160., 151.),
80: (82., 75., 227.),
82: (253., 59., 222.),
84: (240., 130., 89.),
86: (123., 172., 47.),
87: (71., 194., 133.),
88: (24., 94., 205.),
89: (134., 16., 179.),
90: (159., 32., 52.),
93: (213., 208., 88.),
95: (64., 158., 70.),
96: (18., 163., 194.),
97: (65., 29., 153.),
98: (177., 10., 109.),
99: (152., 83., 7.),
100: (83., 175., 30.),
101: (18., 199., 153.),
102: (61., 81., 208.),
103: (213., 85., 216.),
104: (170., 53., 42.),
105: (161., 192., 38.),
106: (23., 241., 91.),
107: (12., 103., 170.),
110: (151., 41., 245.),
112: (133., 51., 80.),
115: (184., 162., 91.),
116: (50., 138., 38.),
118: (31., 237., 236.),
120: (39., 19., 208.),
121: (223., 27., 180.),
122: (254., 141., 85.),
125: (97., 144., 39.),
128: (106., 231., 176.),
130: (12., 61., 162.),
131: (124., 66., 140.),
132: (137., 66., 73.),
134: (250., 253., 26.),
136: (55., 191., 73.),
138: (60., 126., 146.),
139: (153., 108., 234.),
140: (184., 58., 125.),
141: (135., 84., 14.),
145: (139., 248., 91.),
148: (53., 200., 172.),
154: (63., 69., 134.),
155: (190., 75., 186.),
156: (127., 63., 52.),
157: (141., 182., 25.),
159: (56., 144., 89.),
161: (64., 160., 250.),
163: (182., 86., 245.),
165: (139., 18., 53.),
166: (134., 120., 54.),
168: (49., 165., 42.),
169: (51., 128., 133.),
170: (44., 21., 163.),
177: (232., 93., 193.),
180: (176., 102., 54.),
185: (116., 217., 17.),
188: (54., 209., 150.),
191: (60., 99., 204.),
193: (129., 43., 144.),
195: (252., 100., 106.),
202: (187., 196., 73.),
208: (13., 158., 40.),
213: (52., 122., 152.),
214: (128., 76., 202.),
221: (187., 50., 115.),
229: (180., 141., 71.),
230: (77., 208., 35.),
232: (72., 183., 168.),
233: (97., 99., 203.),
242: (172., 22., 158.),
250: (155., 64., 40.),
261: (118., 159., 30.),
264: (69., 252., 148.),
276: (45., 103., 173.),
283: (111., 38., 149.),
286: (184., 9., 49.),
300: (188., 174., 67.),
304: (53., 206., 53.),
312: (97., 235., 252.),
323: (66., 32., 182.),
325: (236., 114., 195.),
331: (241., 154., 83.),
342: (133., 240., 52.),
356: (16., 205., 144.),
370: (75., 101., 198.),
392: (237., 95., 251.),
395: (191., 52., 49.),
399: (227., 254., 54.),
408: (49., 206., 87.),
417: (48., 113., 150.),
488: (125., 73., 182.),
540: (229., 32., 114.),
562: (158., 119., 28.),
570: (60., 205., 27.),
572: (18., 215., 201.),
581: (79., 76., 153.),
609: (134., 13., 116.),
748: (192., 97., 63.),
776: (108., 163., 18.),
1156: (95., 220., 156.),
1163: (98., 141., 208.),
1164: (144., 19., 193.),
1165: (166., 36., 57.),
1166: (212., 202., 34.),
1167: (23., 206., 34.),
1168: (91., 211., 236.),
1169: (79., 55., 137.),
1170: (182., 19., 117.),
1171: (134., 76., 14.),
1172: (87., 185., 28.),
1173: (82., 224., 187.),
1174: (92., 110., 214.),
1175: (168., 80., 171.),
1176: (197., 63., 51.),
1178: (175., 199., 77.),
1179: (62., 180., 98.),
1180: (8., 91., 150.),
1181: (77., 15., 130.),
1182: (154., 65., 96.),
1183: (197., 152., 11.),
1184: (59., 155., 45.),
1185: (12., 147., 145.),
1186: (54., 35., 219.),
1187: (210., 73., 181.),
1188: (221., 124., 77.),
1189: (149., 214., 66.),
1190: (72., 185., 134.),
1191: (42., 94., 198.),
}

### For instance segmentation the non-object categories ###
VALID_PANOPTIC_IDS = (1, 3)

CLASS_LABELS_PANOPTIC = ('wall', 'floor')
```