Datasets:
Publish TraceSpatial RGB and QA Parquet release
Browse files- README.md +109 -57
- data/agibot/train-00000.parquet +3 -0
- data/agibot/train-00001.parquet +3 -0
- data/agibot/train-00002.parquet +3 -0
- data/agibot/train-00003.parquet +3 -0
- data/ca1m/train-00000.parquet +3 -0
- data/ca1m/train-00001.parquet +3 -0
- data/ca1m/train-00002.parquet +3 -0
- data/ca1m/train-00003.parquet +3 -0
- data/droid/train-00000.parquet +3 -0
- data/droid/train-00001.parquet +3 -0
- data/robotwin/train-00000.parquet +3 -0
- data/robotwin/train-00001.parquet +3 -0
- data/robotwin/train-00002.parquet +3 -0
- data/robotwin/train-00003.parquet +3 -0
- data/robotwin/train-00004.parquet +3 -0
- data/scannet/train-00000.parquet +3 -0
- data/scannet/train-00001.parquet +3 -0
- data/scannet/train-00002.parquet +3 -0
- manifest.json +192 -0
- scripts/README.template.md +122 -0
- scripts/USAGE.md +108 -0
- scripts/convert_dataset.py +297 -0
- scripts/environment.yml +8 -0
- scripts/requirements.txt +8 -0
- scripts/test_pipeline.py +73 -0
- scripts/upload_dataset.py +89 -0
README.md
CHANGED
|
@@ -2,108 +2,160 @@
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
pretty_name: TraceSpatial-Trace
|
|
|
|
|
|
|
| 5 |
tags:
|
| 6 |
- robotics
|
| 7 |
- spatial-reasoning
|
| 8 |
-
- visual-question-answering
|
| 9 |
- trajectory
|
|
|
|
| 10 |
configs:
|
| 11 |
- config_name: preview
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
data_files:
|
| 13 |
- split: train
|
| 14 |
-
path:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
# TraceSpatial-Trace
|
| 18 |
|
| 19 |
-
RGB images
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
| --- | ---: | ---: | ---: |
|
| 33 |
| AgiBot | 325,846 | 977,538 | 325,846 |
|
| 34 |
-
|
|
| 35 |
| DROID | 105,180 | 105,180 | 20,409 |
|
| 36 |
| RoboTwin | 146,587 | 1,070,535 | 146,587 |
|
| 37 |
| ScanNet | 151,790 | 455,370 | 3,730 |
|
| 38 |
| **Total** | **1,067,822** | **3,623,880** | **517,215** |
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
-
from datasets import load_dataset
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
image
|
| 56 |
-
question
|
| 57 |
-
answer
|
| 58 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
The
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
|
| 65 |
-
| --- | --- |
|
| 66 |
-
|
|
| 67 |
-
|
|
| 68 |
-
|
|
| 69 |
-
|
|
| 70 |
-
|
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
| `qa_index` | Zero-based QA pair index within the original record |
|
| 74 |
-
| `record_index` | Zero-based source record position in this preview selection; distinguishes repeated original IDs |
|
| 75 |
|
| 76 |
-
|
|
|
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
-
| --- | --- | ---: |
|
| 86 |
-
| AgiBot | end_effector | 274,380 |
|
| 87 |
-
| AgiBot | object | 51,466 |
|
| 88 |
-
| CA1M | not provided (null) | 338,419 |
|
| 89 |
-
| DROID | object | 58,386 |
|
| 90 |
-
| DROID | end_effector | 46,794 |
|
| 91 |
-
| RoboTwin | end_effector | 107,035 |
|
| 92 |
-
| RoboTwin | object | 39,552 |
|
| 93 |
-
| ScanNet | not provided (null) | 151,790 |
|
| 94 |
|
| 95 |
-
|
| 96 |
|
| 97 |
-
|
| 98 |
|
| 99 |
-
##
|
| 100 |
|
| 101 |
-
|
| 102 |
|
| 103 |
-
## License
|
| 104 |
|
| 105 |
-
|
| 106 |
|
| 107 |
## Citation
|
| 108 |
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
pretty_name: TraceSpatial-Trace
|
| 5 |
+
task_categories:
|
| 6 |
+
- visual-question-answering
|
| 7 |
tags:
|
| 8 |
- robotics
|
| 9 |
- spatial-reasoning
|
|
|
|
| 10 |
- trajectory
|
| 11 |
+
- arxiv:2512.13660
|
| 12 |
configs:
|
| 13 |
- config_name: preview
|
| 14 |
+
default: true
|
| 15 |
+
data_files:
|
| 16 |
+
- split: train
|
| 17 |
+
path: data/*/*.parquet
|
| 18 |
+
- config_name: agibot
|
| 19 |
+
data_files:
|
| 20 |
+
- split: train
|
| 21 |
+
path: data/agibot/*.parquet
|
| 22 |
+
- config_name: ca1m
|
| 23 |
+
data_files:
|
| 24 |
+
- split: train
|
| 25 |
+
path: data/ca1m/*.parquet
|
| 26 |
+
- config_name: droid
|
| 27 |
+
data_files:
|
| 28 |
+
- split: train
|
| 29 |
+
path: data/droid/*.parquet
|
| 30 |
+
- config_name: robotwin
|
| 31 |
data_files:
|
| 32 |
- split: train
|
| 33 |
+
path: data/robotwin/*.parquet
|
| 34 |
+
- config_name: scannet
|
| 35 |
+
data_files:
|
| 36 |
+
- split: train
|
| 37 |
+
path: data/scannet/*.parquet
|
| 38 |
---
|
| 39 |
|
| 40 |
# TraceSpatial-Trace
|
| 41 |
|
| 42 |
+
**RGB images and trajectory question–answer pairs from [RoboTracer](https://zhoues.github.io/RoboTracer/).**
|
| 43 |
+
|
| 44 |
+
[Project](https://zhoues.github.io/RoboTracer/) · [Paper](https://arxiv.org/pdf/2512.13660) · [Code](https://github.com/Zhoues/RoboTracer) · [TraceSpatial-Bench](https://huggingface.co/datasets/JingkunAn/TraceSpatial-Bench)
|
| 45 |
+
|
| 46 |
+
This is a **preview** containing 104 QA rows from 40 original records. Full local-corpus counts are shown below; those are not the size of this preview.
|
| 47 |
|
| 48 |
+
## Overview
|
| 49 |
|
| 50 |
+
TraceSpatial-Trace is the trajectory-focused RGB + QA release associated with RoboTracer. It supports research on predicting object and end-effector motion from images and language. Each displayed row contains an RGB image, a question, and its original answer.
|
| 51 |
|
| 52 |
+
The broader TraceSpatial collection described by the project contains approximately 30 million QA pairs. **This repository packages the supplied tracing subset: 3,623,880 QA pairs.** It is distinct from the full collection and from TraceSpatial-Bench, the evaluation dataset. [Project overview](https://zhoues.github.io/RoboTracer/)
|
| 53 |
|
| 54 |
+
The paper's data pipeline combines planned object motion in reconstructed CA-1M/ScanNet scenes, traces extracted from DROID/AgiBot manipulation recordings, and RoboTwin simulation. Its three tracing tasks predict image-plane waypoints, predict waypoints with depth, or add depth to supplied 2D waypoints. See the paper's dataset section and tracing appendices for the generation and filtering procedures. [Paper](https://arxiv.org/html/2512.13660)
|
| 55 |
|
| 56 |
+
This release contains RGB images and QA text. It does not distribute depth maps, camera calibration, precomputed spatial features, videos, robot actions, or the broader collection's reasoning annotations. Depth values appearing in answers are retained.
|
| 57 |
|
| 58 |
+
## Corpus statistics
|
| 59 |
+
|
| 60 |
+
Counts below come from a complete audit of the five supplied annotation files. “Record” means an original conversation, “QA pair” means one human message and its following assistant answer. Several records can refer to the same image.
|
| 61 |
+
|
| 62 |
+
| Source | Original records | QA pairs | Unique referenced RGB images |
|
| 63 |
| --- | ---: | ---: | ---: |
|
| 64 |
| AgiBot | 325,846 | 977,538 | 325,846 |
|
| 65 |
+
| CA-1M | 338,419 | 1,015,257 | 20,643 |
|
| 66 |
| DROID | 105,180 | 105,180 | 20,409 |
|
| 67 |
| RoboTwin | 146,587 | 1,070,535 | 146,587 |
|
| 68 |
| ScanNet | 151,790 | 455,370 | 3,730 |
|
| 69 |
| **Total** | **1,067,822** | **3,623,880** | **517,215** |
|
| 70 |
|
| 71 |
+
The extracted image directory has 604,660 files. Of these, 87,445 are not referenced by the supplied QA; the conversion only embeds referenced images. All references resolve after adapting 102,228 DROID references from colon-containing timestamps to the underscore filenames present on disk. Original IDs and QA strings are preserved.
|
| 72 |
|
| 73 |
+
## Tasks and coordinate conventions
|
| 74 |
|
| 75 |
+
| `task` | Input in addition to RGB | Answer format |
|
| 76 |
+
| --- | --- | --- |
|
| 77 |
+
| `2d_trace` | Task instruction | `[(u1, v1), ...]` |
|
| 78 |
+
| `3d_trace` | Task instruction | `[(u1, v1, d1), ...]` |
|
| 79 |
+
| `2d_to_3d` | Task instruction and 2D waypoints | `[(u1, v1, d1), ...]` |
|
| 80 |
|
| 81 |
+
The paper specifies normalized image-plane coordinates **u, v in [0, 1000]**, with **d in meters**. The three-component representation is **(image coordinate, image coordinate, depth)**, not Cartesian XYZ. Recovering metric XYZ requires camera intrinsics, which are not included here. The converter preserves values and does not re-normalize, clamp, or reproject them. [Trace representation](https://arxiv.org/html/2512.13660)
|
| 82 |
|
| 83 |
+
`task` is a derived convenience label: the converter checks question wording against answer tuple dimensionality. Ambiguous cases receive null rather than a guessed label. It is not an original annotation field.
|
| 84 |
|
| 85 |
+
## Dataset Viewer fields
|
|
|
|
| 86 |
|
| 87 |
+
| Field | Description |
|
| 88 |
+
| --- | --- |
|
| 89 |
+
| `image` | Original encoded RGB image, embedded as a Hugging Face `Image` feature |
|
| 90 |
+
| `question` | Original human message, unchanged |
|
| 91 |
+
| `answer` | Its following assistant message, unchanged |
|
| 92 |
+
| `type` | Original `object` or `end_effector` annotation; null if absent |
|
| 93 |
+
| `source` | `agibot`, `ca1m`, `droid`, `robotwin`, or `scannet` |
|
| 94 |
+
| `task` | Derived task label described above |
|
| 95 |
+
| `id` | Original conversation ID; not guaranteed unique |
|
| 96 |
+
| `qa_index` | Zero-based question–answer position within the original conversation |
|
| 97 |
+
| `record_index` | Zero-based record position in its source annotation file |
|
| 98 |
|
| 99 |
+
The tuple `(source, record_index, qa_index)` uniquely identifies a converted row. Group by `(source, record_index)` and sort by `qa_index` to reconstruct the original conversation. The displayed question does not have earlier turns appended; retain the grouped conversation for applications that require dialogue context.
|
| 100 |
|
| 101 |
+
Missing `type` values are preserved. CA-1M and ScanNet do not provide this field in the supplied files, even though the paper describes their tracing pipeline as object-centric.
|
| 102 |
|
| 103 |
+
| Source | `end_effector` records | `object` records | Missing `type` |
|
| 104 |
+
| --- | ---: | ---: | ---: |
|
| 105 |
+
| AgiBot | 274,380 | 51,466 | 0 |
|
| 106 |
+
| CA-1M | 0 | 0 | 338,419 |
|
| 107 |
+
| DROID | 46,794 | 58,386 | 0 |
|
| 108 |
+
| RoboTwin | 107,035 | 39,552 | 0 |
|
| 109 |
+
| ScanNet | 0 | 0 | 151,790 |
|
| 110 |
+
|
| 111 |
+
## Loading
|
|
|
|
|
|
|
| 112 |
|
| 113 |
+
```python
|
| 114 |
+
from datasets import load_dataset
|
| 115 |
|
| 116 |
+
data = load_dataset(
|
| 117 |
+
"leeibo/TraceSpatial-Trace",
|
| 118 |
+
"preview",
|
| 119 |
+
split="train",
|
| 120 |
+
streaming=True,
|
| 121 |
+
)
|
| 122 |
+
example = next(iter(data))
|
| 123 |
+
print(example["source"], example["type"], example["task"])
|
| 124 |
+
print(example["question"])
|
| 125 |
+
print(example["answer"])
|
| 126 |
+
example["image"].save("example.png")
|
| 127 |
+
```
|
| 128 |
|
| 129 |
+
Use your authenticated HF account while this repository is private. Available configurations are listed in the Viewer/configuration metadata. The conversion scripts produce source-specific configurations and an `all` configuration for a full conversion; limited runs produce a `preview` configuration. The initial uploaded preview has 104 QA rows from the first eight records of each source and is illustrative, not randomly sampled.
|
| 130 |
|
| 131 |
+
`train` is a packaging split, not evidence of an official train/test partition. For evaluation, avoid splitting related images or episodes across partitions. No evaluation results are claimed for this release.
|
| 132 |
|
| 133 |
+
## Reproducible conversion and upload
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
The [`scripts/`](scripts/) directory contains a multi-process JSON-to-Parquet converter, a resumable concurrent uploader, pinned environment files, and a Chinese [usage guide](scripts/USAGE.md).
|
| 136 |
|
| 137 |
+
The converter streams JSON, preserves original image bytes and QA strings, writes bounded row groups, and checkpoints complete shards. It creates a manifest with per-file SHA-256 hashes, row counts, source statistics, and task-label counts. Original files are never modified. Shards may contain repeated image bytes because each row is independently usable; Parquet compression and dictionary encoding reduce repeated storage within row groups.
|
| 138 |
|
| 139 |
+
## Provenance and acknowledgment
|
| 140 |
|
| 141 |
+
This release is associated with the [RoboTracer project](https://zhoues.github.io/RoboTracer/). We acknowledge the source datasets and assets listed by its [official repository](https://github.com/Zhoues/RoboTracer): AgiBot World, CA-1M, DROID, RoboTwin 2.0, and ScanNet. The scripts in this repository package the supplied annotations for HF; they do not reproduce the upstream simulation and annotation-generation pipelines.
|
| 142 |
|
| 143 |
+
## License
|
| 144 |
|
| 145 |
+
The release-specific dataset license has not yet been supplied by the maintainer. No dataset license is inferred from the project website or code repository. Source data remain subject to their applicable original terms; this card does not grant additional rights.
|
| 146 |
|
| 147 |
## Citation
|
| 148 |
|
| 149 |
+
Please cite the RoboTracer paper when using this data. The project page uses the earlier title, “RoboTracer: Mastering Spatial Trace with Reasoning in Vision-Language Models for Robotics.” The current arXiv v4 has the updated title below; both refer to arXiv:2512.13660. [Version history](https://arxiv.org/abs/2512.13660)
|
| 150 |
+
|
| 151 |
+
```bibtex
|
| 152 |
+
@misc{zhou2025robotracer,
|
| 153 |
+
title={Towards Spatial Trace with Reasoning in Vision-Language Models for Robotics},
|
| 154 |
+
author={Enshen Zhou and Yibo Li and Jingkun An and Jiayuan Zhang and Shanyu Rong and Mengzhen Liu and Yi Han and Yuheng Ji and Huajie Tan and Jiawei He and Pengwei Wang and Zhongyuan Wang and Cheng Chi and Lu Sheng and Shanghang Zhang},
|
| 155 |
+
year={2025},
|
| 156 |
+
eprint={2512.13660},
|
| 157 |
+
archivePrefix={arXiv},
|
| 158 |
+
primaryClass={cs.RO},
|
| 159 |
+
url={https://arxiv.org/abs/2512.13660}
|
| 160 |
+
}
|
| 161 |
+
```
|
data/agibot/train-00000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b504664fb02346ea60d8e7103e20745f1eed95f16014c75f2248d5c91934ebec
|
| 3 |
+
size 611490
|
data/agibot/train-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:546bb460b50daf2da6a3ed4b6e09e62f5b9203892cd47b4853edd8bb3ad47c60
|
| 3 |
+
size 559892
|
data/agibot/train-00002.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:489645abd661b8e80237517dd5c4be1c1302501b721e2b3ab841fe204b9dc46d
|
| 3 |
+
size 574754
|
data/agibot/train-00003.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:89c487e1c31a8f1405a48db1c54a6e6c1c31317a4e5d14521e1b8ffd3eae3231
|
| 3 |
+
size 609072
|
data/ca1m/train-00000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a37ab591fe9c04d5c607dbf49a7d7c92f73fa66f2477d69f56c755154fba9c52
|
| 3 |
+
size 589750
|
data/ca1m/train-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed00007235302b3e4debba8370301f7dfbcae9200c96f33d15aafca0e18edda1
|
| 3 |
+
size 576782
|
data/ca1m/train-00002.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f0400e65e797760e88e3cd5df064ee0c85dfc8d628a2501d19dbc4fe84d2732b
|
| 3 |
+
size 563306
|
data/ca1m/train-00003.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bdf495c60441ccd3d626596d29cf3ac6f02531d86a6277fba6f229dded8df5fc
|
| 3 |
+
size 562845
|
data/droid/train-00000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:92e705f6d6f3f6f8e7f5447adc37813a2648a40044e1459c4c039ce7f257e553
|
| 3 |
+
size 497899
|
data/droid/train-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:32d64408a8fb01734e9cf78cac6e8c607a8ca4b22175151bb1ccb584a53eacac
|
| 3 |
+
size 515405
|
data/robotwin/train-00000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:34c8278efb35a28ff7e8f4f1a4648f652fca3674878039cc254070176180ec58
|
| 3 |
+
size 567207
|
data/robotwin/train-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8813c6b13ac3c6332ff563bc047545c5c47eeb0d7b2f466848ee22aa27b77ed0
|
| 3 |
+
size 688916
|
data/robotwin/train-00002.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:311d9c6bb515f289c36cb5d9e6b43dae0adc7b89bf50833ecbf0606d4138d2c6
|
| 3 |
+
size 744897
|
data/robotwin/train-00003.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e38cb25e9931c80f3fae49615918b475f3016c2a821f37ad28fa85cd7140eca6
|
| 3 |
+
size 725168
|
data/robotwin/train-00004.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a3ff075b792215493054963d8799e42da65a3b8a559b13fd82b5aec5de1850c
|
| 3 |
+
size 737428
|
data/scannet/train-00000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:793851099c2fe6d809827ab37b6f18802c3d25f9acadaf81ee80de8cab1d3a8e
|
| 3 |
+
size 266840
|
data/scannet/train-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:852b1766484fc442c7011bd6482ca9a972d4a2ddd6ce74855811e3303851b012
|
| 3 |
+
size 266626
|
data/scannet/train-00002.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40e006ac76b1a3b7f3f6f08526160f57a1f2593cf8f5ddb060a3ae564a9a7f6f
|
| 3 |
+
size 135143
|
manifest.json
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": 1,
|
| 3 |
+
"complete": true,
|
| 4 |
+
"limited": true,
|
| 5 |
+
"sources": [
|
| 6 |
+
"agibot",
|
| 7 |
+
"ca1m",
|
| 8 |
+
"droid",
|
| 9 |
+
"robotwin",
|
| 10 |
+
"scannet"
|
| 11 |
+
],
|
| 12 |
+
"records": 40,
|
| 13 |
+
"qa_rows": 104,
|
| 14 |
+
"files": [
|
| 15 |
+
{
|
| 16 |
+
"path": "data/agibot/train-00000.parquet",
|
| 17 |
+
"rows": 6,
|
| 18 |
+
"bytes": 611490,
|
| 19 |
+
"sha256": "b504664fb02346ea60d8e7103e20745f1eed95f16014c75f2248d5c91934ebec"
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"path": "data/agibot/train-00001.parquet",
|
| 23 |
+
"rows": 6,
|
| 24 |
+
"bytes": 559892,
|
| 25 |
+
"sha256": "546bb460b50daf2da6a3ed4b6e09e62f5b9203892cd47b4853edd8bb3ad47c60"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"path": "data/agibot/train-00002.parquet",
|
| 29 |
+
"rows": 6,
|
| 30 |
+
"bytes": 574754,
|
| 31 |
+
"sha256": "489645abd661b8e80237517dd5c4be1c1302501b721e2b3ab841fe204b9dc46d"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "data/agibot/train-00003.parquet",
|
| 35 |
+
"rows": 6,
|
| 36 |
+
"bytes": 609072,
|
| 37 |
+
"sha256": "89c487e1c31a8f1405a48db1c54a6e6c1c31317a4e5d14521e1b8ffd3eae3231"
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"path": "data/ca1m/train-00000.parquet",
|
| 41 |
+
"rows": 6,
|
| 42 |
+
"bytes": 589750,
|
| 43 |
+
"sha256": "a37ab591fe9c04d5c607dbf49a7d7c92f73fa66f2477d69f56c755154fba9c52"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"path": "data/ca1m/train-00001.parquet",
|
| 47 |
+
"rows": 6,
|
| 48 |
+
"bytes": 576782,
|
| 49 |
+
"sha256": "ed00007235302b3e4debba8370301f7dfbcae9200c96f33d15aafca0e18edda1"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"path": "data/ca1m/train-00002.parquet",
|
| 53 |
+
"rows": 6,
|
| 54 |
+
"bytes": 563306,
|
| 55 |
+
"sha256": "f0400e65e797760e88e3cd5df064ee0c85dfc8d628a2501d19dbc4fe84d2732b"
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"path": "data/ca1m/train-00003.parquet",
|
| 59 |
+
"rows": 6,
|
| 60 |
+
"bytes": 562845,
|
| 61 |
+
"sha256": "bdf495c60441ccd3d626596d29cf3ac6f02531d86a6277fba6f229dded8df5fc"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"path": "data/droid/train-00000.parquet",
|
| 65 |
+
"rows": 5,
|
| 66 |
+
"bytes": 497899,
|
| 67 |
+
"sha256": "92e705f6d6f3f6f8e7f5447adc37813a2648a40044e1459c4c039ce7f257e553"
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"path": "data/droid/train-00001.parquet",
|
| 71 |
+
"rows": 3,
|
| 72 |
+
"bytes": 515405,
|
| 73 |
+
"sha256": "32d64408a8fb01734e9cf78cac6e8c607a8ca4b22175151bb1ccb584a53eacac"
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"path": "data/robotwin/train-00000.parquet",
|
| 77 |
+
"rows": 6,
|
| 78 |
+
"bytes": 567207,
|
| 79 |
+
"sha256": "34c8278efb35a28ff7e8f4f1a4648f652fca3674878039cc254070176180ec58"
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"path": "data/robotwin/train-00001.parquet",
|
| 83 |
+
"rows": 6,
|
| 84 |
+
"bytes": 688916,
|
| 85 |
+
"sha256": "8813c6b13ac3c6332ff563bc047545c5c47eeb0d7b2f466848ee22aa27b77ed0"
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"path": "data/robotwin/train-00002.parquet",
|
| 89 |
+
"rows": 6,
|
| 90 |
+
"bytes": 744897,
|
| 91 |
+
"sha256": "311d9c6bb515f289c36cb5d9e6b43dae0adc7b89bf50833ecbf0606d4138d2c6"
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"path": "data/robotwin/train-00003.parquet",
|
| 95 |
+
"rows": 3,
|
| 96 |
+
"bytes": 725168,
|
| 97 |
+
"sha256": "e38cb25e9931c80f3fae49615918b475f3016c2a821f37ad28fa85cd7140eca6"
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"path": "data/robotwin/train-00004.parquet",
|
| 101 |
+
"rows": 3,
|
| 102 |
+
"bytes": 737428,
|
| 103 |
+
"sha256": "8a3ff075b792215493054963d8799e42da65a3b8a559b13fd82b5aec5de1850c"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"path": "data/scannet/train-00000.parquet",
|
| 107 |
+
"rows": 9,
|
| 108 |
+
"bytes": 266840,
|
| 109 |
+
"sha256": "793851099c2fe6d809827ab37b6f18802c3d25f9acadaf81ee80de8cab1d3a8e"
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"path": "data/scannet/train-00001.parquet",
|
| 113 |
+
"rows": 9,
|
| 114 |
+
"bytes": 266626,
|
| 115 |
+
"sha256": "852b1766484fc442c7011bd6482ca9a972d4a2ddd6ce74855811e3303851b012"
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"path": "data/scannet/train-00002.parquet",
|
| 119 |
+
"rows": 6,
|
| 120 |
+
"bytes": 135143,
|
| 121 |
+
"sha256": "40e006ac76b1a3b7f3f6f08526160f57a1f2593cf8f5ddb060a3ae564a9a7f6f"
|
| 122 |
+
}
|
| 123 |
+
],
|
| 124 |
+
"source_statistics": {
|
| 125 |
+
"agibot": {
|
| 126 |
+
"next_record": 8,
|
| 127 |
+
"qa_rows": 24,
|
| 128 |
+
"mapped_image_records": 0,
|
| 129 |
+
"task_counts": {
|
| 130 |
+
"3d_trace": 8,
|
| 131 |
+
"2d_trace": 8,
|
| 132 |
+
"2d_to_3d": 8
|
| 133 |
+
},
|
| 134 |
+
"type_counts": {
|
| 135 |
+
"end_effector": 8
|
| 136 |
+
}
|
| 137 |
+
},
|
| 138 |
+
"ca1m": {
|
| 139 |
+
"next_record": 8,
|
| 140 |
+
"qa_rows": 24,
|
| 141 |
+
"mapped_image_records": 0,
|
| 142 |
+
"task_counts": {
|
| 143 |
+
"2d_trace": 8,
|
| 144 |
+
"3d_trace": 8,
|
| 145 |
+
"2d_to_3d": 8
|
| 146 |
+
},
|
| 147 |
+
"type_counts": {
|
| 148 |
+
"(missing)": 8
|
| 149 |
+
}
|
| 150 |
+
},
|
| 151 |
+
"droid": {
|
| 152 |
+
"next_record": 8,
|
| 153 |
+
"qa_rows": 8,
|
| 154 |
+
"mapped_image_records": 8,
|
| 155 |
+
"task_counts": {
|
| 156 |
+
"2d_to_3d": 4,
|
| 157 |
+
"3d_trace": 2,
|
| 158 |
+
"2d_trace": 2
|
| 159 |
+
},
|
| 160 |
+
"type_counts": {
|
| 161 |
+
"object": 4,
|
| 162 |
+
"end_effector": 4
|
| 163 |
+
}
|
| 164 |
+
},
|
| 165 |
+
"robotwin": {
|
| 166 |
+
"next_record": 8,
|
| 167 |
+
"qa_rows": 24,
|
| 168 |
+
"mapped_image_records": 0,
|
| 169 |
+
"task_counts": {
|
| 170 |
+
"2d_trace": 8,
|
| 171 |
+
"3d_trace": 8,
|
| 172 |
+
"2d_to_3d": 8
|
| 173 |
+
},
|
| 174 |
+
"type_counts": {
|
| 175 |
+
"end_effector": 8
|
| 176 |
+
}
|
| 177 |
+
},
|
| 178 |
+
"scannet": {
|
| 179 |
+
"next_record": 8,
|
| 180 |
+
"qa_rows": 24,
|
| 181 |
+
"mapped_image_records": 0,
|
| 182 |
+
"task_counts": {
|
| 183 |
+
"2d_trace": 9,
|
| 184 |
+
"2d_to_3d": 7,
|
| 185 |
+
"3d_trace": 8
|
| 186 |
+
},
|
| 187 |
+
"type_counts": {
|
| 188 |
+
"(missing)": 8
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
}
|
scripts/README.template.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TraceSpatial-Trace
|
| 2 |
+
|
| 3 |
+
**RGB images and trajectory question–answer pairs from [RoboTracer](https://zhoues.github.io/RoboTracer/).**
|
| 4 |
+
|
| 5 |
+
[Project](https://zhoues.github.io/RoboTracer/) · [Paper](https://arxiv.org/pdf/2512.13660) · [Code](https://github.com/Zhoues/RoboTracer) · [TraceSpatial-Bench](https://huggingface.co/datasets/JingkunAn/TraceSpatial-Bench)
|
| 6 |
+
|
| 7 |
+
@@STATUS@@
|
| 8 |
+
|
| 9 |
+
## Overview
|
| 10 |
+
|
| 11 |
+
TraceSpatial-Trace is the trajectory-focused RGB + QA release associated with RoboTracer. It supports research on predicting object and end-effector motion from images and language. Each displayed row contains an RGB image, a question, and its original answer.
|
| 12 |
+
|
| 13 |
+
The broader TraceSpatial collection described by the project contains approximately 30 million QA pairs. **This repository packages the supplied tracing subset: 3,623,880 QA pairs.** It is distinct from the full collection and from TraceSpatial-Bench, the evaluation dataset. [Project overview](https://zhoues.github.io/RoboTracer/)
|
| 14 |
+
|
| 15 |
+
The paper's data pipeline combines planned object motion in reconstructed CA-1M/ScanNet scenes, traces extracted from DROID/AgiBot manipulation recordings, and RoboTwin simulation. Its three tracing tasks predict image-plane waypoints, predict waypoints with depth, or add depth to supplied 2D waypoints. See the paper's dataset section and tracing appendices for the generation and filtering procedures. [Paper](https://arxiv.org/html/2512.13660)
|
| 16 |
+
|
| 17 |
+
This release contains RGB images and QA text. It does not distribute depth maps, camera calibration, precomputed spatial features, videos, robot actions, or the broader collection's reasoning annotations. Depth values appearing in answers are retained.
|
| 18 |
+
|
| 19 |
+
## Corpus statistics
|
| 20 |
+
|
| 21 |
+
Counts below come from a complete audit of the five supplied annotation files. “Record” means an original conversation, “QA pair” means one human message and its following assistant answer. Several records can refer to the same image.
|
| 22 |
+
|
| 23 |
+
| Source | Original records | QA pairs | Unique referenced RGB images |
|
| 24 |
+
| --- | ---: | ---: | ---: |
|
| 25 |
+
| AgiBot | 325,846 | 977,538 | 325,846 |
|
| 26 |
+
| CA-1M | 338,419 | 1,015,257 | 20,643 |
|
| 27 |
+
| DROID | 105,180 | 105,180 | 20,409 |
|
| 28 |
+
| RoboTwin | 146,587 | 1,070,535 | 146,587 |
|
| 29 |
+
| ScanNet | 151,790 | 455,370 | 3,730 |
|
| 30 |
+
| **Total** | **1,067,822** | **3,623,880** | **517,215** |
|
| 31 |
+
|
| 32 |
+
The extracted image directory has 604,660 files. Of these, 87,445 are not referenced by the supplied QA; the conversion only embeds referenced images. All references resolve after adapting 102,228 DROID references from colon-containing timestamps to the underscore filenames present on disk. Original IDs and QA strings are preserved.
|
| 33 |
+
|
| 34 |
+
## Tasks and coordinate conventions
|
| 35 |
+
|
| 36 |
+
| `task` | Input in addition to RGB | Answer format |
|
| 37 |
+
| --- | --- | --- |
|
| 38 |
+
| `2d_trace` | Task instruction | `[(u1, v1), ...]` |
|
| 39 |
+
| `3d_trace` | Task instruction | `[(u1, v1, d1), ...]` |
|
| 40 |
+
| `2d_to_3d` | Task instruction and 2D waypoints | `[(u1, v1, d1), ...]` |
|
| 41 |
+
|
| 42 |
+
The paper specifies normalized image-plane coordinates **u, v in [0, 1000]**, with **d in meters**. The three-component representation is **(image coordinate, image coordinate, depth)**, not Cartesian XYZ. Recovering metric XYZ requires camera intrinsics, which are not included here. The converter preserves values and does not re-normalize, clamp, or reproject them. [Trace representation](https://arxiv.org/html/2512.13660)
|
| 43 |
+
|
| 44 |
+
`task` is a derived convenience label: the converter checks question wording against answer tuple dimensionality. Ambiguous cases receive null rather than a guessed label. It is not an original annotation field.
|
| 45 |
+
|
| 46 |
+
## Dataset Viewer fields
|
| 47 |
+
|
| 48 |
+
| Field | Description |
|
| 49 |
+
| --- | --- |
|
| 50 |
+
| `image` | Original encoded RGB image, embedded as a Hugging Face `Image` feature |
|
| 51 |
+
| `question` | Original human message, unchanged |
|
| 52 |
+
| `answer` | Its following assistant message, unchanged |
|
| 53 |
+
| `type` | Original `object` or `end_effector` annotation; null if absent |
|
| 54 |
+
| `source` | `agibot`, `ca1m`, `droid`, `robotwin`, or `scannet` |
|
| 55 |
+
| `task` | Derived task label described above |
|
| 56 |
+
| `id` | Original conversation ID; not guaranteed unique |
|
| 57 |
+
| `qa_index` | Zero-based question–answer position within the original conversation |
|
| 58 |
+
| `record_index` | Zero-based record position in its source annotation file |
|
| 59 |
+
|
| 60 |
+
The tuple `(source, record_index, qa_index)` uniquely identifies a converted row. Group by `(source, record_index)` and sort by `qa_index` to reconstruct the original conversation. The displayed question does not have earlier turns appended; retain the grouped conversation for applications that require dialogue context.
|
| 61 |
+
|
| 62 |
+
Missing `type` values are preserved. CA-1M and ScanNet do not provide this field in the supplied files, even though the paper describes their tracing pipeline as object-centric.
|
| 63 |
+
|
| 64 |
+
| Source | `end_effector` records | `object` records | Missing `type` |
|
| 65 |
+
| --- | ---: | ---: | ---: |
|
| 66 |
+
| AgiBot | 274,380 | 51,466 | 0 |
|
| 67 |
+
| CA-1M | 0 | 0 | 338,419 |
|
| 68 |
+
| DROID | 46,794 | 58,386 | 0 |
|
| 69 |
+
| RoboTwin | 107,035 | 39,552 | 0 |
|
| 70 |
+
| ScanNet | 0 | 0 | 151,790 |
|
| 71 |
+
|
| 72 |
+
## Loading
|
| 73 |
+
|
| 74 |
+
```python
|
| 75 |
+
from datasets import load_dataset
|
| 76 |
+
|
| 77 |
+
data = load_dataset(
|
| 78 |
+
"leeibo/TraceSpatial-Trace",
|
| 79 |
+
"@@CONFIG@@",
|
| 80 |
+
split="train",
|
| 81 |
+
streaming=True,
|
| 82 |
+
)
|
| 83 |
+
example = next(iter(data))
|
| 84 |
+
print(example["source"], example["type"], example["task"])
|
| 85 |
+
print(example["question"])
|
| 86 |
+
print(example["answer"])
|
| 87 |
+
example["image"].save("example.png")
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
Use your authenticated HF account while this repository is private. Available configurations are listed in the Viewer/configuration metadata. The conversion scripts produce source-specific configurations and an `all` configuration for a full conversion; limited runs produce a `preview` configuration. The initial uploaded preview has 104 QA rows from the first eight records of each source and is illustrative, not randomly sampled.
|
| 91 |
+
|
| 92 |
+
`train` is a packaging split, not evidence of an official train/test partition. For evaluation, avoid splitting related images or episodes across partitions. No evaluation results are claimed for this release.
|
| 93 |
+
|
| 94 |
+
## Reproducible conversion and upload
|
| 95 |
+
|
| 96 |
+
The [`scripts/`](scripts/) directory contains a multi-process JSON-to-Parquet converter, a resumable concurrent uploader, pinned environment files, and a Chinese [usage guide](scripts/USAGE.md).
|
| 97 |
+
|
| 98 |
+
The converter streams JSON, preserves original image bytes and QA strings, writes bounded row groups, and checkpoints complete shards. It creates a manifest with per-file SHA-256 hashes, row counts, source statistics, and task-label counts. Original files are never modified. Shards may contain repeated image bytes because each row is independently usable; Parquet compression and dictionary encoding reduce repeated storage within row groups.
|
| 99 |
+
|
| 100 |
+
## Provenance and acknowledgment
|
| 101 |
+
|
| 102 |
+
This release is associated with the [RoboTracer project](https://zhoues.github.io/RoboTracer/). We acknowledge the source datasets and assets listed by its [official repository](https://github.com/Zhoues/RoboTracer): AgiBot World, CA-1M, DROID, RoboTwin 2.0, and ScanNet. The scripts in this repository package the supplied annotations for HF; they do not reproduce the upstream simulation and annotation-generation pipelines.
|
| 103 |
+
|
| 104 |
+
## License
|
| 105 |
+
|
| 106 |
+
The release-specific dataset license has not yet been supplied by the maintainer. No dataset license is inferred from the project website or code repository. Source data remain subject to their applicable original terms; this card does not grant additional rights.
|
| 107 |
+
|
| 108 |
+
## Citation
|
| 109 |
+
|
| 110 |
+
Please cite the RoboTracer paper when using this data. The project page uses the earlier title, “RoboTracer: Mastering Spatial Trace with Reasoning in Vision-Language Models for Robotics.” The current arXiv v4 has the updated title below; both refer to arXiv:2512.13660. [Version history](https://arxiv.org/abs/2512.13660)
|
| 111 |
+
|
| 112 |
+
```bibtex
|
| 113 |
+
@misc{zhou2025robotracer,
|
| 114 |
+
title={Towards Spatial Trace with Reasoning in Vision-Language Models for Robotics},
|
| 115 |
+
author={Enshen Zhou and Yibo Li and Jingkun An and Jiayuan Zhang and Shanyu Rong and Mengzhen Liu and Yi Han and Yuheng Ji and Huajie Tan and Jiawei He and Pengwei Wang and Zhongyuan Wang and Cheng Chi and Lu Sheng and Shanghang Zhang},
|
| 116 |
+
year={2025},
|
| 117 |
+
eprint={2512.13660},
|
| 118 |
+
archivePrefix={arXiv},
|
| 119 |
+
primaryClass={cs.RO},
|
| 120 |
+
url={https://arxiv.org/abs/2512.13660}
|
| 121 |
+
}
|
| 122 |
+
```
|
scripts/USAGE.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TraceSpatial-Trace 转换与上传
|
| 2 |
+
|
| 3 |
+
这套脚本把已有 RGB + QA 数据转换为 HF Dataset Viewer 可直接浏览的 Parquet。它不是 RoboTracer 上游数据生成或训练代码。
|
| 4 |
+
|
| 5 |
+
## 环境
|
| 6 |
+
|
| 7 |
+
本机已安装环境 `tracespatial-hf`。在 Miniforge Prompt 中执行:
|
| 8 |
+
|
| 9 |
+
```powershell
|
| 10 |
+
conda activate tracespatial-hf
|
| 11 |
+
cd C:\Users\lee\Desktop\TraceSpatial-release-work\release\scripts
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
其他机器在本目录运行:
|
| 15 |
+
|
| 16 |
+
```powershell
|
| 17 |
+
conda env create -f environment.yml
|
| 18 |
+
conda activate tracespatial-hf
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
已有 Python 3.11 环境也可用 `python -m pip install -r requirements.txt`。不需要 CUDA/GPU。
|
| 22 |
+
|
| 23 |
+
## 小样本验证
|
| 24 |
+
|
| 25 |
+
```powershell
|
| 26 |
+
python convert_dataset.py --input "C:\Users\lee\Desktop\TraceSpatial-Trace\TraceSpatial-Trace" --output "C:\Users\lee\Desktop\TraceSpatial-preview-build" --workers 5 --limit-records 8 --verify-images
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
每个来源取前 8 条原始记录,然后拆出全部 QA。`preview` 仅是演示子集,不是统计随机样本或测试集。
|
| 30 |
+
|
| 31 |
+
## 全量多进程转换
|
| 32 |
+
|
| 33 |
+
```powershell
|
| 34 |
+
python convert_dataset.py --input "C:\Users\lee\Desktop\TraceSpatial-Trace\TraceSpatial-Trace" --output "C:\Users\lee\Desktop\TraceSpatial-full-release" --workers 5 --shard-mib 512 --row-group-mib 32
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
- 原始 `images/` 和 `metadata/` 不修改。只读取被 QA 引用的 RGB 图像。
|
| 38 |
+
- 一个来源一个进程,本数据包最多 5 个并发进程。增加到 8 不会超过 5 个来源的并行度。
|
| 39 |
+
- 每行独立包含 RGB、问题、答案、type、source、task、id、qa_index、record_index。
|
| 40 |
+
- `record_index` 是原始 JSON 数组中的位置。重复 id 不去重,也不丢失问答。
|
| 41 |
+
- 保留原始图像字节,不重编码;保留原始 QA 字符串;缺失 type 留 null。
|
| 42 |
+
- 严格检查单图引用、配对角色与文本类型;遇到缺图或格式错误会报错,不静默跳过。
|
| 43 |
+
- `--verify-images` 可额外对所有引用图像解码校验,代价是更长运行时间。
|
| 44 |
+
- 512 MiB 指近似未压缩内容阈值,实际 Parquet 大小取决于压缩;分片在整条原始记录结束后切分,单条超大记录可能超过阈值。
|
| 45 |
+
- 每个 row group 约 32 MiB,最多 128 行,单张图片上限 64 MiB。Arrow 的编码缓冲会额外占内存,建议从 3–5 个进程开始。
|
| 46 |
+
- 每行嵌入图像,逻辑内容量会因重复图像超过原始包;字典编码与 Zstd 减少行组内重复。不要把 189.6 GB 原始大小当作发布文件大小。
|
| 47 |
+
|
| 48 |
+
## 中断与续跑
|
| 49 |
+
|
| 50 |
+
原命令再次执行即可。每个完整分片写入 `.state/<source>.json` 后才算完成;已完成分片会校验 SHA-256 并跳过,不完整分片重新写入。恢复时仍需流式跳过 JSON 前面的记录。
|
| 51 |
+
|
| 52 |
+
保持原始图片不变。恢复身份会检查 JSON 路径、大小、mtime、脚本哈希和转换参数,但不会给 50 多万张原始图片逐一建立内容快照。原图或元数据、转换参数、代码发生变化时,应使用新的输出目录。改变 `--workers` 不改变数据,可以用于调整并发。
|
| 53 |
+
|
| 54 |
+
`.state/conversion.log` 保存来源级进度;终端显示逐分片进度。Windows 后台启动示例:
|
| 55 |
+
|
| 56 |
+
```powershell
|
| 57 |
+
Start-Process -FilePath "$env:CONDA_PREFIX\python.exe" -ArgumentList @('convert_dataset.py', '--input', '"C:\Users\lee\Desktop\TraceSpatial-Trace\TraceSpatial-Trace"', '--output', '"C:\Users\lee\Desktop\TraceSpatial-full-release"', '--workers', '5') -WorkingDirectory (Get-Location).Path -WindowStyle Hidden -RedirectStandardOutput '..\conversion.stdout.log' -RedirectStandardError '..\conversion.stderr.log'
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
只在没有其他转换进程使用同一输出目录时启动;脚本还会通过文件锁阻止并发写入。
|
| 61 |
+
|
| 62 |
+
## 上传
|
| 63 |
+
|
| 64 |
+
先登录,不要将 token 写入脚本:
|
| 65 |
+
|
| 66 |
+
```powershell
|
| 67 |
+
hf auth login
|
| 68 |
+
hf auth whoami
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
先校验文件和展示计划(无网络写入):
|
| 72 |
+
|
| 73 |
+
```powershell
|
| 74 |
+
python upload_dataset.py --folder "C:\Users\lee\Desktop\TraceSpatial-full-release" --repo-id leeibo/TraceSpatial-Trace --workers 4
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
正式上传:
|
| 78 |
+
|
| 79 |
+
```powershell
|
| 80 |
+
python upload_dataset.py --folder "C:\Users\lee\Desktop\TraceSpatial-full-release" --repo-id leeibo/TraceSpatial-Trace --workers 4 --execute
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
默认使用当前 `upload_folder` + `hf_xet` 的并发、分批提交与续传实现。`--workers` 默认控制本地 SHA-256 并行验证;现代上传路径的网络并发由 SDK/Xet 管理。必须安装 requirements 中的 hf-xet。
|
| 84 |
+
|
| 85 |
+
如需明确控制 SDK 上传 worker 数,可以额外指定 `--legacy-workers`:它使用当前仍可用但上游已弃用的 `upload_large_folder(num_workers=...)`。默认不采用该兼容模式。
|
| 86 |
+
|
| 87 |
+
重复上传命令可恢复未完成上传,不要启动多个上传进程。`.state/upload.log` 保存状态,HF 的缓存用于恢复。不会删除远端文件;不会更改现有仓库的公开/私有状态;不存在的仓库以私有方式创建。上传前需要完整 manifest,并校验全部分片;上传后检查远端大小以及可用的 LFS SHA-256。
|
| 88 |
+
|
| 89 |
+
**注意:当 SDK 分批提交时,中途失败可能已提交部分文件。完成并通过末尾验证后才算整次上传成功。** 此时再重新运行即可。脚本不会自动付费升级存储或切换仓库可见性。
|
| 90 |
+
|
| 91 |
+
## 输出结构
|
| 92 |
+
|
| 93 |
+
```text
|
| 94 |
+
release/
|
| 95 |
+
README.md
|
| 96 |
+
manifest.json
|
| 97 |
+
data/agibot/train-00000.parquet
|
| 98 |
+
data/ca1m/...
|
| 99 |
+
data/droid/...
|
| 100 |
+
data/robotwin/...
|
| 101 |
+
data/scannet/...
|
| 102 |
+
scripts/
|
| 103 |
+
.state/ # 本地检查点与日志,不上传
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
README 由 `README.template.md` 加上实际转换规模和 HF configs 生成。完整转换提供 `all` 和五个来源配置;小样本转换提供 `preview` 和各来源配置。
|
| 107 |
+
|
| 108 |
+
全量完成不等于立即公开。许可证仍需维护者确定。私有仓库的 Viewer 能否显示取决于 HF 账户能力;原始上传和已授权用户的下载不等同于在线 Viewer 支持。
|
scripts/convert_dataset.py
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Stream original JSON into image-embedded QA Parquet, one process per source."""
|
| 2 |
+
import argparse
|
| 3 |
+
import ast
|
| 4 |
+
from collections import Counter
|
| 5 |
+
from concurrent.futures import ProcessPoolExecutor, as_completed
|
| 6 |
+
import hashlib
|
| 7 |
+
import io
|
| 8 |
+
import json
|
| 9 |
+
import logging
|
| 10 |
+
import multiprocessing
|
| 11 |
+
import os
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
import re
|
| 14 |
+
import shutil
|
| 15 |
+
import sys
|
| 16 |
+
|
| 17 |
+
import ijson
|
| 18 |
+
import pyarrow as pa
|
| 19 |
+
import pyarrow.parquet as pq
|
| 20 |
+
from datasets import Features, Image, Value
|
| 21 |
+
from filelock import FileLock
|
| 22 |
+
from PIL import Image as PILImage
|
| 23 |
+
import yaml
|
| 24 |
+
|
| 25 |
+
VERSION = 1
|
| 26 |
+
FIELDS = Features({'image': Image(), 'question': Value('string'), 'answer': Value('string'),
|
| 27 |
+
'type': Value('string'), 'source': Value('string'), 'task': Value('string'),
|
| 28 |
+
'id': Value('string'), 'qa_index': Value('int32'), 'record_index': Value('int64')})
|
| 29 |
+
SCHEMA = FIELDS.arrow_schema
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def sha256(path):
|
| 33 |
+
h = hashlib.sha256()
|
| 34 |
+
with Path(path).open('rb') as f:
|
| 35 |
+
for block in iter(lambda: f.read(8 * 1024 * 1024), b''):
|
| 36 |
+
h.update(block)
|
| 37 |
+
return h.hexdigest()
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def save_json(path, value):
|
| 41 |
+
path = Path(path)
|
| 42 |
+
tmp = path.with_suffix(path.suffix + '.tmp')
|
| 43 |
+
tmp.write_text(json.dumps(value, ensure_ascii=False, indent=2), encoding='utf-8')
|
| 44 |
+
os.replace(tmp, path)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def infer_task(question, answer):
|
| 48 |
+
"""Conservative derived label; never rewrite or execute answer text."""
|
| 49 |
+
if len(answer) > 100000:
|
| 50 |
+
return None
|
| 51 |
+
try:
|
| 52 |
+
points = ast.literal_eval(answer)
|
| 53 |
+
if not isinstance(points, (list, tuple)) or not points:
|
| 54 |
+
return None
|
| 55 |
+
if any(not isinstance(p, (list, tuple)) or len(p) not in (2, 3) for p in points):
|
| 56 |
+
return None
|
| 57 |
+
dims = {len(p) for p in points}
|
| 58 |
+
if len(dims) != 1 or any(not isinstance(v, (int, float)) or isinstance(v, bool) for p in points for v in p):
|
| 59 |
+
return None
|
| 60 |
+
except (ValueError, SyntaxError, TypeError, RecursionError):
|
| 61 |
+
return None
|
| 62 |
+
q = re.sub(r'\b([23])\s+d\b', r'\1d', question.lower())
|
| 63 |
+
if re.search(r'\blift(?:ing)?\b', q) and '2d' in q and '3d' in q and dims == {3}:
|
| 64 |
+
return '2d_to_3d'
|
| 65 |
+
if dims == {2} and '2d' in q:
|
| 66 |
+
return '2d_trace'
|
| 67 |
+
if dims == {3} and '3d' in q and '2d' not in q:
|
| 68 |
+
return '3d_trace'
|
| 69 |
+
return None
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def resolve_image(root, name):
|
| 73 |
+
# Input release uses flat image names. Do not accept traversal or absolute paths.
|
| 74 |
+
if not isinstance(name, str) or '/' in name or '\\' in name or name in ('', '.', '..'):
|
| 75 |
+
raise ValueError(f'Expected flat image filename: {name!r}')
|
| 76 |
+
candidates = [name] if ':' not in name else [name.replace(':', '_')]
|
| 77 |
+
for candidate in candidates:
|
| 78 |
+
path = (root / candidate).resolve()
|
| 79 |
+
if path.parent == root and path.is_file():
|
| 80 |
+
return path
|
| 81 |
+
raise FileNotFoundError(f'RGB image missing: {name}')
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def convert_source(job):
|
| 85 |
+
source, metadata, images, out, opts = job
|
| 86 |
+
metadata, images, out = Path(metadata), Path(images), Path(out)
|
| 87 |
+
pa.set_cpu_count(1) # prevent each process spawning another CPU-sized thread pool
|
| 88 |
+
dest = out / 'data' / source
|
| 89 |
+
dest.mkdir(parents=True, exist_ok=True)
|
| 90 |
+
state_path = out / '.state' / f'{source}.json'
|
| 91 |
+
stat = metadata.stat()
|
| 92 |
+
identity = {'version': VERSION, 'script_sha256': sha256(__file__), 'metadata': str(metadata),
|
| 93 |
+
'size': stat.st_size, 'mtime_ns': stat.st_mtime_ns,
|
| 94 |
+
'images': str(images), 'options': opts}
|
| 95 |
+
if state_path.exists():
|
| 96 |
+
state = json.loads(state_path.read_text(encoding='utf-8'))
|
| 97 |
+
if state['identity'] != identity:
|
| 98 |
+
raise RuntimeError(f'{source}: input/options/code changed; use a new output directory')
|
| 99 |
+
for item in state['files']:
|
| 100 |
+
path = out / item['path']
|
| 101 |
+
if not path.is_file() or path.stat().st_size != item['bytes'] or sha256(path) != item['sha256']:
|
| 102 |
+
raise RuntimeError(f'{source}: completed shard changed: {path}')
|
| 103 |
+
if state['complete']:
|
| 104 |
+
print(f'{source}: resume verified, already complete', flush=True)
|
| 105 |
+
return state
|
| 106 |
+
else:
|
| 107 |
+
state = {'identity': identity, 'source': source, 'complete': False, 'next_record': 0,
|
| 108 |
+
'qa_rows': 0, 'mapped_image_records': 0, 'task_counts': {}, 'type_counts': {}, 'files': []}
|
| 109 |
+
save_json(state_path, state)
|
| 110 |
+
writer = None
|
| 111 |
+
pending, pending_size, shard_size, shard_rows = [], 0, 0, 0
|
| 112 |
+
tasks, types = Counter(state['task_counts']), Counter(state['type_counts'])
|
| 113 |
+
processed, total_rows = state['next_record'], state['qa_rows']
|
| 114 |
+
mapped = state['mapped_image_records']
|
| 115 |
+
target = opts['shard_mib'] * 1024**2
|
| 116 |
+
group_target = opts['row_group_mib'] * 1024**2
|
| 117 |
+
shard_path = None
|
| 118 |
+
tmp = None
|
| 119 |
+
|
| 120 |
+
def flush_group():
|
| 121 |
+
nonlocal pending, pending_size, writer, shard_path, tmp
|
| 122 |
+
if not pending:
|
| 123 |
+
return
|
| 124 |
+
if writer is None:
|
| 125 |
+
shard_path = dest / f'train-{len(state["files"]):05d}.parquet'
|
| 126 |
+
tmp = shard_path.with_suffix('.parquet.incomplete')
|
| 127 |
+
writer = pq.ParquetWriter(tmp, SCHEMA, compression='zstd', compression_level=3,
|
| 128 |
+
use_dictionary=True, dictionary_pagesize_limit=16*1024**2)
|
| 129 |
+
writer.write_table(pa.Table.from_pylist(pending, schema=SCHEMA), row_group_size=len(pending))
|
| 130 |
+
pending, pending_size = [], 0
|
| 131 |
+
|
| 132 |
+
def finish_shard():
|
| 133 |
+
nonlocal writer, shard_rows, shard_size
|
| 134 |
+
flush_group()
|
| 135 |
+
if writer is None:
|
| 136 |
+
return
|
| 137 |
+
writer.close()
|
| 138 |
+
writer = None
|
| 139 |
+
assert pq.ParquetFile(tmp).metadata.num_rows == shard_rows
|
| 140 |
+
os.replace(tmp, shard_path)
|
| 141 |
+
state['files'].append({'path': shard_path.relative_to(out).as_posix(),
|
| 142 |
+
'rows': shard_rows, 'bytes': shard_path.stat().st_size,
|
| 143 |
+
'sha256': sha256(shard_path)})
|
| 144 |
+
state.update(next_record=processed, qa_rows=total_rows, mapped_image_records=mapped,
|
| 145 |
+
task_counts=dict(tasks), type_counts=dict(types))
|
| 146 |
+
save_json(state_path, state)
|
| 147 |
+
print(f'{source}: {processed:,} records / {total_rows:,} QA; committed {shard_path.name}', flush=True)
|
| 148 |
+
shard_rows, shard_size = 0, 0
|
| 149 |
+
|
| 150 |
+
try:
|
| 151 |
+
with metadata.open('rb') as fp:
|
| 152 |
+
for record_index, record in enumerate(ijson.items(fp, 'item')):
|
| 153 |
+
if opts['limit_records'] and record_index >= opts['limit_records']:
|
| 154 |
+
break
|
| 155 |
+
if record_index < state['next_record']:
|
| 156 |
+
continue
|
| 157 |
+
refs = record.get('image')
|
| 158 |
+
conv = record.get('conversations')
|
| 159 |
+
if not isinstance(refs, list) or len(refs) != 1:
|
| 160 |
+
raise ValueError(f'{source}[{record_index}]: expected exactly one RGB reference')
|
| 161 |
+
if not isinstance(conv, list) or not conv or len(conv) % 2:
|
| 162 |
+
raise ValueError(f'{source}[{record_index}]: invalid conversation length')
|
| 163 |
+
path = resolve_image(images, refs[0])
|
| 164 |
+
blob = path.read_bytes()
|
| 165 |
+
if len(blob) > 64 * 1024**2:
|
| 166 |
+
raise ValueError(f'Image exceeds 64 MiB memory guard: {path}')
|
| 167 |
+
if opts['verify_images']:
|
| 168 |
+
with PILImage.open(io.BytesIO(blob)) as im:
|
| 169 |
+
im.verify()
|
| 170 |
+
mapped += path.name != refs[0]
|
| 171 |
+
kind = record.get('type')
|
| 172 |
+
if kind is not None and not isinstance(kind, str):
|
| 173 |
+
raise ValueError(f'{source}[{record_index}]: non-string type')
|
| 174 |
+
if not isinstance(record.get('id'), str):
|
| 175 |
+
raise ValueError(f'{source}[{record_index}]: non-string id')
|
| 176 |
+
types[kind if kind is not None else '(missing)'] += 1
|
| 177 |
+
for offset in range(0, len(conv), 2):
|
| 178 |
+
q, a = conv[offset:offset+2]
|
| 179 |
+
if q.get('from') != 'human' or a.get('from') != 'gpt':
|
| 180 |
+
raise ValueError(f'{source}[{record_index}]: nonalternating roles')
|
| 181 |
+
question, answer = q['value'], a['value']
|
| 182 |
+
if not isinstance(question, str) or not isinstance(answer, str):
|
| 183 |
+
raise ValueError('QA text must be strings')
|
| 184 |
+
task = infer_task(question, answer)
|
| 185 |
+
tasks[task or '(unknown)'] += 1
|
| 186 |
+
row = {'image': {'bytes': blob, 'path': path.name}, 'question': question,
|
| 187 |
+
'answer': answer, 'type': kind, 'source': source, 'task': task,
|
| 188 |
+
'id': record['id'], 'qa_index': offset//2, 'record_index': record_index}
|
| 189 |
+
size = len(blob) + len(question.encode('utf-8')) + len(answer.encode('utf-8')) + 256
|
| 190 |
+
if pending and (pending_size + size > group_target or len(pending) >= 128):
|
| 191 |
+
flush_group()
|
| 192 |
+
pending.append(row)
|
| 193 |
+
pending_size += size
|
| 194 |
+
shard_size += size
|
| 195 |
+
shard_rows += 1
|
| 196 |
+
total_rows += 1
|
| 197 |
+
processed = record_index + 1
|
| 198 |
+
# Checkpoint only at whole-record boundaries, preserving conversation groups.
|
| 199 |
+
if shard_size >= target:
|
| 200 |
+
finish_shard()
|
| 201 |
+
finish_shard()
|
| 202 |
+
state.update(complete=True, next_record=processed, qa_rows=total_rows,
|
| 203 |
+
mapped_image_records=mapped, task_counts=dict(tasks), type_counts=dict(types))
|
| 204 |
+
save_json(state_path, state)
|
| 205 |
+
return state
|
| 206 |
+
except BaseException:
|
| 207 |
+
if writer is not None:
|
| 208 |
+
writer.close()
|
| 209 |
+
raise
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def write_card(out, manifest):
|
| 213 |
+
template = Path(__file__).with_name('README.template.md').read_text(encoding='utf-8')
|
| 214 |
+
configs = []
|
| 215 |
+
if manifest['limited']:
|
| 216 |
+
configs.append({'config_name': 'preview', 'default': True,
|
| 217 |
+
'data_files': [{'split': 'train', 'path': 'data/*/*.parquet'}]})
|
| 218 |
+
else:
|
| 219 |
+
configs.append({'config_name': 'all', 'default': True,
|
| 220 |
+
'data_files': [{'split': 'train', 'path': 'data/*/*.parquet'}]})
|
| 221 |
+
for source in manifest['sources']:
|
| 222 |
+
configs.append({'config_name': source, 'data_files': [{'split': 'train', 'path': f'data/{source}/*.parquet'}]})
|
| 223 |
+
metadata = {'language': ['en'], 'pretty_name': 'TraceSpatial-Trace',
|
| 224 |
+
'task_categories': ['visual-question-answering'],
|
| 225 |
+
'tags': ['robotics', 'spatial-reasoning', 'trajectory', 'arxiv:2512.13660'], 'configs': configs}
|
| 226 |
+
if manifest['limited']:
|
| 227 |
+
status = f"This is a **preview** containing {manifest['qa_rows']:,} QA rows from {manifest['records']:,} original records. Full local-corpus counts are shown below; those are not the size of this preview."
|
| 228 |
+
else:
|
| 229 |
+
status = f"This conversion contains **{manifest['qa_rows']:,} QA rows** from **{manifest['records']:,} original records** across {len(manifest['sources'])} sources."
|
| 230 |
+
text = template.replace('@@STATUS@@', status).replace('@@CONFIG@@', 'preview' if manifest['limited'] else 'all')
|
| 231 |
+
(out/'README.md').write_text('---\n'+yaml.safe_dump(metadata, sort_keys=False)+'---\n\n'+text, encoding='utf-8')
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
def main():
|
| 235 |
+
p = argparse.ArgumentParser(description=__doc__)
|
| 236 |
+
p.add_argument('--input', type=Path, required=True, help='Directory containing images/ and metadata/')
|
| 237 |
+
p.add_argument('--output', type=Path, required=True, help='New release directory; repeat to resume')
|
| 238 |
+
p.add_argument('--workers', type=int, default=min(5, os.cpu_count() or 1))
|
| 239 |
+
p.add_argument('--shard-mib', type=int, default=512, help='Approximate uncompressed bytes; finish whole record before splitting')
|
| 240 |
+
p.add_argument('--row-group-mib', type=int, default=32)
|
| 241 |
+
p.add_argument('--limit-records', type=int, default=0, help='Per-source record limit; 0 means all')
|
| 242 |
+
p.add_argument('--verify-images', action='store_true', help='Decode/verify every referenced image; slower')
|
| 243 |
+
args = p.parse_args()
|
| 244 |
+
if min(args.workers, args.shard_mib, args.row_group_mib) < 1 or args.limit_records < 0:
|
| 245 |
+
p.error('worker/size arguments must be positive and limit nonnegative')
|
| 246 |
+
root, out = args.input.resolve(), args.output.resolve()
|
| 247 |
+
if out == root or root in out.parents:
|
| 248 |
+
p.error('Output must be separate from the input dataset')
|
| 249 |
+
files = sorted((root/'metadata').glob('*.json'))
|
| 250 |
+
if not files or not (root/'images').is_dir():
|
| 251 |
+
p.error('Input needs metadata/*.json and images/')
|
| 252 |
+
sources = [f.name.split('_')[0] for f in files]
|
| 253 |
+
if len(sources) != len(set(sources)):
|
| 254 |
+
p.error('Multiple metadata files share a source label')
|
| 255 |
+
out.mkdir(parents=True, exist_ok=True)
|
| 256 |
+
(out/'.state').mkdir(exist_ok=True)
|
| 257 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s',
|
| 258 |
+
handlers=[logging.StreamHandler(), logging.FileHandler(out/'.state'/'conversion.log', encoding='utf-8')])
|
| 259 |
+
opts = {k: getattr(args, k) for k in ('shard_mib','row_group_mib','limit_records','verify_images')}
|
| 260 |
+
with FileLock(out/'.state'/'convert.lock', timeout=0):
|
| 261 |
+
plan = {'sources': sources, 'input': str(root), 'options': opts, 'script_sha256':sha256(__file__)}
|
| 262 |
+
plan_path = out/'.state'/'plan.json'
|
| 263 |
+
if plan_path.exists() and json.loads(plan_path.read_text(encoding='utf-8')) != plan:
|
| 264 |
+
raise RuntimeError('Output belongs to another conversion; use a fresh directory')
|
| 265 |
+
save_json(plan_path, plan)
|
| 266 |
+
jobs = [(s, str(f), str((root/'images').resolve()), str(out), opts) for s,f in zip(sources,files)]
|
| 267 |
+
results = {}
|
| 268 |
+
with ProcessPoolExecutor(max_workers=min(args.workers,len(jobs)), mp_context=multiprocessing.get_context('spawn')) as pool:
|
| 269 |
+
futures = {pool.submit(convert_source,j):j[0] for j in jobs}
|
| 270 |
+
for future in as_completed(futures):
|
| 271 |
+
source = futures[future]
|
| 272 |
+
try:
|
| 273 |
+
results[source] = future.result()
|
| 274 |
+
logging.info('%s complete: %s QA rows', source, results[source]['qa_rows'])
|
| 275 |
+
except BaseException:
|
| 276 |
+
for f in futures: f.cancel()
|
| 277 |
+
logging.exception('%s failed; completed shards remain resumable', source)
|
| 278 |
+
raise
|
| 279 |
+
results = {s:results[s] for s in sorted(results)}
|
| 280 |
+
manifest = {'version':VERSION, 'complete':True, 'limited':bool(args.limit_records),
|
| 281 |
+
'sources':list(results), 'records':sum(r['next_record'] for r in results.values()),
|
| 282 |
+
'qa_rows':sum(r['qa_rows'] for r in results.values()),
|
| 283 |
+
'files':[item for r in results.values() for item in r['files']],
|
| 284 |
+
'source_statistics': {s:{k:r[k] for k in ('next_record','qa_rows','mapped_image_records','task_counts','type_counts')} for s,r in results.items()}}
|
| 285 |
+
write_card(out,manifest)
|
| 286 |
+
script_dest = out/'scripts'
|
| 287 |
+
script_dest.mkdir(exist_ok=True)
|
| 288 |
+
for f in Path(__file__).parent.iterdir():
|
| 289 |
+
if f.is_file() and f.suffix in ('.py','.md','.txt','.yml') and f.resolve() != (script_dest/f.name).resolve():
|
| 290 |
+
shutil.copy2(f,script_dest/f.name)
|
| 291 |
+
save_json(out/'manifest.json', manifest) # publish only after all sources succeed
|
| 292 |
+
logging.info('COMPLETE: %s QA rows, %s shards',manifest['qa_rows'],len(manifest['files']))
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
if __name__ == '__main__':
|
| 296 |
+
multiprocessing.freeze_support()
|
| 297 |
+
main()
|
scripts/environment.yml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: tracespatial-hf
|
| 2 |
+
channels:
|
| 3 |
+
- conda-forge
|
| 4 |
+
dependencies:
|
| 5 |
+
- python=3.11
|
| 6 |
+
- pip
|
| 7 |
+
- pip:
|
| 8 |
+
- -r requirements.txt
|
scripts/requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
huggingface_hub==1.32.0
|
| 2 |
+
datasets==5.0.1
|
| 3 |
+
pyarrow==25.0.1
|
| 4 |
+
Pillow==12.3.0
|
| 5 |
+
ijson==3.5.1
|
| 6 |
+
PyYAML==6.0.3
|
| 7 |
+
filelock==4.0.1
|
| 8 |
+
hf-xet==1.6.0
|
scripts/test_pipeline.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Integration checks: real-source fidelity and recovery after a missing-image failure."""
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import subprocess
|
| 6 |
+
import sys
|
| 7 |
+
import tempfile
|
| 8 |
+
import unittest
|
| 9 |
+
|
| 10 |
+
import pyarrow.parquet as pq
|
| 11 |
+
from PIL import Image
|
| 12 |
+
from convert_dataset import infer_task, sha256
|
| 13 |
+
|
| 14 |
+
SCRIPT = Path(__file__).with_name('convert_dataset.py')
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class PipelineTests(unittest.TestCase):
|
| 18 |
+
def test_task_labels_and_ambiguity(self):
|
| 19 |
+
self.assertEqual(infer_task('Predict 2D waypoints', '[(1, 2)]'), '2d_trace')
|
| 20 |
+
self.assertEqual(infer_task('Predict 3D waypoints', '[(1, 2, 0.4)]'), '3d_trace')
|
| 21 |
+
self.assertEqual(infer_task('Lift the 2 D waypoints to 3 D', '[(1, 2, 0.4)]'), '2d_to_3d')
|
| 22 |
+
self.assertIsNone(infer_task('Predict 2D waypoints', '[(1, 2, 3)]'))
|
| 23 |
+
self.assertIsNone(infer_task('Predict 3D waypoints', '__import__("os").getcwd()'))
|
| 24 |
+
self.assertIsNone(infer_task('Predict 3D waypoints', '[("a", 2, 3)]'))
|
| 25 |
+
|
| 26 |
+
def test_checkpoint_resume_after_missing_image(self):
|
| 27 |
+
with tempfile.TemporaryDirectory(prefix='tracespatial-test-') as directory:
|
| 28 |
+
base = Path(directory)
|
| 29 |
+
root, output = base/'input', base/'output'
|
| 30 |
+
(root/'images').mkdir(parents=True)
|
| 31 |
+
(root/'metadata').mkdir()
|
| 32 |
+
image1 = root/'images'/'frame_01.png'
|
| 33 |
+
image2 = root/'images'/'frame_02.png'
|
| 34 |
+
Image.frombytes('RGB',(700,700),os.urandom(700*700*3)).save(image1)
|
| 35 |
+
records = []
|
| 36 |
+
for n in (1,2):
|
| 37 |
+
records.append({'id':'duplicate-id','image':[f'frame:0{n}.png'],
|
| 38 |
+
'conversations':[{'from':'human','value':'Predict 2D waypoints'},
|
| 39 |
+
{'from':'gpt','value':'[(10, 20), (30, 40)]'}]})
|
| 40 |
+
(root/'metadata'/'droid_test.json').write_text(json.dumps(records),encoding='utf-8')
|
| 41 |
+
command = [sys.executable,str(SCRIPT),'--input',str(root),'--output',str(output),
|
| 42 |
+
'--workers','2','--shard-mib','1','--row-group-mib','1']
|
| 43 |
+
failed = subprocess.run(command,capture_output=True,text=True)
|
| 44 |
+
self.assertNotEqual(failed.returncode,0)
|
| 45 |
+
self.assertIn('RGB image missing',failed.stderr)
|
| 46 |
+
self.assertFalse((output/'manifest.json').exists())
|
| 47 |
+
state = json.loads((output/'.state'/'droid.json').read_text())
|
| 48 |
+
self.assertEqual(state['next_record'],1)
|
| 49 |
+
first = output/state['files'][0]['path']
|
| 50 |
+
original_sha, original_mtime = sha256(first), first.stat().st_mtime_ns
|
| 51 |
+
image2.write_bytes(image1.read_bytes())
|
| 52 |
+
resumed = subprocess.run(command,capture_output=True,text=True)
|
| 53 |
+
self.assertEqual(resumed.returncode,0,resumed.stderr)
|
| 54 |
+
self.assertEqual(sha256(first),original_sha)
|
| 55 |
+
self.assertEqual(first.stat().st_mtime_ns,original_mtime)
|
| 56 |
+
manifest = json.loads((output/'manifest.json').read_text())
|
| 57 |
+
self.assertEqual(manifest['qa_rows'],2)
|
| 58 |
+
rows = [row for item in manifest['files'] for row in pq.read_table(output/item['path']).to_pylist()]
|
| 59 |
+
self.assertEqual([r['record_index'] for r in rows],[0,1])
|
| 60 |
+
self.assertEqual([r['id'] for r in rows],['duplicate-id','duplicate-id'])
|
| 61 |
+
self.assertTrue(all(r['type'] is None for r in rows))
|
| 62 |
+
self.assertEqual(manifest['source_statistics']['droid']['mapped_image_records'],2)
|
| 63 |
+
uploader = Path(__file__).with_name('upload_dataset.py')
|
| 64 |
+
plan = subprocess.run([sys.executable,str(uploader),'--folder',str(output)],capture_output=True,text=True)
|
| 65 |
+
self.assertEqual(plan.returncode,0,plan.stderr)
|
| 66 |
+
with first.open('ab') as f: f.write(b'corruption')
|
| 67 |
+
bad = subprocess.run([sys.executable,str(uploader),'--folder',str(output)],capture_output=True,text=True)
|
| 68 |
+
self.assertNotEqual(bad.returncode,0)
|
| 69 |
+
self.assertIn('checksum mismatch',bad.stderr)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
if __name__ == '__main__':
|
| 73 |
+
unittest.main(verbosity=2)
|
scripts/upload_dataset.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Manifest-validated Hugging Face upload with SDK-managed concurrency and resume."""
|
| 2 |
+
import argparse
|
| 3 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 4 |
+
import json
|
| 5 |
+
import logging
|
| 6 |
+
import os
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
from filelock import FileLock
|
| 10 |
+
from huggingface_hub import HfApi
|
| 11 |
+
from huggingface_hub.errors import RepositoryNotFoundError
|
| 12 |
+
from convert_dataset import sha256, save_json
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def main():
|
| 16 |
+
p = argparse.ArgumentParser(description=__doc__)
|
| 17 |
+
p.add_argument('--folder', type=Path, required=True)
|
| 18 |
+
p.add_argument('--repo-id', default='leeibo/TraceSpatial-Trace')
|
| 19 |
+
p.add_argument('--workers', type=int, default=4, help='Checksum workers; also upload workers when --legacy-workers is used')
|
| 20 |
+
p.add_argument('--execute', action='store_true', help='Without this flag, only validate and show upload plan')
|
| 21 |
+
p.add_argument('--legacy-workers', action='store_true', help='Use resumable upload_large_folder for explicit worker control (deprecated upstream)')
|
| 22 |
+
args = p.parse_args()
|
| 23 |
+
if args.workers < 1: p.error('--workers must be positive')
|
| 24 |
+
root = args.folder.resolve()
|
| 25 |
+
manifest_path = root/'manifest.json'
|
| 26 |
+
if not manifest_path.is_file(): p.error('Conversion manifest.json missing; finish conversion first')
|
| 27 |
+
manifest = json.loads(manifest_path.read_text(encoding='utf-8'))
|
| 28 |
+
if not manifest.get('complete'): p.error('Conversion not complete')
|
| 29 |
+
(root/'.state').mkdir(exist_ok=True)
|
| 30 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s',
|
| 31 |
+
handlers=[logging.StreamHandler(), logging.FileHandler(root/'.state'/'upload.log', encoding='utf-8')])
|
| 32 |
+
with FileLock(root/'.state'/'upload.lock', timeout=0), FileLock(root/'.state'/'convert.lock', timeout=0):
|
| 33 |
+
def validate(item):
|
| 34 |
+
path = (root/item['path']).resolve()
|
| 35 |
+
if root not in path.parents or not path.is_file():
|
| 36 |
+
raise RuntimeError(f'Invalid/missing shard path: {item["path"]}')
|
| 37 |
+
if path.stat().st_size != item['bytes'] or sha256(path) != item['sha256']:
|
| 38 |
+
raise RuntimeError(f'Shard checksum mismatch: {item["path"]}')
|
| 39 |
+
with ThreadPoolExecutor(max_workers=args.workers) as pool:
|
| 40 |
+
list(pool.map(validate, manifest['files']))
|
| 41 |
+
tracked = {x['path'] for x in manifest['files']}
|
| 42 |
+
actual = {f.relative_to(root).as_posix() for f in root.glob('data/**/*.parquet')}
|
| 43 |
+
if tracked != actual:
|
| 44 |
+
raise RuntimeError('Untracked or missing data shards; use a clean output directory')
|
| 45 |
+
if not (root/'README.md').is_file(): raise RuntimeError('README.md missing')
|
| 46 |
+
ancillary = [p.relative_to(root).as_posix() for pattern in ('scripts/*.py','scripts/*.md','scripts/*.txt','scripts/*.yml','assets/*') for p in root.glob(pattern) if p.is_file()]
|
| 47 |
+
allow = sorted(tracked) + ['README.md','manifest.json'] + ancillary
|
| 48 |
+
logging.info('Plan: %s files, %.3f GiB in data shards, %s QA rows -> %s',len(allow),sum(f['bytes'] for f in manifest['files'])/1024**3,manifest['qa_rows'],args.repo_id)
|
| 49 |
+
if not args.execute:
|
| 50 |
+
logging.info('Dry run complete; add --execute to upload. No network writes performed.')
|
| 51 |
+
return
|
| 52 |
+
# Bind SDK resume cache to one destination. Never print or embed the token.
|
| 53 |
+
binding = root/'.state'/'upload-target.json'
|
| 54 |
+
target = {'repo_id':args.repo_id, 'repo_type':'dataset'}
|
| 55 |
+
if binding.exists() and json.loads(binding.read_text(encoding='utf-8')) != target:
|
| 56 |
+
raise RuntimeError('This folder upload cache belongs to another repo; use a fresh staging folder')
|
| 57 |
+
api = HfApi()
|
| 58 |
+
logging.info('Authenticated as %s',api.whoami()['name'])
|
| 59 |
+
try:
|
| 60 |
+
info = api.dataset_info(args.repo_id)
|
| 61 |
+
logging.info('Existing repository visibility: %s', 'private' if info.private else 'public')
|
| 62 |
+
except RepositoryNotFoundError:
|
| 63 |
+
api.create_repo(args.repo_id, repo_type='dataset', private=True, exist_ok=True)
|
| 64 |
+
save_json(binding,target)
|
| 65 |
+
if args.legacy_workers:
|
| 66 |
+
# Explicitly requested compatibility mode; no concurrent committing processes.
|
| 67 |
+
api.upload_large_folder(repo_id=args.repo_id, repo_type='dataset', folder_path=root,
|
| 68 |
+
num_workers=args.workers, allow_patterns=allow, print_report_every=30)
|
| 69 |
+
else:
|
| 70 |
+
from huggingface_hub.utils._runtime import is_xet_available
|
| 71 |
+
if not is_xet_available():
|
| 72 |
+
raise RuntimeError("Install hf-xet from requirements.txt for resumable multi-commit upload")
|
| 73 |
+
# Current SDK: internally concurrent, resumable, automatically splits commits.
|
| 74 |
+
api.upload_folder(repo_id=args.repo_id, repo_type='dataset', folder_path=root,
|
| 75 |
+
allow_patterns=allow, commit_message='Publish TraceSpatial RGB and QA Parquet release')
|
| 76 |
+
remote = {f.path:f for f in api.list_repo_tree(args.repo_id,repo_type='dataset',recursive=True) if hasattr(f,'size')}
|
| 77 |
+
for item in manifest['files']:
|
| 78 |
+
f = remote.get(item['path'])
|
| 79 |
+
if f is None or f.size != item['bytes']:
|
| 80 |
+
raise RuntimeError(f'Remote size mismatch: {item["path"]}')
|
| 81 |
+
lfs = getattr(f,'lfs',None)
|
| 82 |
+
remote_sha = getattr(lfs,'sha256',None)
|
| 83 |
+
if remote_sha and remote_sha != item['sha256']:
|
| 84 |
+
raise RuntimeError(f'Remote SHA-256 mismatch: {item["path"]}')
|
| 85 |
+
logging.info('Upload verified: https://huggingface.co/datasets/%s',args.repo_id)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
if __name__ == '__main__':
|
| 89 |
+
main()
|