BillLin66 commited on
Commit
f4fe7bc
·
verified ·
1 Parent(s): 77b5c05

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. ASE_exported/README.md +113 -0
  2. ASE_exported/data/atek/cubercnn/train/80967/annotations.tar.gz +3 -0
  3. ASE_exported/data/atek/cubercnn/train/80993/annotations.tar.gz +3 -0
  4. ASE_exported/data/atek/cubercnn/train/81089/annotations.tar.gz +3 -0
  5. ASE_exported/data/atek/cubercnn/train/81277/annotations.tar.gz +3 -0
  6. ASE_exported/data/atek/cubercnn/train/81419/annotations.tar.gz +3 -0
  7. ASE_exported/data/atek/cubercnn/train/81841/annotations.tar.gz +3 -0
  8. ASE_exported/data/atek/cubercnn/train/82268/annotations.tar.gz +3 -0
  9. ASE_exported/data/atek/cubercnn/train/82866/annotations.tar.gz +3 -0
  10. ASE_exported/data/atek/cubercnn/train/82892/annotations.tar.gz +3 -0
  11. ASE_exported/data/atek/cubercnn/train/83188/annotations.tar.gz +3 -0
  12. ASE_exported/data/atek/cubercnn/train/83518/annotations.tar.gz +3 -0
  13. ASE_exported/data/atek/cubercnn/train/83520/annotations.tar.gz +3 -0
  14. ASE_exported/data/atek/cubercnn/train/83527/annotations.tar.gz +3 -0
  15. ASE_exported/data/atek/cubercnn/train/83940/annotations.tar.gz +3 -0
  16. ASE_exported/data/atek/cubercnn/train/84359/annotations.tar.gz +3 -0
  17. ASE_exported/data/atek/cubercnn/train/84705/annotations.tar.gz +3 -0
  18. ASE_exported/data/atek/cubercnn/train/84957/annotations.tar.gz +3 -0
  19. ASE_exported/data/atek/cubercnn/train/85429/annotations.tar.gz +3 -0
  20. ASE_exported/data/atek/cubercnn/train/85871/annotations.tar.gz +3 -0
  21. ASE_exported/data/atek/cubercnn/train/8588/annotations.tar.gz +3 -0
  22. ASE_exported/data/atek/cubercnn/train/85885/annotations.tar.gz +3 -0
  23. ASE_exported/data/atek/cubercnn/train/86052/annotations.tar.gz +3 -0
  24. ASE_exported/data/atek/cubercnn/train/86055/annotations.tar.gz +3 -0
  25. ASE_exported/data/atek/cubercnn/train/86258/annotations.tar.gz +3 -0
  26. ASE_exported/data/atek/cubercnn/train/86856/annotations.tar.gz +3 -0
  27. ASE_exported/data/atek/cubercnn/train/87180/annotations.tar.gz +3 -0
  28. ASE_exported/data/atek/cubercnn/train/87187/annotations.tar.gz +3 -0
  29. ASE_exported/data/atek/cubercnn/train/87528/annotations.tar.gz +3 -0
  30. ASE_exported/data/atek/cubercnn/train/87970/annotations.tar.gz +3 -0
  31. ASE_exported/data/atek/cubercnn/train/87984/annotations.tar.gz +3 -0
  32. ASE_exported/data/atek/cubercnn/train/88104/annotations.tar.gz +3 -0
  33. ASE_exported/data/atek/cubercnn/train/88336/annotations.tar.gz +3 -0
  34. ASE_exported/data/atek/cubercnn/train/88560/annotations.tar.gz +3 -0
  35. ASE_exported/data/atek/cubercnn/train/88594/annotations.tar.gz +3 -0
  36. ASE_exported/data/atek/cubercnn/train/88752/annotations.tar.gz +3 -0
  37. ASE_exported/data/atek/cubercnn/train/88938/annotations.tar.gz +3 -0
  38. ASE_exported/data/atek/cubercnn/train/89022/annotations.tar.gz +3 -0
  39. ASE_exported/data/atek/cubercnn/train/89210/annotations.tar.gz +3 -0
  40. ASE_exported/data/atek/cubercnn/train/89228/annotations.tar.gz +3 -0
  41. ASE_exported/data/atek/cubercnn/train/8924/annotations.tar.gz +3 -0
  42. ASE_exported/data/atek/cubercnn/train/89446/annotations.tar.gz +3 -0
  43. ASE_exported/data/atek/cubercnn/train/89674/annotations.tar.gz +3 -0
  44. ASE_exported/data/atek/cubercnn/train/89680/annotations.tar.gz +3 -0
  45. ASE_exported/data/atek/cubercnn/train/901/annotations.tar.gz +3 -0
  46. ASE_exported/data/atek/cubercnn/train/9234/annotations.tar.gz +3 -0
  47. ASE_exported/kits/convert_ase.py +438 -0
  48. ASE_exported/kits/download_ase.py +369 -0
  49. ASE_exported/kits/unify_ase.py +56 -0
  50. ASE_exported/kits/verify_ase.py +278 -0
ASE_exported/README.md ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ASE 导出
2
+
3
+ ## 目录
4
+
5
+ ```text
6
+ ASE_exported/
7
+ ├── README.md
8
+ ├── data/
9
+ │ ├── index.json
10
+ │ ├── original/<split>/<scene>/
11
+ │ │ ├── ase_scene_language.txt
12
+ │ │ └── object_instances_to_classes.json
13
+ │ └── atek/cubercnn/train/<scene>/annotations.tar.gz
14
+ ├── kits/
15
+ │ ├── download_ase.py
16
+ │ ├── convert_ase.py
17
+ │ ├── unify_ase.py
18
+ │ └── verify_ase.py
19
+ ├── ase.jsonl
20
+ ├── source_inventory.json
21
+ ├── json_room.json
22
+ └── multiroom/
23
+ ├── json_multi_merged.json
24
+ └── json_multi_split.json
25
+ ```
26
+
27
+ `data/` 仅保留已选源标注,不含视频、RGB 或完整远端分片。上游缺失的语言或类别文件不会补造。`index.json` 是转换所需的源文件定位与选择索引;`annotations.tar.gz` 存放选中的原始 GT 成员。
28
+
29
+ 上图为本地及解压后的目录。Hugging Face 交付将 `data/original/` 原样打包为 `data/original.tar.gz`,避免其 train 下 100,000 个场景目录超过 Hub 每层 10,000 条目的限制。下载后在 `ASE_exported/` 内执行 `tar -xzf data/original.tar.gz -C data` 即恢复上述路径,随后脚本与 `index.json` 无需修改;其余文件保持原目录结构。
30
+
31
+ `ase.jsonl` 与 `multiroom/json_multi_merged.json` 分别以 JSONL、JSON 数组保存 8,373 个完整场景;`json_room.json` 包含全部 16,375 个逐房间场景;`json_multi_split.json` 仅包含多房间场景拆出的 12,936 个房间。完整场景共含 396,948 条已归房家具,保留其中 331 个空房间。`source_inventory.json` 是这 8,373 个场景的源信息与未归房实例配套清单。
32
+
33
+ `kits/` 保留下载、转换、汇总和验收脚本。本地 `.git/`、`.gitignore` 可保留,上传 Hugging Face 时排除。
34
+
35
+ ## 上游源数据
36
+
37
+ 源数据为 Meta 的 Aria Synthetic Environments。原始 ZIP 提供场景语言和实例类别;ATEK 的 `cubercnn/train` 标注提供实例框、位姿和相机下的 GT 记录。两者通过原始场景号、实例 ID 对应。
38
+
39
+ 下载入口来自官方 [EFM3D 数据说明](https://github.com/facebookresearch/efm3d/blob/61d30ed4eca836ab0d5e63df18bb4b915050fa89/data/README.md)及 [ATEK 仓库](https://github.com/facebookresearch/atek/tree/aae40aa7d5b9573b5b81460467d7377c519127fb),对应清单为 `aria_synthetic_environments_dataset_download_urls.json`、`AriaSyntheticEnvironment_ATEK_download_urls.json`。具体本地选择以 `data/index.json` 为准。
40
+
41
+ 原始索引覆盖 101,000 个场景,但所用 ATEK 清单只覆盖 9,966 个 train 场景。导出还要求能够形成房间记录,且至少一个房间有已归入家具,因此当前交付为 8,373 个 train 场景,不代表原数据集全量。`source_subset` 始终取原始 ZIP 的划分,不改写为模型任务划分。
42
+
43
+ ## schema 字段表
44
+
45
+ 字段以[转换脚本](kits/convert_ase.py)和[汇总脚本](kits/unify_ase.py)为准。长度为米,面积为平方米。原坐标 Z-up、场景全局原点,源未声明手性;家具位置为源 OBB 中心,尺寸为局部 XYZ 全尺寸,旋转满足 `R = Rz · Ry · Rx`,单位为度。
46
+
47
+ ### 场景字段
48
+
49
+ | 字段 | 类型 | 来源与取值 |
50
+ |---|---|---|
51
+ | `scene_id` | string | 完整场景为 `ase_<split>_<源场景号补足7位>`;逐房间视图改为对应 `room_id`。 |
52
+ | `sample_id` | string | 与所在视图的 `scene_id` 相同。 |
53
+ | `dataset` | string | `ASE`。 |
54
+ | `source_dataset` | string | `aria_synthetic_environments`。 |
55
+ | `source_subset` | string | 原始 ZIP 划分 `train` 或 `test`;当前交付只有 `train`。 |
56
+ | `room_count` | integer | `len(rooms)`,逐房间视图为 1。 |
57
+ | `total_area` | number / null | 完整场景累加已知房间面积,全部缺失则 `null`;逐房间视图取该房间面积。部分缺失时只是已知部分之和。 |
58
+ | `building_style` | null | 无源风格标注。 |
59
+ | `description` | null | 不从场景命令生成描述。 |
60
+ | `description_source` | null | 无描述来源。 |
61
+ | `provenance` | object | `source_file` 为原始 ZIP 文件名,`source_scene_index` 为原始场景号整数,`split` 为原始划分。 |
62
+ | `rooms` | array<object> | 按墙端点连通组建立房间,按组内最小 wall ID 排序;保留场景中的空房间。 |
63
+
64
+ ### 房间字段
65
+
66
+ | 字段 | 类型 | 来源与取值 |
67
+ |---|---|---|
68
+ | `room_id` | string | `<完整scene_id>::room_<room_index>`。 |
69
+ | `room_index` | integer | 墙组排序后的连续索引,从 0 开始。 |
70
+ | `room_type` | string / null | 项目决定:按已归房家具的 ATEK `category_ids` 与边界顶点数推断,规则见下文。 |
71
+ | `room_type_source` | string | 有推断为 `inferred_from_furniture`,否则 `unavailable`。 |
72
+ | `room_boundary` | array<[number, number]> / null | 沿源墙端点邻接关系遍历链或环所得 XY 顶点,不重复起点;开放链以首尾连线闭合,不能完整表达则 `null`。 |
73
+ | `room_boundary_type` | string / null | 有边界为 `wall_polygon`,否则 `null`。 |
74
+ | `room_area_m2` | number / null | 上述轮廓的鞋带面积;无边界则 `null`。 |
75
+ | `room_height` | number / null | 本组源墙 `height` 全部一致时取该值,缺失或不一致则 `null`,不平均。 |
76
+ | `coordinate_system` | string | 固定说明米制、源手性未声明、Z-up、场景全局原点、OBB 中心与局部尺寸、ZYX 欧拉角。 |
77
+ | `doors` | array<object> | 源 `make_door` 通过 wall ID 关联本组,每项为 `{position:{x,y,z}, width, height}`;无记录为 `[]`。 |
78
+ | `windows` | array<object> | 同 `doors`,来源为 `make_window`。同一开口关联两房间时分别保留。 |
79
+ | `furniture_quantity` | integer | `len(furniture)`,不是源类别表总数。 |
80
+ | `furniture` | array<object> | 非结构实例按源 OBB 中心 XY 唯一归房,按实例 ID 排序;无法唯一归房的进入配套清单。 |
81
+ | `source_fields` | object | `make_wall`、`make_door`、`make_window` 数组,保留本组墙和关联开口的完整原参数。 |
82
+
83
+ 房型使用 ATEK 类别 ID 6 作为睡眠信号、ID 4 作为沙发信号。边界顶点多于 4 时,有睡眠信号为 `apartment`,否则有沙发为 `living room`;其他情况下,两种信号均有为 `studio`,只有睡眠为 `bedroom`,只有沙发为 `living room`。无信号为 `null`。这些是项目推断,不是上游房型标签。
84
+
85
+ ### 家具字段
86
+
87
+ | 字段 | 类型 | 来源与取值 |
88
+ |---|---|---|
89
+ | `furniture_category` | string / null | 仅取 `object_instances_to_classes.json[str(instance_id)]` 原字符串;缺失则 `null`,不用 ATEK 合并类别补值。 |
90
+ | `furniture_instance_id` | string | `<完整scene_id>::inst_<源instance_id>`。 |
91
+ | `furniture_position` | object / null | ATEK `ts_world_object` 平移列对应的 `{x,y,z}`;无 GT 则 `null`。 |
92
+ | `furniture_rotation` | object | ATEK 旋转矩阵分解出的 `{x:roll,y:pitch,z:yaw}`,角度归一到 `[-180,180)`,保留 8 位小数;无 GT 则三个分量均为 `null`。 |
93
+ | `furniture_size` | object / null | 源 `object_dimensions` 的 X/Y/Z 对应 `{width,length,height}`;不乘 2、不按长短边重排,无 GT 则 `null`。 |
94
+ | `source_fields` | object | 有 GT 时保留 `source_file`、`obb3_gt`、`obb2_gt`;无 GT 为 `{}`。源路径相对导出根目录,归档成员以 `::` 定位。 |
95
+
96
+ `obb3_gt` 按源 camera 保存单实例切片,保留 `instance_ids`、`category_names`、`category_ids`、`object_dimensions`、`ts_world_object` 的原键与批维。`obb2_gt` 同样保留 `instance_ids`、`category_names`、`category_ids`、`box_ranges`、`visibility_ratios`;缺失 2D 记录为 `{}`。
97
+
98
+ ### 配套清单字段
99
+
100
+ | 字段 | 类型 | 来源与取值 |
101
+ |---|---|---|
102
+ | `scene_id` | string | 对应完整场景 ID。 |
103
+ | `unassigned_objects` | array<object> | 家具 schema 的实例记录:无位置、未落入任何房间或落入多个房间。 |
104
+ | `structural_instances` | array<object> | 被识别为 `wall`、`floor`、`ceiling`、`door`、`window` 的实例记录,不计入房间家具。 |
105
+ | `source_fields` | object | `object_instances_to_classes` 原类别表,以及场景语言的全部命令及参数。 |
106
+
107
+ ## 已知缺陷
108
+
109
+ - 所选 GT 只覆盖原数据集的一部分场景和实例;有类别表不代表有几何。全部房间为空或没有房间的场景不进入交付,其配套清单也不输出,需回查源数据。
110
+ - 墙端点连通组不等于建筑学房间,可能包含整个住宅。开放墙链的首尾连线没有缺口距离限制;分叉或无法遍历的组边界为空,影响面积和家具归属。
111
+ - 家具按中心点唯一归房,不按物体实际占地切分;边界附近、跨房间或几何缺失的对象可能进入未归房清单。
112
+ - 房型仅有 `apartment`、`studio`、`bedroom`、`living room` 四类及 `null`,无法表达厨房等类型;源家具类别与 ATEK 推断类别采用不同词表。
113
+ - 同一实例有多条 GT 时采用所选记录中的第一条;所留片段不能保证覆盖完整序列中的所有冲突或可见实例。门窗是墙引用的开口,不能视为与实例清单一一对应。
ASE_exported/data/atek/cubercnn/train/80967/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5d194000aa76ef834d1f7e97db64af83e6e01d917ab611d37423388bb3b6e5f
3
+ size 16807
ASE_exported/data/atek/cubercnn/train/80993/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae34b42630b34ea0cc0207258ae6dbb3106bb865189f189593ab8520b3060c25
3
+ size 33767
ASE_exported/data/atek/cubercnn/train/81089/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b7167b85a31c2a353f5eee3af0cba357ab74bcc008bcfa5deedd59ab5d93c702
3
+ size 18559
ASE_exported/data/atek/cubercnn/train/81277/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2dbe11c96eb4c6bfa1ee85db09c98be5af2b4acf845b44c1c9699034bff8b58a
3
+ size 47589
ASE_exported/data/atek/cubercnn/train/81419/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e3ab44a87d85c9c20a48a59f870c18d6e0654fff32a117845fde420dfd7693e
3
+ size 56079
ASE_exported/data/atek/cubercnn/train/81841/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:406fd0266867b75cc9a02b9c91267c13842468e52625d471d513cea71dc58cb4
3
+ size 13212
ASE_exported/data/atek/cubercnn/train/82268/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bbc67eeed9be7b44841a907ecbc54845081ebe15a8bfb7e6938ca36d2ad0d08
3
+ size 25838
ASE_exported/data/atek/cubercnn/train/82866/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4079eea5ee401092e26be1bd1c085049aabb41f2e5a1497b00e113c154d682b4
3
+ size 36718
ASE_exported/data/atek/cubercnn/train/82892/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f380df0e1a8350d59bb8b893b223fe8b2e6a303ab3c99fe488210611cceb9f42
3
+ size 31967
ASE_exported/data/atek/cubercnn/train/83188/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:769469db93f973e8dd663fc534cebe69956693e5b68753f7d38e61798fb4e377
3
+ size 32784
ASE_exported/data/atek/cubercnn/train/83518/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b81a50a55ab20af09b20d26d5316bd7006000216819c10e9bfcd48b5e75b1b7
3
+ size 12672
ASE_exported/data/atek/cubercnn/train/83520/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b4dbd77a0b3ea76fc8c17509b67df95caae55d5fb0976051154e027ed092faa
3
+ size 8813
ASE_exported/data/atek/cubercnn/train/83527/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c09685bd7e49c68115bbbfa7c1f8cb260bdba94239d3dcd81ca02f32104757c
3
+ size 36304
ASE_exported/data/atek/cubercnn/train/83940/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:03c1979fb32b59bacbe5021273c597b268e681c685d47643092aa27440721761
3
+ size 8354
ASE_exported/data/atek/cubercnn/train/84359/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01549eed809ceb3b8f090c40db34de80dd305ffd3ee7c5154f5b460e951f293e
3
+ size 4620
ASE_exported/data/atek/cubercnn/train/84705/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3068f8ef1a70f54893df3079dd5a38072d50b37816d6bd72bf45d1d0c2e9a8cb
3
+ size 10189
ASE_exported/data/atek/cubercnn/train/84957/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6671d05e1a0bf72a52485f8f9f91d36423c9a66af7060652f2b3b8ba4f75d969
3
+ size 36435
ASE_exported/data/atek/cubercnn/train/85429/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca2a16e8964fc961267132bd349664f53fdf37f6b3fe59de3398b3f72b74b127
3
+ size 30644
ASE_exported/data/atek/cubercnn/train/85871/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cebab1c2e7cc5a5d4a71f74ff1ad34e780a92031d09cced7b283e3af620f59c3
3
+ size 9304
ASE_exported/data/atek/cubercnn/train/8588/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a247d9381f29185da1a995df35173554a2ffa40083f424b556fc036ff85dd3ac
3
+ size 13145
ASE_exported/data/atek/cubercnn/train/85885/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0184ab116bbc701601f42fff2aa188ac8417b62f7552aded5295f7bcd9ee18e7
3
+ size 30442
ASE_exported/data/atek/cubercnn/train/86052/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79f2ba946c642b7207dd39b50600dbbafd3ebc01ad69037319fa58cda3f804df
3
+ size 38695
ASE_exported/data/atek/cubercnn/train/86055/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:857c67885bf712279e344a2dad3391004f7993b12406903261b40ff6d2c0a81f
3
+ size 19314
ASE_exported/data/atek/cubercnn/train/86258/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:031b55c1c48f7cc0ece4326a1ab024ea9baaa05cefcf8a468470e3e35cf6e0c6
3
+ size 31482
ASE_exported/data/atek/cubercnn/train/86856/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ede3e062bc65d55b88eea68de25250ae038d7c620c2379aa4cb2c6b94f253b62
3
+ size 10762
ASE_exported/data/atek/cubercnn/train/87180/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dca06e3942c952db17093953afdd9bc0881ed2fb72142fc0ac1f4a15caeb54d7
3
+ size 22883
ASE_exported/data/atek/cubercnn/train/87187/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d582d9685c85ba492d42d45300067da5011fc6ae790ad1bfd6da95d0ae81dbd
3
+ size 32007
ASE_exported/data/atek/cubercnn/train/87528/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e636960fedbc7fbfe47771d779bfe4b36ad5bc506cc4c43db5ac4274db48f030
3
+ size 15360
ASE_exported/data/atek/cubercnn/train/87970/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:23d0da615e6ebc2c358c4c6330f514ccb660c0b551772ac190950117284cea60
3
+ size 7038
ASE_exported/data/atek/cubercnn/train/87984/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0601b5a385d3ef67963214769c663ae55cad18626b563f8f3247a2794e876e12
3
+ size 23529
ASE_exported/data/atek/cubercnn/train/88104/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f520a2644031c30deb68948e97de99e87f7873568802a38d65edea6da951817
3
+ size 15257
ASE_exported/data/atek/cubercnn/train/88336/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0225631c47b3109b974bf18fe40f88c85333c6a131ad77ce4bd1e79da2f6e939
3
+ size 64885
ASE_exported/data/atek/cubercnn/train/88560/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b31af3864acaa70c6191c75fa80d152651879c0870400f83f384c9556565ffa
3
+ size 11368
ASE_exported/data/atek/cubercnn/train/88594/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d0a89e87e3bd022d023524a52b00d14e4d0bf879fa7850c55a020c4f4ece8c5
3
+ size 84118
ASE_exported/data/atek/cubercnn/train/88752/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bfc4065b79cb7266fe6ea246ff8b3fdd86773a7e42f6773dcffe8bc0abd2fabf
3
+ size 49962
ASE_exported/data/atek/cubercnn/train/88938/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:029d43f5ac85c8bd97b481f6fca9ba341c37e37e3c9f849a1b5fd54bfbbe08ee
3
+ size 19991
ASE_exported/data/atek/cubercnn/train/89022/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c425c39c89091af4afa8cd20373370a215a61debf0f0fdf4817b5850090fee1
3
+ size 63459
ASE_exported/data/atek/cubercnn/train/89210/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38202a5eecf5c3a19446f74e9aa0b0277fe4b9d66d2f458449a407a0cb96de51
3
+ size 71420
ASE_exported/data/atek/cubercnn/train/89228/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2dd0c9151386610b86bb73c9f9c287dd9a55d4db7193e674fd1a27a7e32652f
3
+ size 19940
ASE_exported/data/atek/cubercnn/train/8924/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a63d92762154db195d5315c971bdcce3d702616f442f5b85c64b9fd9f320f4d0
3
+ size 46816
ASE_exported/data/atek/cubercnn/train/89446/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3d68ae018ba75a39ef60c6d7d3a0581b21ff68f37b849a2f64ebead12f07db59
3
+ size 7127
ASE_exported/data/atek/cubercnn/train/89674/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a26336fe42ce11bceb3d927cc38871498048c0047982a08487c784bab095655a
3
+ size 4707
ASE_exported/data/atek/cubercnn/train/89680/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25e3397cf460009410a6cded1af5e645e7534ba97f4c998a8ac2e501e117b7d8
3
+ size 70356
ASE_exported/data/atek/cubercnn/train/901/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb63db6b98b9e2829048f0e1f4ab8afea31c9fa4c78587f52e18b380e3b7a253
3
+ size 46064
ASE_exported/data/atek/cubercnn/train/9234/annotations.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ba8ec6b6438acada040bfe7f5cb2eb26cbff2db9c76dc4c762be88e3605ee8e
3
+ size 37635
ASE_exported/kits/convert_ase.py ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Convert selected ASE source records to the fixed scene/room/furniture schema.
2
+
3
+ Field calculations are the independently reviewed ASE preview implementation.
4
+ No runtime dependency on development files or another exported dataset.
5
+ """
6
+ from __future__ import annotations
7
+ import argparse
8
+ from collections import defaultdict
9
+ from contextlib import contextmanager
10
+ import json
11
+ import io
12
+ import math
13
+ import os
14
+ import tarfile
15
+ import zipfile
16
+ from pathlib import Path
17
+
18
+ class JsonWriter:
19
+ def __init__(self, path, *, lines=False):
20
+ self.path = Path(path)
21
+ self.lines = lines
22
+ self.count = 0
23
+
24
+ def __enter__(self):
25
+ self.path.parent.mkdir(parents=True, exist_ok=True)
26
+ self.tmp = self.path.with_suffix(self.path.suffix + '.part')
27
+ self.handle = self.tmp.open('w', encoding='utf-8')
28
+ if not self.lines:
29
+ self.handle.write('[\n')
30
+ return self
31
+
32
+ def write(self, value):
33
+ encoded = json.dumps(value, ensure_ascii=False, allow_nan=False, separators=(',', ':'))
34
+ if self.count and not self.lines:
35
+ self.handle.write(',\n')
36
+ self.handle.write(encoded)
37
+ if self.lines:
38
+ self.handle.write('\n')
39
+ self.count += 1
40
+
41
+ def __exit__(self, kind, value, traceback):
42
+ try:
43
+ if kind is None:
44
+ if not self.lines:
45
+ self.handle.write('\n]\n')
46
+ self.handle.flush()
47
+ os.fsync(self.handle.fileno())
48
+ finally:
49
+ self.handle.close()
50
+ if kind is None:
51
+ os.replace(self.tmp, self.path)
52
+ else:
53
+ self.tmp.unlink(missing_ok=True)
54
+
55
+
56
+ def load_selection(data_dir, limit):
57
+ index = json.loads((Path(data_dir) / 'index.json').read_text(encoding='utf-8'))
58
+ rows = sorted(index['scenes'], key=lambda r: (r['split'], r['scene_index']))
59
+ identities = [(r['split'], r['scene_index']) for r in rows]
60
+ if len(identities) != len(set(identities)):
61
+ raise ValueError('Duplicate split/scene identities in input index')
62
+ # Enumerate the index, not language/GT files: absent annotations retain scenes.
63
+ return index, rows[:limit] if limit is not None else rows
64
+
65
+
66
+ @contextmanager
67
+ def source_members(reference):
68
+ """Read original members from loose files or archive::member references."""
69
+ filename, separator, member = str(reference).partition('::')
70
+ if separator and filename.endswith('.tar.gz'):
71
+ with tarfile.open(filename, 'r:gz') as archive:
72
+ folder = Path(member).parent.as_posix()
73
+ def read(name):
74
+ target = name if folder == '.' else folder + '/' + name
75
+ return archive.extractfile(target).read()
76
+ yield Path(member).name, read
77
+ elif separator:
78
+ with zipfile.ZipFile(filename) as archive:
79
+ folder = Path(member).parent.as_posix()
80
+ def read(name):
81
+ target = name if folder == '.' else folder + '/' + name
82
+ return archive.read(target)
83
+ yield Path(member).name, read
84
+ else:
85
+ path = Path(filename)
86
+ yield path.name, lambda name: (path.parent / name).read_bytes()
87
+
88
+
89
+ SCENE_KEYS = 'scene_id sample_id dataset source_dataset source_subset room_count total_area building_style description description_source provenance rooms'.split()
90
+ ROOM_KEYS = 'room_id room_index room_type room_type_source room_boundary room_boundary_type room_area_m2 room_height coordinate_system doors windows furniture_quantity furniture source_fields'.split()
91
+ FURNITURE_KEYS = 'furniture_category furniture_instance_id furniture_position furniture_rotation furniture_size source_fields'.split()
92
+ # The two ATEK cubercnn GT namespaces, with the raw member keys each one carries.
93
+ GT_KEYS = {'obb3_gt': ('instance_ids', 'category_ids', 'object_dimensions', 'ts_world_object'),
94
+ 'obb2_gt': ('instance_ids', 'category_ids', 'box_ranges', 'visibility_ratios')}
95
+ # Structured3D STRUCTURAL_LABELS; original ASE names, not ATEK's "other".
96
+ STRUCTURAL = {'wall', 'floor', 'ceiling', 'door', 'window'}
97
+ COORDINATES = ('meter; source handedness not declared; Z-up; scene-global origin; '
98
+ 'furniture position=source OBB center; size=local XYZ full extents; '
99
+ 'rotation=ZYX intrinsic Euler degrees, R=Rz*Ry*Rx; openings=source center')
100
+
101
+
102
+ # Pinned InteriorGS geometry; approved ASE-specific room-type rules (see README).
103
+ def finite(value: object) -> bool:
104
+ return isinstance(value, (int, float)) and math.isfinite(float(value))
105
+
106
+ def point_xy(point: object) -> tuple[float, float] | None:
107
+ if isinstance(point, dict):
108
+ x, y = point.get("x"), point.get("y")
109
+ elif isinstance(point, list) and len(point) >= 2:
110
+ x, y = point[0], point[1]
111
+ else:
112
+ return None
113
+ if not (finite(x) and finite(y)):
114
+ return None
115
+ return float(x), float(y)
116
+
117
+ def polygon_area(profile: list[object]) -> float | None:
118
+ points = [point_xy(p) for p in profile]
119
+ if len(points) < 3 or any(p is None for p in points):
120
+ return None
121
+ area = 0.0
122
+ for (x1, y1), (x2, y2) in zip(points, points[1:] + points[:1]):
123
+ area += x1 * y2 - x2 * y1
124
+ return abs(area) / 2.0
125
+
126
+ def point_in_polygon(x: float, y: float, profile: list[object], eps: float = 1e-8) -> bool:
127
+ points = [point_xy(p) for p in profile]
128
+ if len(points) < 3 or any(p is None for p in points):
129
+ return False
130
+ inside = False
131
+ for (x1, y1), (x2, y2) in zip(points, points[1:] + points[:1]):
132
+ cross = (x - x1) * (y2 - y1) - (y - y1) * (x2 - x1)
133
+ dot = (x - x1) * (x2 - x1) + (y - y1) * (y2 - y1)
134
+ length_sq = (x2 - x1) ** 2 + (y2 - y1) ** 2
135
+ if abs(cross) <= eps and -eps <= dot <= length_sq + eps:
136
+ return True
137
+ if (y1 > y) != (y2 > y):
138
+ crossing_x = (x2 - x1) * (y - y1) / (y2 - y1) + x1
139
+ if x < crossing_x:
140
+ inside = not inside
141
+ return inside
142
+
143
+ def atek_name(entry):
144
+ """Native ATEK label for one instance, the only naming a scene without
145
+ object_instances_to_classes.json has."""
146
+ for record in (entry or {}).get('source_fields', {}).get('obb3_gt', {}).values():
147
+ names = record.get('category_names')
148
+ if names:
149
+ return names[0]
150
+ return None
151
+
152
+
153
+ def atek_category_id(entry):
154
+ """Native ATEK class id. Preferred over the name for room-type inference:
155
+ the id space is global, so it survives the 28,120 scenes that ship no
156
+ object_instances_to_classes.json, where category_names is also absent."""
157
+ for record in (entry or {}).get('source_fields', {}).get('obb3_gt', {}).values():
158
+ ids = record.get('category_ids')
159
+ if ids:
160
+ return ids[0]
161
+ return None
162
+
163
+
164
+ # Neither ASE vocabulary names a bathroom, kitchen or office fixture, so sleeping
165
+ # and seating are the only functions a wall ring can be shown to hold. Chair
166
+ # (95.9% of rooms) and table (76.2%) are too common to discriminate alone.
167
+ # ASE models no interior partitions, so one ring can enclose a whole dwelling.
168
+ # The ring's own shape says which: ASE walls are axis aligned, so a four-vertex
169
+ # ring is exactly one rectangular room and more vertices are a compound footprint.
170
+ # Shape is read first, because what a single room holds and what a whole dwelling
171
+ # holds are different questions.
172
+ SLEEPING_ID, SEATING_ID = 6, 4 # bed / mattress / sleeping bag; sofa
173
+
174
+ def infer_room_type(category_ids, boundary):
175
+ ids = set(category_ids)
176
+ sleeping, seating = SLEEPING_ID in ids, SEATING_ID in ids
177
+ if boundary and len(boundary) > 4:
178
+ return 'apartment' if sleeping else 'living room' if seating else None
179
+ if sleeping:
180
+ return 'studio' if seating else 'bedroom'
181
+ return 'living room' if seating else None
182
+
183
+
184
+ def euler(matrix):
185
+ # SceneSmith euler_xyz_from_angle_axis(), from the matrix decomposition
186
+ # onward. ASE already supplies R, so no angle-axis conversion is needed.
187
+ sy = math.hypot(matrix[0][0], matrix[1][0])
188
+ if sy > 1e-12:
189
+ roll = math.atan2(matrix[2][1], matrix[2][2])
190
+ pitch = math.atan2(-matrix[2][0], sy)
191
+ yaw = math.atan2(matrix[1][0], matrix[0][0])
192
+ else:
193
+ roll = math.atan2(-matrix[1][2], matrix[1][1])
194
+ pitch = math.atan2(-matrix[2][0], sy)
195
+ yaw = 0.0
196
+ def degrees(value):
197
+ value = (math.degrees(value) + 180) % 360 - 180
198
+ return round(0.0 if abs(value) < 5e-13 else value, 8)
199
+ return dict(zip('xyz', map(degrees, (roll, pitch, yaw))))
200
+
201
+
202
+ def read_language(path):
203
+ commands = defaultdict(list)
204
+ if path is not None:
205
+ for line in path.read_text().splitlines():
206
+ if not line.strip():
207
+ continue
208
+ name, *items = line.split(', ')
209
+ raw = {key: float(value) for key, value in (item.split('=') for item in items)}
210
+ for key in raw:
211
+ if key == 'id' or key.endswith('_id'):
212
+ raw[key] = int(raw[key])
213
+ commands[name].append(raw)
214
+ return commands
215
+
216
+
217
+ def endpoint(wall, side):
218
+ return tuple(wall[f'{side}_{axis}'] for axis in 'xyz')
219
+
220
+
221
+ def wall_groups(walls):
222
+ adjacency = defaultdict(list)
223
+ for index, wall in enumerate(walls):
224
+ a, b = endpoint(wall, 'a'), endpoint(wall, 'b')
225
+ adjacency[a].append((b, index))
226
+ adjacency[b].append((a, index))
227
+ remaining = set(adjacency)
228
+ groups = []
229
+ while remaining:
230
+ stack, vertices, edge_ids = [min(remaining)], set(), set()
231
+ while stack:
232
+ point = stack.pop()
233
+ if point in vertices:
234
+ continue
235
+ vertices.add(point)
236
+ for other, edge in adjacency[point]:
237
+ edge_ids.add(edge)
238
+ stack.append(other)
239
+ remaining -= vertices
240
+ group_walls = sorted((walls[i] for i in edge_ids), key=lambda w: w['id'])
241
+ # Same endpoint adjacency as SAGE10k. For an open chain, start at
242
+ # its endpoint and retain the terminal vertex (project adaptation).
243
+ ends = sorted(p for p in vertices if len(adjacency[p]) == 1)
244
+ chain_or_cycle = (len(ends) in (0, 2) and all(len(adjacency[p]) in (1, 2) for p in vertices))
245
+ ordered, used = [], set()
246
+ if chain_or_cycle:
247
+ point = ends[0] if ends else min(vertices)
248
+ while True:
249
+ ordered.append(point)
250
+ choices = sorted((i, q) for q, i in adjacency[point] if i not in used)
251
+ if not choices:
252
+ break
253
+ edge, point = choices[0]
254
+ used.add(edge)
255
+ if point == ordered[0]:
256
+ break
257
+ poly = [list(p[:2]) for p in ordered] if len(ordered) >= 3 and used == edge_ids else None
258
+ groups.append((group_walls, poly, bool(ends)))
259
+ return sorted(groups, key=lambda item: item[0][0]['id'])
260
+
261
+
262
+ def load_gt(paths, export_root, observations=None):
263
+ objects, conflicts = {}, []
264
+ if not paths:
265
+ return objects, conflicts
266
+ import torch
267
+ # Only cached snippets, ordered by source sample/time/camera. Repeated
268
+ # static labels are deduplicated by native instance ID, without averaging.
269
+ for path in sorted(paths):
270
+ with source_members(path) as (name, read):
271
+ prefix = name[:-len('gt_data.json')]
272
+ metadata = json.loads(read(name))
273
+ gt = metadata['obb3_gt']
274
+ chosen = {tuple(pair) for pair in observations[str(path)]} if observations is not None else None
275
+ for camera in sorted(gt):
276
+ if chosen is not None and (camera,) not in chosen:
277
+ continue
278
+ def load(space, key):
279
+ return torch.load(io.BytesIO(read(f'{prefix}gt_data#{space}+{camera}+{key}.pth')),
280
+ map_location='cpu', weights_only=True).tolist()
281
+ spaces = {'obb3_gt': {key: load('obb3_gt', key) for key in GT_KEYS['obb3_gt']}}
282
+ try:
283
+ spaces['obb2_gt'] = {key: load('obb2_gt', key) for key in GT_KEYS['obb2_gt']}
284
+ except KeyError: # a frame the source left without 2D annotations
285
+ spaces['obb2_gt'] = {}
286
+ fields = spaces['obb3_gt']
287
+ # obb2 lists its own detections; align them by native instance ID.
288
+ second = {sid: i for i, sid in enumerate(spaces['obb2_gt'].get('instance_ids', []))}
289
+ for i, instance_id in enumerate(fields['instance_ids']):
290
+ raw = {key: [values[i]] for key, values in fields.items()}
291
+ raw['category_names'] = [gt[camera]['category_names'][i]]
292
+ j = second.get(instance_id)
293
+ raw2 = {} if j is None else dict(
294
+ {key: [values[j]] for key, values in spaces['obb2_gt'].items()},
295
+ category_names=[metadata['obb2_gt'][camera]['category_names'][j]])
296
+ value = {'pose': fields['ts_world_object'][i], 'dims': fields['object_dimensions'][i],
297
+ 'source_fields': {'source_file': Path(os.path.relpath(path, export_root)).as_posix(),
298
+ 'obb3_gt': {camera: raw},
299
+ 'obb2_gt': {camera: raw2} if raw2 else {}}}
300
+ if instance_id in objects:
301
+ if objects[instance_id]['pose'] != value['pose'] or objects[instance_id]['dims'] != value['dims']:
302
+ conflicts.append({'instance_id': instance_id,
303
+ 'selected_source': objects[instance_id]['source_fields'],
304
+ 'conflicting_source': value['source_fields']})
305
+ else:
306
+ objects[instance_id] = value
307
+ return objects, conflicts
308
+
309
+
310
+ def furniture_record(scene, instance_id, category, gt):
311
+ return {
312
+ 'furniture_category': category,
313
+ 'furniture_instance_id': f'{scene}::inst_{instance_id}',
314
+ 'furniture_position': dict(zip('xyz', [row[3] for row in gt['pose']])) if gt else None,
315
+ 'furniture_rotation': euler(gt['pose']) if gt else dict.fromkeys('xyz'),
316
+ 'furniture_size': dict(zip(('width', 'length', 'height'), gt['dims'])) if gt else None,
317
+ 'source_fields': gt['source_fields'] if gt else {},
318
+ }
319
+
320
+
321
+ def opening(raw):
322
+ return {'position': {axis: raw[f'position_{axis}'] for axis in 'xyz'},
323
+ 'width': raw['width'], 'height': raw['height']}
324
+
325
+
326
+ def build_scene(scene_id, split, commands, classes, gt):
327
+ scene = f'ase_{split}_{scene_id:07d}'
328
+ rooms = []
329
+ for index, (walls, poly, open_chain) in enumerate(wall_groups(commands.get('make_wall', []))):
330
+ ids = {w['id'] for w in walls}
331
+ door_raw = [w for w in commands.get('make_door', []) if ids & {w['wall0_id'], w['wall1_id']}]
332
+ window_raw = [w for w in commands.get('make_window', []) if ids & {w['wall0_id'], w['wall1_id']}]
333
+ heights = {w.get('height') for w in walls}
334
+ room = {
335
+ 'room_id': f'{scene}::room_{index}', 'room_index': index,
336
+ 'room_type': None, 'room_type_source': 'unavailable',
337
+ 'room_boundary': poly, 'room_boundary_type': 'wall_polygon' if poly else None,
338
+ 'room_area_m2': polygon_area(poly) if poly else None,
339
+ 'room_height': next(iter(heights)) if len(heights) == 1 else None,
340
+ 'coordinate_system': COORDINATES,
341
+ 'doors': list(map(opening, door_raw)), 'windows': list(map(opening, window_raw)),
342
+ 'furniture_quantity': 0, 'furniture': [],
343
+ 'source_fields': {'make_wall': walls, 'make_door': door_raw, 'make_window': window_raw},
344
+ }
345
+ rooms.append(room)
346
+ unassigned, structural = [], []
347
+ room_ids = defaultdict(list)
348
+ for instance_id in sorted({int(k) for k in classes} | set(gt)):
349
+ category = classes.get(str(instance_id)) # single category source for the published field
350
+ entry = gt.get(instance_id)
351
+ item = furniture_record(scene, instance_id, category, entry)
352
+ # Recognise structure through either vocabulary: where the classes file
353
+ # is absent the ATEK label is the only evidence this is not furniture.
354
+ name = category or atek_name(entry)
355
+ if name in STRUCTURAL:
356
+ structural.append(item)
357
+ continue
358
+ pos = item['furniture_position']
359
+ matches = [i for i, room in enumerate(rooms) if pos and room['room_boundary']
360
+ and point_in_polygon(pos['x'], pos['y'], room['room_boundary'])]
361
+ if len(matches) == 1:
362
+ rooms[matches[0]]['furniture'].append(item)
363
+ category_id = atek_category_id(entry)
364
+ if category_id is not None:
365
+ room_ids[matches[0]].append(category_id)
366
+ else:
367
+ unassigned.append(item)
368
+ for index, room in enumerate(rooms):
369
+ kind = infer_room_type(room_ids[index], room['room_boundary']) if room['furniture'] else None
370
+ room['room_type'] = kind
371
+ room['room_type_source'] = 'inferred_from_furniture' if kind else 'unavailable'
372
+ room['furniture_quantity'] = len(room['furniture'])
373
+ areas = [r['room_area_m2'] for r in rooms if r['room_area_m2'] is not None]
374
+ result = {
375
+ 'scene_id': scene, 'sample_id': scene, 'dataset': 'ASE',
376
+ 'source_dataset': 'aria_synthetic_environments', 'source_subset': split,
377
+ 'room_count': len(rooms), 'total_area': sum(areas) if areas else None,
378
+ 'building_style': None, 'description': None, 'description_source': None,
379
+ 'provenance': {'source_file': f'{split}_chunk_{scene_id // 10:07d}.zip',
380
+ 'source_scene_index': scene_id, 'split': split}, 'rooms': rooms,
381
+ }
382
+ # Companion source inventory, NOT additional keys in the fixed scene schema.
383
+ retained = {'scene_id': scene, 'unassigned_objects': unassigned, 'structural_instances': structural,
384
+ 'source_fields': {'object_instances_to_classes': classes, **dict(commands)}}
385
+ return result, retained
386
+
387
+
388
+ def convert(data_dir, out_dir, limit=None):
389
+ _, rows = load_selection(data_dir, limit)
390
+ counts = {'scenes': 0, 'dropped_scenes': 0, 'rooms': 0, 'assigned_objects': 0,
391
+ 'unassigned_records': 0, 'structural_records': 0, 'conflicting_gt_observations': 0}
392
+ with JsonWriter(out_dir / 'ase.jsonl', lines=True) as scenes, \
393
+ JsonWriter(out_dir / 'source_inventory.json') as inventory:
394
+ for row in rows:
395
+ language = data_dir / row['language_file'] if row['language_file'] else None
396
+ classes = json.loads((data_dir / row['classes_file']).read_text(encoding='utf-8')) if row['classes_file'] else {}
397
+ observations = ({str(data_dir / name): pairs for name, pairs in row['gt_observations'].items()}
398
+ if 'gt_observations' in row else None)
399
+ gt, conflicts = load_gt([data_dir / name for name in row['gt_files']], out_dir, observations)
400
+ scene, retained = build_scene(row['scene_index'], row['split'], read_language(language), classes, gt)
401
+ scene['provenance']['source_file'] = row['source_file']
402
+ assert set(scene) == set(SCENE_KEYS)
403
+ for room in scene['rooms']:
404
+ assert set(room) == set(ROOM_KEYS)
405
+ for item in room['furniture']:
406
+ assert set(item) == set(FURNITURE_KEYS)
407
+ # A scene whose every room is empty carries no furniture supervision.
408
+ if not any(room['furniture'] for room in scene['rooms']):
409
+ counts['dropped_scenes'] += 1
410
+ continue
411
+ scenes.write(scene)
412
+ inventory.write(retained)
413
+ counts['scenes'] += 1
414
+ counts['rooms'] += len(scene['rooms'])
415
+ counts['assigned_objects'] += sum(r['furniture_quantity'] for r in scene['rooms'])
416
+ counts['unassigned_records'] += len(retained['unassigned_objects'])
417
+ counts['structural_records'] += len(retained['structural_instances'])
418
+ counts['conflicting_gt_observations'] += len(conflicts)
419
+ if counts['scenes'] % 1000 == 0:
420
+ print(json.dumps(counts), flush=True)
421
+ return counts
422
+
423
+
424
+ def main():
425
+ parser = argparse.ArgumentParser(description=__doc__)
426
+ parser.add_argument('--data-dir', type=Path, default=Path(__file__).resolve().parents[1] / 'data')
427
+ parser.add_argument('--out-dir', type=Path, default=Path(__file__).resolve().parents[1])
428
+ scope = parser.add_mutually_exclusive_group(required=True)
429
+ scope.add_argument('--limit', type=int)
430
+ scope.add_argument('--all', action='store_true')
431
+ args = parser.parse_args()
432
+ if args.limit is not None and args.limit < 1:
433
+ parser.error('--limit must be positive')
434
+ print(json.dumps(convert(args.data_dir, args.out_dir, args.limit)))
435
+
436
+
437
+ if __name__ == '__main__':
438
+ main()
ASE_exported/kits/download_ase.py ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Download ASE scene annotations and selected GT members into data/."""
2
+ from __future__ import annotations
3
+ import argparse
4
+ from concurrent.futures import ThreadPoolExecutor, as_completed
5
+ import hashlib
6
+ import io
7
+ import json
8
+ import os
9
+ from pathlib import Path
10
+ import re
11
+ import tarfile
12
+ import time
13
+ import zipfile
14
+ import requests
15
+ from urllib3.exceptions import HTTPError as ResponseReadError
16
+
17
+ class RangeFile(io.RawIOBase):
18
+ """A seekable remote file: never accept a server's whole-file response."""
19
+ def __init__(self, url, size=None, block_size=16384):
20
+ self.block_size, self.start, self.buffer = block_size, 0, b''
21
+ self.url, self.size, self.pos, self.received = url, size, 0, 0
22
+ self.session = requests.Session()
23
+ if size is None:
24
+ self.fetch(0, 1)
25
+
26
+ def fetch(self, start, size):
27
+ return with_retries(self._fetch_once, start, size)
28
+
29
+ def _fetch_once(self, start, size):
30
+ end = start + size - 1
31
+ try:
32
+ with self.session.get(self.url, headers={
33
+ 'Range': f'bytes={start}-{end}', 'Accept-Encoding': 'identity'},
34
+ timeout=30, stream=True) as response:
35
+ match = re.fullmatch(r'bytes (\d+)-(\d+)/(\d+)', response.headers.get('Content-Range', ''))
36
+ if response.status_code >= 400:
37
+ raise RuntimeError(f'Range request failed: HTTP {response.status_code}')
38
+ if response.status_code != 206 or not match or tuple(map(int, match.group(1, 2))) != (start, end):
39
+ raise ValueError('Server did not return the requested byte range')
40
+ total = int(match.group(3))
41
+ if self.size is not None and self.size != total:
42
+ raise ValueError('Remote size disagrees with manifest or previous response')
43
+ self.size = total
44
+ if response.headers.get('Content-Encoding', 'identity') != 'identity':
45
+ raise ValueError('Unexpected content encoding')
46
+ blob = response.raw.read(size + 1)
47
+ self.received += len(blob)
48
+ # A short read is a transport failure, not a broken contract:
49
+ # raise it as RuntimeError so with_retries() retries the range
50
+ # instead of losing the whole chunk to one truncated response.
51
+ if len(blob) != size:
52
+ raise RuntimeError('Range request failed: truncated range response')
53
+ except requests.RequestException:
54
+ raise RuntimeError('Range request failed: network connection error') from None
55
+ return blob
56
+
57
+ def close(self):
58
+ self.session.close()
59
+ super().close()
60
+
61
+ def readable(self):
62
+ return True
63
+
64
+ def seekable(self):
65
+ return True
66
+
67
+ def tell(self):
68
+ return self.pos
69
+
70
+ def seek(self, offset, whence=0):
71
+ self.pos = offset if whence == 0 else self.pos + offset if whence == 1 else self.size + offset
72
+ if self.pos < 0:
73
+ raise ValueError('Negative seek')
74
+ return self.pos
75
+
76
+ def read(self, size=-1):
77
+ size = min(self.size - self.pos, self.size - self.pos if size < 0 else size)
78
+ if size <= 0:
79
+ return b''
80
+ if self.pos == 0 and size == self.size:
81
+ raise ValueError('Whole-file read refused')
82
+ if self.start <= self.pos and self.pos + size <= self.start + len(self.buffer):
83
+ offset = self.pos - self.start
84
+ result = self.buffer[offset:offset + size]
85
+ else:
86
+ amount = min(self.size - self.pos, max(size, self.block_size))
87
+ if self.pos == 0 and amount == self.size:
88
+ amount = size
89
+ self.start = self.pos
90
+ self.buffer = self.fetch(self.pos, amount)
91
+ result = self.buffer[:size]
92
+ self.pos += size
93
+ return result
94
+
95
+
96
+ def save_member(out, relative, blob, files):
97
+ path = out / relative
98
+ path.parent.mkdir(parents=True, exist_ok=True)
99
+ tmp = path.with_suffix(path.suffix + '.part')
100
+ tmp.write_bytes(blob)
101
+ tmp.replace(path)
102
+ files[relative] = {'bytes': len(blob), 'sha256': hashlib.sha256(blob).hexdigest()}
103
+ return relative
104
+
105
+
106
+ GT_NAMESPACES = ('obb3_gt', 'obb2_gt')
107
+ GT_KEYS = {'obb3_gt': ('instance_ids', 'category_ids', 'object_dimensions', 'ts_world_object'),
108
+ 'obb2_gt': ('instance_ids', 'category_ids', 'box_ranges', 'visibility_ratios')}
109
+
110
+
111
+ def wanted_gt(name):
112
+ name = Path(name).name
113
+ return name.endswith('.gt_data.json') or (
114
+ any(f'.gt_data#{space}+' in name for space in GT_NAMESPACES) and name.endswith('.pth'))
115
+
116
+
117
+ def new_row(split, sid, source_file, listed):
118
+ return {'split': split, 'scene_index': sid, 'source_file': source_file,
119
+ 'language_file': None, 'classes_file': None, 'gt_files': [],
120
+ 'atek_listed': listed}
121
+
122
+
123
+ def write_json(path, value):
124
+ path = Path(path)
125
+ path.parent.mkdir(parents=True, exist_ok=True)
126
+ tmp = path.with_suffix(path.suffix + '.part')
127
+ text = json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False) + '\n'
128
+ tmp.write_text(text, encoding='utf-8')
129
+ os.replace(tmp, path)
130
+
131
+
132
+ def positive_int(value):
133
+ value = int(value)
134
+ if value < 1:
135
+ raise ValueError('Expected a positive integer')
136
+ return value
137
+
138
+
139
+ def add_scope_arguments(parser):
140
+ group = parser.add_mutually_exclusive_group(required=True)
141
+ group.add_argument('--limit', type=positive_int, help='Process at most N indexed scenes')
142
+ group.add_argument('--all', action='store_true', help='All indexed scenes; requires user authorization')
143
+
144
+
145
+ def read_manifests(args):
146
+ originals = json.loads(args.original_manifest.read_text(encoding='utf-8'))
147
+ metadata = json.loads(args.atek_manifest.read_text(encoding='utf-8'))
148
+ config = metadata['atek_data_for_all_configs']['cubercnn']
149
+ if (metadata['raw_dataset_name'], metadata['raw_dataset_release_version'], config['atek_wds_version']) != ('AriaSyntheticEnvironment', '1.0', 'v0.1.1'):
150
+ raise ValueError('Expected ASE release 1.0 / cubercnn WDS v0.1.1')
151
+ return originals, config['wds_file_urls']
152
+
153
+
154
+ def with_retries(function, *args):
155
+ for attempt in range(3):
156
+ try:
157
+ return function(*args)
158
+ except (RuntimeError, OSError, EOFError, zipfile.BadZipFile, ResponseReadError):
159
+ if attempt == 2:
160
+ raise
161
+ time.sleep(attempt + 1)
162
+
163
+
164
+ def select_originals(args, originals):
165
+ entries = sorted(originals, key=lambda r: r['filename'])
166
+ if args.split != 'both':
167
+ entries = [r for r in entries if r['filename'].startswith(args.split + '_chunk_')]
168
+ if args.scene_ids is not None:
169
+ chunks = {sid // 10 for sid in args.scene_ids}
170
+ entries = [r for r in entries if int(Path(r['filename']).stem.rsplit('_', 1)[1]) in chunks]
171
+ elif args.limit is not None:
172
+ entries = entries[:max(1, (args.limit + 9) // 10)]
173
+ return entries
174
+
175
+
176
+ def probe_sample(offsets, read, selected, read_many=None):
177
+ """Read IDs first; retain raw members only where a new ID needs geometry.
178
+
179
+ A cubercnn sample is a single frame, so its gt_data.json nests camera only.
180
+ Retention still follows the source order: sample key, then camera.
181
+ """
182
+ import torch
183
+ if read_many is None:
184
+ read_many = lambda names: [read(name) for name in names]
185
+ blobs, observations, probed = {}, {}, 0
186
+ for name in sorted(n for n in offsets if n.endswith('.gt_data.json')):
187
+ metadata = read(name)
188
+ records = json.loads(metadata)['obb3_gt']
189
+ prefix = name[:-len('gt_data.json')]
190
+ rows = [(camera, f'{prefix}gt_data#obb3_gt+{camera}+') for camera in sorted(records)]
191
+ ids_blobs = read_many([stem + 'instance_ids.pth' for _, stem in rows])
192
+ needed = []
193
+ for (camera, stem), ids_blob in zip(rows, ids_blobs):
194
+ ids = torch.load(io.BytesIO(ids_blob), map_location='cpu', weights_only=True).tolist()
195
+ probed += 1
196
+ if not set(ids) - selected:
197
+ continue
198
+ blobs[name] = metadata
199
+ blobs[stem + 'instance_ids.pth'] = ids_blob
200
+ needed.extend(stem + key + '.pth'
201
+ for key in ('ts_world_object', 'object_dimensions', 'category_ids'))
202
+ # The 2D annotations ride along in the same sample; keep them unmapped.
203
+ # A frame without them must not abort a full run, so take what is there.
204
+ needed.extend(f'{prefix}gt_data#obb2_gt+{camera}+{key}.pth'
205
+ for key in GT_KEYS['obb2_gt'])
206
+ observations.setdefault(name, []).append([camera])
207
+ selected.update(ids)
208
+ needed = [member for member in needed if member in offsets]
209
+ blobs.update(zip(needed, read_many(needed)))
210
+ return blobs, observations, probed
211
+
212
+
213
+ def file_digest(path):
214
+ digest = hashlib.sha256()
215
+ with path.open('rb') as handle:
216
+ for block in iter(lambda: handle.read(1024 * 1024), b''):
217
+ digest.update(block)
218
+ return digest.hexdigest()
219
+
220
+
221
+ def original_chunk(out_dir, entry, listed_scenes, scene_ids=None, limit=None):
222
+ files, rows = {}, []
223
+ split = entry['filename'].split('_chunk_')[0]
224
+ with RangeFile(entry['cdn']) as remote, zipfile.ZipFile(remote) as archive:
225
+ members = set(archive.namelist())
226
+ ids = sorted({int(name.split('/')[0]) for name in members
227
+ if name.split('/')[0].isdigit()})
228
+ if scene_ids is not None:
229
+ ids = [sid for sid in ids if sid in scene_ids]
230
+ if limit is not None:
231
+ ids = ids[:limit]
232
+ for sid in ids:
233
+ row = new_row(split, sid, entry['filename'], split == 'train' and str(sid) in listed_scenes)
234
+ for key, filename in [('language_file', 'ase_scene_language.txt'),
235
+ ('classes_file', 'object_instances_to_classes.json')]:
236
+ member = f'{sid}/{filename}'
237
+ if member in members:
238
+ relative = f'original/{split}/{sid}/{filename}'
239
+ row[key] = save_member(out_dir, relative, archive.read(member), files)
240
+ rows.append(row)
241
+ return rows, files
242
+
243
+
244
+ def fetch_originals(args, originals, listed_scenes):
245
+ entries = select_originals(args, originals)
246
+ rows, files = [], {}
247
+ if args.limit is not None:
248
+ # Limit before writing source files, including a partial final ZIP.
249
+ for entry in entries:
250
+ chunk_rows, chunk_files = with_retries(
251
+ original_chunk, args.out_dir, entry, listed_scenes, args.scene_ids,
252
+ args.limit - len(rows))
253
+ rows.extend(chunk_rows)
254
+ files.update(chunk_files)
255
+ if len(rows) == args.limit:
256
+ break
257
+ else:
258
+ with ThreadPoolExecutor(max_workers=args.workers) as pool:
259
+ futures = [pool.submit(with_retries, original_chunk, args.out_dir,
260
+ entry, listed_scenes, args.scene_ids) for entry in entries]
261
+ for completed, future in enumerate(as_completed(futures), 1):
262
+ chunk_rows, chunk_files = future.result()
263
+ rows.extend(chunk_rows)
264
+ files.update(chunk_files)
265
+ if completed % 25 == 0 or completed == len(entries):
266
+ print(f'Original ZIPs: {completed}/{len(entries)}', flush=True)
267
+ rows.sort(key=lambda row: (row['split'], row['scene_index']))
268
+ return rows, files
269
+
270
+
271
+ def fetch_shard(session, entry):
272
+ """cubercnn shards are ~8 MiB, so one GET beats thousands of header probes."""
273
+ expected = int(entry['file_size_bytes'])
274
+ def once():
275
+ response = session.get(entry['download_url'], headers={'Accept-Encoding': 'identity'},
276
+ timeout=180)
277
+ if response.status_code != 200:
278
+ raise RuntimeError(f'Shard request failed: HTTP {response.status_code}')
279
+ if len(response.content) != expected:
280
+ raise ValueError('Shard length disagrees with the manifest')
281
+ return response.content
282
+ return with_retries(once)
283
+
284
+
285
+ def shard_samples(archive):
286
+ """Group a shard's GT members by sample, in tar order, mirroring tar_gt_offsets."""
287
+ groups, order = {}, []
288
+ for member in archive.getmembers():
289
+ if not member.isfile():
290
+ continue
291
+ name = Path(member.name).name
292
+ sample = name.split('.', 1)[0]
293
+ if sample not in groups:
294
+ groups[sample] = {}
295
+ order.append(sample)
296
+ if wanted_gt(name):
297
+ groups[sample][name] = member.name
298
+ return [(sample, groups[sample]) for sample in order if groups[sample]]
299
+
300
+
301
+ def gt_scene(out_dir, sid, shards):
302
+ relative = f'atek/cubercnn/train/{sid}/annotations.tar.gz'
303
+ target = out_dir / relative
304
+ target.parent.mkdir(parents=True, exist_ok=True)
305
+ temporary = target.with_suffix(target.suffix + '.part')
306
+ selected, observations = set(), {}
307
+ session = requests.Session()
308
+ try:
309
+ # Write selected members directly into the scene's single source archive.
310
+ with tarfile.open(temporary, 'w:gz') as output:
311
+ for shard, entry in sorted(shards.items()):
312
+ with tarfile.open(fileobj=io.BytesIO(fetch_shard(session, entry))) as source:
313
+ for sample, paths in shard_samples(source):
314
+ def read(name, _s=source, _p=paths):
315
+ return _s.extractfile(_p[name]).read()
316
+ blobs, chosen, _ = probe_sample(paths, read, selected)
317
+ for name, payload in blobs.items():
318
+ member = tarfile.TarInfo(shard + '/' + name)
319
+ member.size = len(payload)
320
+ output.addfile(member, io.BytesIO(payload))
321
+ observations.update({relative + '::' + shard + '/' + name: pairs
322
+ for name, pairs in chosen.items()})
323
+ temporary.replace(target)
324
+ finally:
325
+ session.close()
326
+ temporary.unlink(missing_ok=True)
327
+ return {'gt_files': sorted(observations), 'gt_observations': observations,
328
+ 'gt_probe_complete': True}, {
329
+ relative: {'bytes': target.stat().st_size, 'sha256': file_digest(target)}}
330
+
331
+
332
+ def download(args):
333
+ index_path = args.out_dir / 'index.json'
334
+ # An interrupted rerun must not leave an old index certifying new partial files.
335
+ index_path.unlink(missing_ok=True)
336
+ originals, listed_scenes = read_manifests(args)
337
+ rows, files = fetch_originals(args, originals, listed_scenes)
338
+ gt_rows = [row for row in rows if row['atek_listed']]
339
+ with ThreadPoolExecutor(max_workers=args.workers) as pool:
340
+ futures = {pool.submit(gt_scene, args.out_dir, row['scene_index'],
341
+ listed_scenes[str(row['scene_index'])]): row for row in gt_rows}
342
+ for completed, future in enumerate(as_completed(futures), 1):
343
+ fields, gt_files = future.result()
344
+ futures[future].update(fields)
345
+ files.update(gt_files)
346
+ print(f'GT scenes: {completed}/{len(gt_rows)}', flush=True)
347
+ scope = ('all original ASE scenes' if args.all and args.split == 'both'
348
+ and args.scene_ids is None else 'selected source scenes')
349
+ index = {'scope': scope, 'atek_config': 'cubercnn', 'raw_release': '1.0',
350
+ 'wds_version': 'v0.1.1', 'scenes': rows, 'files': files}
351
+ write_json(index_path, index)
352
+ print(json.dumps({'scenes': len(rows), 'gt_scenes': len(gt_rows),
353
+ 'source_files': len(files), 'output': str(args.out_dir)}), flush=True)
354
+
355
+
356
+ def main():
357
+ parser = argparse.ArgumentParser(description=__doc__)
358
+ parser.add_argument('--original-manifest', type=Path, required=True)
359
+ parser.add_argument('--atek-manifest', type=Path, required=True)
360
+ parser.add_argument('--out-dir', type=Path, default=Path(__file__).resolve().parents[1] / 'data')
361
+ parser.add_argument('--workers', type=positive_int, default=8)
362
+ parser.add_argument('--split', choices=('both', 'train', 'test'), default='both')
363
+ parser.add_argument('--scene-ids', type=lambda text: [int(value) for value in text.split(',')])
364
+ add_scope_arguments(parser)
365
+ download(parser.parse_args())
366
+
367
+
368
+ if __name__ == '__main__':
369
+ main()
ASE_exported/kits/unify_ase.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Write complete-scene, all-room and multi-scene-room JSON array views.
2
+
3
+ File roles follow pinned Structured3D unify_structured3d.py. Room objects retain
4
+ scene-global coordinates and their IDs/indices, as in 3D-FRONT's view projection.
5
+ """
6
+ from __future__ import annotations
7
+ import argparse
8
+ import json
9
+ from pathlib import Path
10
+ from convert_ase import JsonWriter
11
+
12
+
13
+ def room_scene(scene, room):
14
+ result = dict(scene)
15
+ result.update(scene_id=room['room_id'], sample_id=room['room_id'],
16
+ room_count=1, total_area=room['room_area_m2'], rooms=[room])
17
+ return result
18
+
19
+
20
+ def unify(jsonl, out_dir, limit=None):
21
+ with jsonl.open(encoding='utf-8') as source, \
22
+ JsonWriter(out_dir / 'multiroom/json_multi_merged.json') as merged, \
23
+ JsonWriter(out_dir / 'json_room.json') as rooms, \
24
+ JsonWriter(out_dir / 'multiroom/json_multi_split.json') as split:
25
+ for line in source:
26
+ if limit is not None and merged.count >= limit:
27
+ break
28
+ if not line.strip():
29
+ continue
30
+ scene = json.loads(line)
31
+ merged.write(scene) # Includes zero-room and single-room scenes.
32
+ for room in scene['rooms']:
33
+ item = room_scene(scene, room)
34
+ rooms.write(item)
35
+ if scene['room_count'] > 1:
36
+ split.write(item)
37
+ return {'merged_scenes': merged.count, 'room_records': rooms.count,
38
+ 'multi_split_records': split.count}
39
+
40
+
41
+ def main():
42
+ parser = argparse.ArgumentParser(description=__doc__)
43
+ base = Path(__file__).resolve().parents[1]
44
+ parser.add_argument('--jsonl', type=Path, default=base / 'ase.jsonl')
45
+ parser.add_argument('--out-dir', type=Path, default=base)
46
+ scope = parser.add_mutually_exclusive_group(required=True)
47
+ scope.add_argument('--limit', type=int)
48
+ scope.add_argument('--all', action='store_true')
49
+ args = parser.parse_args()
50
+ if args.limit is not None and args.limit < 1:
51
+ parser.error('--limit must be positive')
52
+ print(json.dumps(unify(args.jsonl, args.out_dir, args.limit)))
53
+
54
+
55
+ if __name__ == '__main__':
56
+ main()
ASE_exported/kits/verify_ase.py ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Check ASE artifacts against selected inputs without importing the converter.
2
+
3
+ Checks the fixed keys, source geometry, lossless ID retention and JSON views.
4
+ Missing source values and open wall chains are not scene-rejection conditions.
5
+ """
6
+ from __future__ import annotations
7
+ import argparse
8
+ from collections import Counter
9
+ from contextlib import contextmanager
10
+ import hashlib
11
+ import json
12
+ import io
13
+ import math
14
+ import tarfile
15
+ import zipfile
16
+ from itertools import zip_longest
17
+ from pathlib import Path
18
+
19
+ def load_selection(data_dir, limit):
20
+ index = json.loads((Path(data_dir) / 'index.json').read_text(encoding='utf-8'))
21
+ rows = sorted(index['scenes'], key=lambda r: (r['split'], r['scene_index']))
22
+ identities = [(r['split'], r['scene_index']) for r in rows]
23
+ if len(identities) != len(set(identities)):
24
+ raise ValueError('Duplicate split/scene identities in input index')
25
+ # Enumerate the index, not language/GT files: absent annotations retain scenes.
26
+ return index, rows[:limit] if limit is not None else rows
27
+
28
+
29
+ def read_jsonl(path):
30
+ with Path(path).open(encoding='utf-8') as handle:
31
+ for line in handle:
32
+ if line.strip():
33
+ yield json.loads(line)
34
+
35
+
36
+ @contextmanager
37
+ def source_members(reference):
38
+ """Read original members from loose files or archive::member references."""
39
+ filename, separator, member = str(reference).partition('::')
40
+ if separator and filename.endswith('.tar.gz'):
41
+ with tarfile.open(filename, 'r:gz') as archive:
42
+ folder = Path(member).parent.as_posix()
43
+ def read(name):
44
+ target = name if folder == '.' else folder + '/' + name
45
+ return archive.extractfile(target).read()
46
+ yield Path(member).name, read
47
+ elif separator:
48
+ with zipfile.ZipFile(filename) as archive:
49
+ folder = Path(member).parent.as_posix()
50
+ def read(name):
51
+ target = name if folder == '.' else folder + '/' + name
52
+ return archive.read(target)
53
+ yield Path(member).name, read
54
+ else:
55
+ path = Path(filename)
56
+ yield path.name, lambda name: (path.parent / name).read_bytes()
57
+
58
+
59
+ def source_key(reference):
60
+ filename, separator, member = str(reference).partition('::')
61
+ return str(Path(filename).resolve()), member if separator else None
62
+
63
+
64
+ SCENE_KEYS = set('scene_id sample_id dataset source_dataset source_subset room_count total_area building_style description description_source provenance rooms'.split())
65
+ ROOM_KEYS = set('room_id room_index room_type room_type_source room_boundary room_boundary_type room_area_m2 room_height coordinate_system doors windows furniture_quantity furniture source_fields'.split())
66
+ FURNITURE_KEYS = set('furniture_category furniture_instance_id furniture_position furniture_rotation furniture_size source_fields'.split())
67
+ STRUCTURAL = {'wall', 'floor', 'ceiling', 'door', 'window'}
68
+ ROOM_TYPES = {'bedroom', 'studio', 'apartment', 'living room', None}
69
+ GT_KEYS = {'obb3_gt': ('instance_ids', 'category_ids', 'object_dimensions', 'ts_world_object'),
70
+ 'obb2_gt': ('instance_ids', 'category_ids', 'box_ranges', 'visibility_ratios')}
71
+
72
+
73
+ def source_gt(paths, observations=None):
74
+ """Independently select the first raw source row by sample/time/camera."""
75
+ selected = {}
76
+ if not paths:
77
+ return selected
78
+ import torch
79
+ for path in sorted(paths):
80
+ with source_members(path) as (name, read):
81
+ document = json.loads(read(name))
82
+ prefix = name[:-len('gt_data.json')]
83
+ chosen = {tuple(pair) for pair in observations[str(path)]} if observations is not None else None
84
+ for camera, record in sorted(document['obb3_gt'].items()):
85
+ if chosen is not None and (camera,) not in chosen:
86
+ continue
87
+ def load(space, key):
88
+ return torch.load(io.BytesIO(read(f'{prefix}gt_data#{space}+{camera}+{key}.pth')),
89
+ map_location='cpu', weights_only=True).tolist()
90
+ spaces = {'obb3_gt': {key: load('obb3_gt', key) for key in GT_KEYS['obb3_gt']}}
91
+ try:
92
+ spaces['obb2_gt'] = {key: load('obb2_gt', key) for key in GT_KEYS['obb2_gt']}
93
+ except KeyError: # a frame the source left without 2D annotations
94
+ spaces['obb2_gt'] = {}
95
+ values = dict(spaces['obb3_gt'], category_names=record['category_names'])
96
+ flat = (dict(spaces['obb2_gt'],
97
+ category_names=document['obb2_gt'][camera]['category_names'])
98
+ if spaces['obb2_gt'] else {})
99
+ second = {sid: i for i, sid in enumerate(flat.get('instance_ids', []))}
100
+ for offset, sid in enumerate(values['instance_ids']):
101
+ j = second.get(sid)
102
+ pair = {} if j is None else {key: [value[j]] for key, value in flat.items()}
103
+ selected.setdefault(sid, (path, camera,
104
+ {key: [value[offset]] for key, value in values.items()},
105
+ pair))
106
+ return selected
107
+
108
+
109
+ def joint_name(item, classes, gt, scene_id):
110
+ """Category under either vocabulary; ATEK names the instances a scene
111
+ missing object_instances_to_classes.json leaves unnamed."""
112
+ instance_id = int(item['furniture_instance_id'][len(scene_id + '::inst_'):])
113
+ category = classes.get(str(instance_id))
114
+ if category:
115
+ return category
116
+ entry = gt.get(instance_id)
117
+ return entry[2]['category_names'][0] if entry else None
118
+
119
+
120
+ def verify_item(item, classes, gt, scene_id, out_dir):
121
+ assert set(item) == FURNITURE_KEYS
122
+ prefix = scene_id + '::inst_'
123
+ assert item['furniture_instance_id'].startswith(prefix)
124
+ instance_id = int(item['furniture_instance_id'][len(prefix):])
125
+ assert item['furniture_category'] == classes.get(str(instance_id))
126
+ if instance_id not in gt:
127
+ assert item['furniture_position'] is None and item['furniture_size'] is None
128
+ assert item['furniture_rotation'] == {'x': None, 'y': None, 'z': None}
129
+ assert item['source_fields'] == {}
130
+ return instance_id, 0.0
131
+ path, camera, raw, raw2 = gt[instance_id]
132
+ sf = item['source_fields']
133
+ assert set(sf) == {'source_file', 'obb3_gt', 'obb2_gt'}
134
+ assert source_key(out_dir / sf['source_file']) == source_key(path)
135
+ assert sf['obb3_gt'] == {camera: raw}
136
+ assert sf['obb2_gt'] == ({camera: raw2} if raw2 else {})
137
+ matrix, dims = raw['ts_world_object'][0], raw['object_dimensions'][0]
138
+ assert item['furniture_position'] == dict(zip('xyz', [row[3] for row in matrix]))
139
+ assert item['furniture_size'] == dict(zip(('width', 'length', 'height'), dims))
140
+ angles = [item['furniture_rotation'][axis] for axis in 'xyz']
141
+ assert all(-180 <= angle < 180 for angle in angles)
142
+ x, y, z = map(math.radians, angles)
143
+ cx, cy, cz, sx, sy, sz = math.cos(x), math.cos(y), math.cos(z), math.sin(x), math.sin(y), math.sin(z)
144
+ rebuilt = [[cz*cy, cz*sy*sx-sz*cx, cz*sy*cx+sz*sx],
145
+ [sz*cy, sz*sy*sx+cz*cx, sz*sy*cx-cz*sx], [-sy, cy*sx, cy*cx]]
146
+ error = max(abs(rebuilt[i][j] - matrix[i][j]) for i in range(3) for j in range(3))
147
+ assert error < 1e-6, (item['furniture_instance_id'], error)
148
+ return instance_id, error
149
+
150
+
151
+ def array_records(path):
152
+ """Our writer stores one complete JSON object on each array line."""
153
+ with path.open(encoding='utf-8') as handle:
154
+ assert next(handle).strip() == '['
155
+ for line in handle:
156
+ text = line.strip()
157
+ if text == ']':
158
+ assert not handle.read().strip()
159
+ return
160
+ if text:
161
+ yield json.loads(text[:-1] if text.endswith(',') else text)
162
+ raise ValueError(f'Incomplete JSON array: {path}')
163
+
164
+
165
+ def verify(data_dir, out_dir, limit):
166
+ index, selected = load_selection(data_dir, limit)
167
+ merged = array_records(out_dir / 'multiroom/json_multi_merged.json')
168
+ singles = array_records(out_dir / 'json_room.json')
169
+ split = array_records(out_dir / 'multiroom/json_multi_split.json')
170
+ inventories = array_records(out_dir / 'source_inventory.json')
171
+ for name, meta in index['files'].items():
172
+ path = data_dir / name
173
+ digest = hashlib.sha256()
174
+ with path.open('rb') as handle:
175
+ for blob in iter(lambda: handle.read(1024 * 1024), b''):
176
+ digest.update(blob)
177
+ assert path.stat().st_size == meta['bytes'] and digest.hexdigest() == meta['sha256'], name
178
+ totals = Counter(scenes=0, room_records=0, multi_split_records=0)
179
+ max_error = 0.0
180
+ rows = iter(selected)
181
+ for scene, inventory, intermediate in zip_longest(merged, inventories, read_jsonl(out_dir / 'ase.jsonl')):
182
+ assert all(value is not None for value in (scene, inventory, intermediate))
183
+ assert scene == intermediate
184
+ # Scenes without any furnished room are dropped, so walk the index
185
+ # forward to the retained one and account for everything skipped.
186
+ for row in rows:
187
+ expected_id = f"ase_{row['split']}_{row['scene_index']:07d}"
188
+ if scene['scene_id'] == expected_id:
189
+ break
190
+ totals['dropped_scenes'] += 1
191
+ # No geometry means no instance could ever land inside a room.
192
+ if row['gt_files']:
193
+ totals['dropped_scenes_with_geometry'] += 1
194
+ else:
195
+ raise AssertionError(f"{scene['scene_id']} is not in the input index")
196
+ assert scene['scene_id'] == inventory['scene_id'] == expected_id
197
+ assert any(room['furniture'] for room in scene['rooms']), scene['scene_id']
198
+ totals['scenes'] += 1
199
+ assert set(scene) == SCENE_KEYS
200
+ assert scene['dataset'] == 'ASE' and scene['source_dataset'] == 'aria_synthetic_environments'
201
+ assert scene['sample_id'] == scene['scene_id'] and scene['source_subset'] == row['split']
202
+ assert scene['provenance'] == {'source_file': row['source_file'], 'source_scene_index': row['scene_index'], 'split': row['split']}
203
+ assert all(scene[key] is None for key in ('building_style', 'description', 'description_source'))
204
+ assert scene['room_count'] == len(scene['rooms'])
205
+ areas = [r['room_area_m2'] for r in scene['rooms'] if r['room_area_m2'] is not None]
206
+ assert scene['total_area'] == (sum(areas) if areas else None)
207
+ classes = json.loads((data_dir / row['classes_file']).read_text(encoding='utf-8')) if row['classes_file'] else {}
208
+ assert inventory['source_fields']['object_instances_to_classes'] == classes
209
+ observations = ({str(data_dir / name): pairs for name, pairs in row['gt_observations'].items()}
210
+ if 'gt_observations' in row else None)
211
+ gt = source_gt([data_dir / name for name in row['gt_files']], observations)
212
+ seen = []
213
+ for i, room in enumerate(scene['rooms']):
214
+ totals['room_records'] += 1
215
+ totals['room_type_null'] += room['room_type'] is None
216
+ totals['rooms_without_assigned_furniture'] += not room['furniture']
217
+ assert set(room) == ROOM_KEYS
218
+ assert room['room_id'] == f"{scene['scene_id']}::room_{i}" and room['room_index'] == i
219
+ assert room['furniture_quantity'] == len(room['furniture'])
220
+ # Furniture without a sleeping or seating anchor leaves no type.
221
+ assert room['room_type'] in ROOM_TYPES, room['room_id']
222
+ assert room['furniture'] or room['room_type'] is None, room['room_id']
223
+ assert room['room_type_source'] == ('inferred_from_furniture' if room['room_type'] else 'unavailable')
224
+ assert room['room_boundary_type'] == ('wall_polygon' if room['room_boundary'] else None)
225
+ for item in room['furniture']:
226
+ assert joint_name(item, classes, gt, scene['scene_id']) not in STRUCTURAL
227
+ assert item['furniture_position'] is not None
228
+ sid, error = verify_item(item, classes, gt, scene['scene_id'], out_dir)
229
+ seen.append(sid)
230
+ max_error = max(max_error, error)
231
+ totals['assigned_objects'] += 1
232
+ single = dict(scene)
233
+ single.update(scene_id=room['room_id'], sample_id=room['room_id'], rooms=[room], room_count=1, total_area=room['room_area_m2'])
234
+ assert next(singles) == single
235
+ if scene['room_count'] > 1:
236
+ assert next(split) == single
237
+ totals['multi_split_records'] += 1
238
+ for bucket in ('unassigned_objects', 'structural_instances'):
239
+ totals[bucket] += len(inventory[bucket])
240
+ for item in inventory[bucket]:
241
+ assert (joint_name(item, classes, gt, scene['scene_id']) in STRUCTURAL) == (bucket == 'structural_instances')
242
+ sid, error = verify_item(item, classes, gt, scene['scene_id'], out_dir)
243
+ seen.append(sid)
244
+ max_error = max(max_error, error)
245
+ assert len(seen) == len(set(seen)), scene['scene_id']
246
+ assert set(seen) == {int(k) for k in classes} | set(gt), scene['scene_id']
247
+ totals['retained_source_ids'] += len(seen)
248
+ totals['gt_instances'] += len(gt)
249
+ assert next(singles, None) is None and next(split, None) is None
250
+ for row in rows: # scenes dropped after the last retained one
251
+ totals['dropped_scenes'] += 1
252
+ if row['gt_files']:
253
+ totals['dropped_scenes_with_geometry'] += 1
254
+ assert totals['scenes'] + totals['dropped_scenes'] == len(selected)
255
+ return {'passed': True, **dict(totals), 'max_rotation_reconstruction_error': max_error,
256
+ 'input_file_hashes_match': True, 'every_retained_scene_is_furnished': True,
257
+ 'all_source_ids_retained_once': True, 'views_preserve_room_objects': True,
258
+ 'scope': index['scope'],
259
+ 'gt_probe_complete_scenes': sum(r.get('gt_probe_complete', False) for r in selected)}
260
+
261
+
262
+ def main():
263
+ parser = argparse.ArgumentParser(description=__doc__)
264
+ base = Path(__file__).resolve().parents[1]
265
+ parser.add_argument('--data-dir', type=Path, default=base / 'data')
266
+ parser.add_argument('--out-dir', type=Path, default=base)
267
+ scope = parser.add_mutually_exclusive_group(required=True)
268
+ scope.add_argument('--limit', type=int)
269
+ scope.add_argument('--all', action='store_true')
270
+ args = parser.parse_args()
271
+ if args.limit is not None and args.limit < 1:
272
+ parser.error('--limit must be positive')
273
+ result = verify(args.data_dir, args.out_dir, args.limit)
274
+ print(json.dumps(result))
275
+
276
+
277
+ if __name__ == '__main__':
278
+ main()