Update dataset reader and split coverage
Browse files- README.md +17 -0
- REPRODUCE.md +12 -1
- STATUS.md +8 -1
- catalog/availability.json +24 -0
- catalog/frames.jsonl.gz +3 -0
- xfield_sim.py +140 -0
README.md
CHANGED
|
@@ -34,6 +34,23 @@ python read_example.py
|
|
| 34 |
|
| 35 |
训练输入包括雷达 cube、RGB、相机内外参和图像前端的深度、语义特征。监督包括占据层、回波角色、反射面、折回目标、车辆与静态恢复标签。3,486 个训练帧另有六类语义、高度和车道监督,用 `dense_present` 判断。测试输入和评分标签分别存放。
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
[当前发布进度](STATUS.md) · [字段与使用](FIELDS.md) · [训练与评测划分](SPLITS.md) · [复现代码](REPRODUCE.md)
|
| 38 |
|
| 39 |
仿真采集来源为 [CARLA X-band Radar NLOS](https://huggingface.co/datasets/KAS2003/carla-xband-radar-nlos)。
|
|
|
|
| 34 |
|
| 35 |
训练输入包括雷达 cube、RGB、相机内外参和图像前端的深度、语义特征。监督包括占据层、回波角色、反射面、折回目标、车辆与静态恢复标签。3,486 个训练帧另有六类语义、高度和车道监督,用 `dense_present` 判断。测试输入和评分标签分别存放。
|
| 36 |
|
| 37 |
+
## 训练与评测
|
| 38 |
+
|
| 39 |
+
下载 [xfield_sim.py](xfield_sim.py),安装 `numpy zstandard filelock huggingface_hub`。下面的代码取一份已发布的训练样本。读取时只下载对应分片。
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
from xfield_sim import XFieldSim
|
| 43 |
+
|
| 44 |
+
train = XFieldSim("fit")
|
| 45 |
+
key = train.available_keys()[0]
|
| 46 |
+
frame = train[key]
|
| 47 |
+
radar = frame["inputs"]["cube"]
|
| 48 |
+
rgb = frame["inputs"]["image_rgb"]
|
| 49 |
+
labels = frame["targets"]
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
本地下载完整目录后可使用 `XFieldSim("fit", local_dir="./xfield-sim-core")`。源数据按实际访问口径约 248.48 GB,其中训练约 212.01 GB。下载大小取决于分片压缩。
|
| 53 |
+
|
| 54 |
[当前发布进度](STATUS.md) · [字段与使用](FIELDS.md) · [训练与评测划分](SPLITS.md) · [复现代码](REPRODUCE.md)
|
| 55 |
|
| 56 |
仿真采集来源为 [CARLA X-band Radar NLOS](https://huggingface.co/datasets/KAS2003/carla-xband-radar-nlos)。
|
REPRODUCE.md
CHANGED
|
@@ -2,7 +2,18 @@
|
|
| 2 |
|
| 3 |
与此划分相配的 XField 代码版本为 [XField_PredCore](https://github.com/kasssssss/XField_PredCore/tree/9edbf4ba909533f8f0df8132726d9811ea0169dd)。仿真 cube+RGB 和 RA+RGB 使用共享的 Stage 1、学习折回、Stage 2 和 Bipolar。
|
| 4 |
|
| 5 |
-
`read_example.py` 可独立运行
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
雷达编码器的早期预训练、Fold 初始化、Stage 2 缓存和补全头使用过不同的监督。需要从头复做这些阶段时,可参考[阶段依赖及成员清单](https://huggingface.co/datasets/KAS2003/carla-xband-radar-nlos/blob/385666cfcdc2eb466429760b0783ff711c3fc056/releases/2026-11-03/final/STAGE_DATA.md)。新方法可以直接从本仓的固定训练集开始。
|
| 8 |
|
|
|
|
| 2 |
|
| 3 |
与此划分相配的 XField 代码版本为 [XField_PredCore](https://github.com/kasssssss/XField_PredCore/tree/9edbf4ba909533f8f0df8132726d9811ea0169dd)。仿真 cube+RGB 和 RA+RGB 使用共享的 Stage 1、学习折回、Stage 2 和 Bipolar。
|
| 4 |
|
| 5 |
+
`read_example.py` 可独立运行。复现原训练时,在 XField 代码环境中使用下面的入口。它将 RGB 按原训练方式归一化,并保留存在的语义、高度和车道目标。
|
| 6 |
+
|
| 7 |
+
```python
|
| 8 |
+
from xfield_sim import XFieldSim
|
| 9 |
+
from training.rgb_required import batchify
|
| 10 |
+
|
| 11 |
+
train = XFieldSim("fit")
|
| 12 |
+
keys = train.available_keys()[:4]
|
| 13 |
+
batch = batchify([train.xfield_sample(k) for k in keys])
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
锁定测试先用 `XFieldSim("paired_eval")[key]` 产生预测,再用 `test_truth(key)` 读取独立车辆和整场占据标签。
|
| 17 |
|
| 18 |
雷达编码器的早期预训练、Fold 初始化、Stage 2 缓存和补全头使用过不同的监督。需要从头复做这些阶段时,可参考[阶段依赖及成员清单](https://huggingface.co/datasets/KAS2003/carla-xband-radar-nlos/blob/385666cfcdc2eb466429760b0783ff711c3fc056/releases/2026-11-03/final/STAGE_DATA.md)。新方法可以直接从本仓的固定训练集开始。
|
| 19 |
|
STATUS.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
| 1 |
# 发布进度
|
| 2 |
|
| 3 |
-
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# 发布进度
|
| 2 |
|
| 3 |
+
2026-11-03 20:59 UTC+8
|
| 4 |
|
| 5 |
+
| 划分 | 可读帧 | 总帧数 |
|
| 6 |
+
|---|---:|---:|
|
| 7 |
+
| fit | 192 | 29,223 |
|
| 8 |
+
| dev | 1,484 | 1,484 |
|
| 9 |
+
| paired_eval | 3,270 | 3,270 |
|
| 10 |
+
|
| 11 |
+
训练帧的 RGB/监督和雷达分片同时存在才计为可读。测试真值存放在 [test_labels](test_labels)。
|
catalog/availability.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"as_of": "2026-11-03 20:59 UTC+8",
|
| 3 |
+
"state": "PUBLISHING",
|
| 4 |
+
"data_revision": "9eebef5702531f2809fb7ac5c9fbe104eb2a149c",
|
| 5 |
+
"coverage": {
|
| 6 |
+
"fit": {
|
| 7 |
+
"planned": 29223,
|
| 8 |
+
"ready": 192,
|
| 9 |
+
"shards": 88
|
| 10 |
+
},
|
| 11 |
+
"dev": {
|
| 12 |
+
"planned": 1484,
|
| 13 |
+
"ready": 1484,
|
| 14 |
+
"shards": 16
|
| 15 |
+
},
|
| 16 |
+
"paired_eval": {
|
| 17 |
+
"planned": 3270,
|
| 18 |
+
"ready": 3270,
|
| 19 |
+
"shards": 69
|
| 20 |
+
}
|
| 21 |
+
},
|
| 22 |
+
"test_labels_present": true,
|
| 23 |
+
"independent_read_revision": null
|
| 24 |
+
}
|
catalog/frames.jsonl.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:462a2132a0e2aba0e88c69178832c6ecea5e2d76958f289272a6da1abce55e68
|
| 3 |
+
size 1736020
|
xfield_sim.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Read XField simulation frames from a downloaded dataset or a pinned public Hub revision."""
|
| 2 |
+
from functools import lru_cache
|
| 3 |
+
import gzip
|
| 4 |
+
import hashlib
|
| 5 |
+
import io
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
import tarfile
|
| 10 |
+
import tempfile
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
import zstandard as zstd
|
| 14 |
+
from filelock import FileLock
|
| 15 |
+
from huggingface_hub import HfApi, hf_hub_download
|
| 16 |
+
|
| 17 |
+
REPO = 'KAS2003/xfield-sim-core'
|
| 18 |
+
SPLITS = ('fit', 'dev', 'paired_eval')
|
| 19 |
+
SENSORS = {'image_rgb', 'img', 'cube', 'depth', 'sem', 'K', 'T', 'steer'}
|
| 20 |
+
|
| 21 |
+
@lru_cache(maxsize=8)
|
| 22 |
+
def _tar(path, pid):
|
| 23 |
+
return tarfile.open(path, mode='r:')
|
| 24 |
+
|
| 25 |
+
class XFieldSim:
|
| 26 |
+
"""New methods get separate input and target dictionaries. The test sensor files contain no GT."""
|
| 27 |
+
|
| 28 |
+
def __init__(self, split='fit', *, revision=None, local_dir=None, cache_dir=None):
|
| 29 |
+
if split not in SPLITS:
|
| 30 |
+
raise ValueError(f'Unknown split {split!r}')
|
| 31 |
+
self.split = split
|
| 32 |
+
self.local_dir = Path(local_dir).resolve() if local_dir else None
|
| 33 |
+
self.cache = Path(cache_dir or os.environ.get('XFIELD_CACHE', Path.home()/'.cache/xfield-sim'))
|
| 34 |
+
if self.local_dir is None:
|
| 35 |
+
self.revision = HfApi(token=False).dataset_info(
|
| 36 |
+
REPO, revision=revision or 'refs/heads/main', expand=['sha']).sha
|
| 37 |
+
else:
|
| 38 |
+
self.revision = revision
|
| 39 |
+
with gzip.open(self.file('catalog/frames.jsonl.gz'), 'rt') as f:
|
| 40 |
+
self.rows = [r for line in f if (r := json.loads(line))['split'] == split]
|
| 41 |
+
with self.file(f'splits/{split}.txt').open() as f:
|
| 42 |
+
keys = [s.rstrip('\n') for s in f]
|
| 43 |
+
if keys != [r['key'] for r in self.rows] or len(set(keys)) != len(keys):
|
| 44 |
+
raise ValueError('Frame index does not match the split')
|
| 45 |
+
self.by_key = {r['key']:i for i,r in enumerate(self.rows)}
|
| 46 |
+
|
| 47 |
+
def __len__(self):
|
| 48 |
+
return len(self.rows)
|
| 49 |
+
|
| 50 |
+
def file(self, name):
|
| 51 |
+
if self.local_dir:
|
| 52 |
+
return self.local_dir/name
|
| 53 |
+
return Path(hf_hub_download(REPO, name, repo_type='dataset', revision=self.revision, token=False))
|
| 54 |
+
|
| 55 |
+
def archive(self, name):
|
| 56 |
+
path = self.file(name)
|
| 57 |
+
if name.endswith('.tar.zst'):
|
| 58 |
+
# A single seekable copy per immutable source file, shared by data-loader workers.
|
| 59 |
+
scope = self.revision or 'download-'+hashlib.sha256(str(self.local_dir).encode()).hexdigest()[:16]
|
| 60 |
+
unpacked = (self.cache/scope/name).with_suffix('')
|
| 61 |
+
unpacked.parent.mkdir(parents=True, exist_ok=True)
|
| 62 |
+
with FileLock(str(unpacked)+'.lock'):
|
| 63 |
+
if not unpacked.exists():
|
| 64 |
+
with tempfile.NamedTemporaryFile(dir=unpacked.parent, delete=False) as out:
|
| 65 |
+
tmp = Path(out.name)
|
| 66 |
+
try:
|
| 67 |
+
with path.open('rb') as stream:
|
| 68 |
+
zstd.ZstdDecompressor().copy_stream(stream, out)
|
| 69 |
+
except BaseException:
|
| 70 |
+
tmp.unlink(missing_ok=True)
|
| 71 |
+
raise
|
| 72 |
+
tmp.replace(unpacked)
|
| 73 |
+
path = unpacked
|
| 74 |
+
return _tar(str(path), os.getpid())
|
| 75 |
+
|
| 76 |
+
def read(self, index):
|
| 77 |
+
row = self.rows[self.by_key[index] if isinstance(index, str) else index]
|
| 78 |
+
ar = self.archive(row['shard'])
|
| 79 |
+
with ar.extractfile(row['member']) as member, np.load(io.BytesIO(member.read()), allow_pickle=False) as z:
|
| 80 |
+
sample = {k:z[k] for k in z.files}
|
| 81 |
+
if str(sample['key']) != row['key']:
|
| 82 |
+
raise ValueError('Prepared frame identity mismatch')
|
| 83 |
+
if self.split == 'fit':
|
| 84 |
+
with self.archive(row['radar']).extractfile(row['radar_member']) as member:
|
| 85 |
+
data = zstd.ZstdDecompressor().decompress(member.read())
|
| 86 |
+
sample['cube'] = np.load(io.BytesIO(data), allow_pickle=False)
|
| 87 |
+
if 'img' in sample:
|
| 88 |
+
sample['image_rgb'] = sample.pop('img')
|
| 89 |
+
cube = sample['cube']
|
| 90 |
+
if cube.shape != (512,25,64) or cube.dtype != np.complex64 or sample['image_rgb'].shape != (3,360,640):
|
| 91 |
+
raise ValueError('Invalid radar/RGB dimensions')
|
| 92 |
+
if self.split == 'fit' and bool(sample['dense_present']) != row['dense']:
|
| 93 |
+
raise ValueError('Dense supervision flag mismatch')
|
| 94 |
+
inputs = {k:v for k,v in sample.items() if k in SENSORS}
|
| 95 |
+
labels = {k:v for k,v in sample.items() if k not in SENSORS|{'key','route'}}
|
| 96 |
+
if self.split == 'paired_eval' and labels:
|
| 97 |
+
raise ValueError('Unexpected labels in test sensors')
|
| 98 |
+
return {'key':row['key'], 'route':str(sample.get('route',row['episode'])), 'inputs':inputs, 'targets':labels}
|
| 99 |
+
|
| 100 |
+
__getitem__ = read
|
| 101 |
+
|
| 102 |
+
def available_keys(self):
|
| 103 |
+
"""Keys whose required shards exist at the selected revision or in the local download."""
|
| 104 |
+
if self.local_dir:
|
| 105 |
+
exists = lambda name: (self.local_dir/name).is_file()
|
| 106 |
+
else:
|
| 107 |
+
files = set(HfApi(token=False).list_repo_files(REPO, repo_type='dataset', revision=self.revision))
|
| 108 |
+
exists = files.__contains__
|
| 109 |
+
return [r['key'] for r in self.rows if exists(r['shard']) and ('radar' not in r or exists(r['radar']))]
|
| 110 |
+
|
| 111 |
+
def xfield_sample(self,index):
|
| 112 |
+
"""A fit/dev item accepted by XField_PredCore training.rgb_required.batchify."""
|
| 113 |
+
if self.split == 'paired_eval':
|
| 114 |
+
raise ValueError('Use read() for paired test inference')
|
| 115 |
+
frame = self.read(index)
|
| 116 |
+
item = {**frame['inputs'], **frame['targets'], 'key':frame['key'], 'route':frame['route']}
|
| 117 |
+
rgb = item.pop('image_rgb').astype(np.float32)/255
|
| 118 |
+
mean=np.array([.485,.456,.406], dtype=np.float32)[:,None,None]
|
| 119 |
+
std=np.array([.229,.224,.225], dtype=np.float32)[:,None,None]
|
| 120 |
+
item['image']=(rgb-mean)/std
|
| 121 |
+
item['dense'] = tuple(item.pop(n) for n in ('dense_sem','dense_height','dense_lane')) if bool(item.pop('dense_present')) else None
|
| 122 |
+
return item
|
| 123 |
+
|
| 124 |
+
def test_truth(self,index):
|
| 125 |
+
"""Read the separately stored targets when scoring frozen test predictions."""
|
| 126 |
+
if self.split != 'paired_eval':
|
| 127 |
+
raise ValueError('Test truth is available only for paired_eval')
|
| 128 |
+
row=self.rows[self.by_key[index] if isinstance(index,str) else index]
|
| 129 |
+
if not hasattr(self,'_vehicles'):
|
| 130 |
+
with gzip.open(self.file('test_labels/vehicles.jsonl.gz'),'rt') as f:
|
| 131 |
+
self._vehicles={r['key']:r for r in map(json.loads,f)}
|
| 132 |
+
out={'vehicles':self._vehicles[row['key']]}
|
| 133 |
+
if row['present']:
|
| 134 |
+
with tarfile.open(self.file('test_labels/scene_occupancy.tar.gz'),'r:gz') as ar:
|
| 135 |
+
with np.load(io.BytesIO(ar.extractfile(row['key']+'.npz').read()),allow_pickle=False) as z:
|
| 136 |
+
if str(z['key'])!=row['key']:raise ValueError('Test label identity mismatch')
|
| 137 |
+
shape=tuple(z['shape']);n=int(np.prod(shape))
|
| 138 |
+
out['occupancy']={k:np.unpackbits(z[k])[:n].reshape(shape).astype(bool) for k in ('obs','any')}
|
| 139 |
+
return out
|
| 140 |
+
|