rajanish4 commited on
Commit
e70edb1
·
verified ·
1 Parent(s): 5ea7518

add README.md

Browse files
Files changed (1) hide show
  1. README.md +268 -0
README.md ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ pretty_name: XMR Industrial Foreign Object Detection — Lentils (Hyperspectral)
4
+ task_categories:
5
+ - object-detection
6
+ - image-segmentation
7
+ tags:
8
+ - hyperspectral
9
+ - hsi
10
+ - food-quality
11
+ - food-safety
12
+ - industrial-inspection
13
+ - anomaly-detection
14
+ - foreign-object-detection
15
+ - lentils
16
+ - cuvis
17
+ - cubert
18
+ size_categories:
19
+ - 1K<n<10K
20
+ ---
21
+
22
+ # XMR Industrial Foreign Object Detection — Lentils (Hyperspectral)
23
+
24
+ **1,136 hyperspectral frames, 696 with pixel-level COCO annotations, 7 foreign-object
25
+ classes, 15 merged `.cu3s` capture sessions across 3 acquisition days.**
26
+
27
+ Companion dataset to the Cubert whitepaper *“Spectral Foreign Object Detection in
28
+ Lentils Using a Compact Hyperspectral Channel Selector”* (Raj, May 2026). The
29
+ dataset is the larger counterpart to the small demo at
30
+ [`cubert-gmbh/XMR_Demo_Industrial_Foreign_Object_Detection_Lentils`](https://huggingface.co/datasets/cubert-gmbh/XMR_Demo_Industrial_Foreign_Object_Detection_Lentils),
31
+ which contained a single 69-frame capture for the lentils tutorial notebook.
32
+
33
+ - 📄 Whitepaper: see `whitepaper/lentils_hsi_whitepaper_draft.md` (linked from Cubert AI documentation)
34
+ - 📦 Demo / tutorial: `cubert-gmbh/XMR_Demo_Industrial_Foreign_Object_Detection_Lentils`
35
+ - 📬 Contact: Anish Raj, Cubert GmbH — `raj@cubert-gmbh.de`
36
+
37
+ ## Summary
38
+
39
+ | | |
40
+ |---|---|
41
+ | Total frames | **1,136** |
42
+ | Annotated frames | **696** (61.3 %) |
43
+ | Annotated foreign-object regions | **1,536** |
44
+ | Hyperspectral cubes (merged `.cu3s` files) | **15** |
45
+ | Spectral resolution | **61 bands · 430–910 nm · 8 nm spacing** |
46
+ | Spatial resolution | **1080 × 1000** |
47
+ | Processing mode | **Reflectance** (55 % gray reference + dark reference) |
48
+ | Splits | **train 808 · val 148 · test 180** (71.1 / 13.0 / 15.8 %) |
49
+ | Total size on disk | **~57 GB** |
50
+ | License | **CC BY 4.0** |
51
+
52
+ ### Per-day breakdown
53
+
54
+ | Day | Capture date | Subfolders | Frames | Annotated | Foreign-object regions |
55
+ |---|---|---:|---:|---:|---:|
56
+ | day2 | 2026-03-03 | 6 | 384 | 188 | 368 |
57
+ | day3 | 2026-03-10 | 6 | 492 | 328 | 648 |
58
+ | day4 | 2026-03-17 | 3 | 260 | 180 | 520 |
59
+ | **Total** | | **15** | **1,136** | **696** | **1,536** |
60
+
61
+ ## Foreign-object classes
62
+
63
+ | id | name | object count |
64
+ |---:|--- |---:|
65
+ | 0 | `Unlabeled` | (background / normal lentils + belt) |
66
+ | 1 | `stem_k` | 288 |
67
+ | 2 | `stone` | 516 |
68
+ | 3 | `alu_shard` | 112 |
69
+ | 4 | `blue_paper` | 80 |
70
+ | 5 | `white_paper` | 60 |
71
+ | 6 | `fly` | 420 |
72
+ | 7 | `rubber` | 60 |
73
+
74
+ Class id 0 (`Unlabeled`) is the background and is implicit — pixels not covered by
75
+ any other category. Five subfolders contain only normal/background captures (no
76
+ foreign objects); their frames appear in `splits.csv` with `has_annotation=0`.
77
+
78
+ ## Acquisition setup
79
+
80
+ - Camera: **Cubert XMR 50 mm** hyperspectral, operated through Cuvis Next
81
+ - Illumination: 4 halogen lamps
82
+ - Background: blue FDA-compliant conveyor-belt material (belt stationary during capture)
83
+ - Field of view: ≈12.5 × 12 cm at 46.6 cm working distance
84
+ - Exposure: 15 ms
85
+ - White reference: 55 % gray target; dark reference acquired by covering the lens
86
+ - Lentils: **Emershofer Beluga** and **Emershofer dark green marbled**
87
+
88
+ For every scene arrangement, **four captures under different lighting conditions**
89
+ form a grouped unit (`group_id` in `splits.csv`). All four images of a group are
90
+ always kept in the same train / val / test split to prevent lighting-only
91
+ information leakage between evaluation sets.
92
+
93
+ The setup is a lab proof-of-concept with production-relevant design elements,
94
+ not a full production deployment study. See the whitepaper §Limitations for the
95
+ caveats.
96
+
97
+ ## Repository layout
98
+
99
+ ```
100
+ README.md
101
+ LICENSE (CC BY 4.0)
102
+ splits.csv # primary split file — 1 row per saved frame
103
+ splits_verification.md # proof that splits.csv mirrors the asai2 reference
104
+ asai2_singlefile_splits.csv # the original single-cu3s split, preserved for audit
105
+ dataset_summary.json # copied from whitepaper/dataset_summary.json
106
+ annotations_canonical/ # reference: per-day concatenated COCO (time-ordered global ids)
107
+ day2_global_coco.json
108
+ day3_global_coco.json
109
+ day4_global_coco.json
110
+ data/
111
+ day2/
112
+ <subfolder>.cu3s # hyperspectral cube (merged capture session)
113
+ <subfolder>.info # sensor sidecar (frame indexing)
114
+ <subfolder>.json # per-cu3s COCO annotations (image_ids are local 0..N-1)
115
+ … # 6 subfolders for day2
116
+ day3/ # 6 subfolders for day3
117
+ day4/ # 3 subfolders for day4
118
+ ```
119
+
120
+ `<subfolder>` is the capture-session timestamp `YYYY_MM_DD_HH-MM-SS` (with `_1`/`_2`
121
+ suffix when the camera was restarted at the same wall-clock second).
122
+
123
+ ### Per-`<subfolder>.json` COCO schema
124
+
125
+ Standard COCO with extra per-image fields for hyperspectral and traceability:
126
+
127
+ ```jsonc
128
+ {
129
+ "info": { "subfolder": "…", "day": "…", "frame_count": N, "annotation_count": M },
130
+ "licenses": [],
131
+ "categories": [ { "id": 0..7, "name": "Unlabeled|stem_k|…|rubber" } ],
132
+ "images": [
133
+ {
134
+ "id": <local_image_id>, // 0..N-1, matches index inside the .cu3s
135
+ "file_name": "<subfolder>.cu3s",
136
+ "width": 1080, "height": 1000,
137
+ "channels": 0, "wavelength": [],
138
+ "global_frame_id": <int>, // 0..(day_total-1) — keys to splits.csv & canonical day COCO
139
+ "camera_frame_num": <int>, // raw camera frame counter (matches `.info`)
140
+ "camera_name": "Auto_000_<n>"
141
+ }
142
+ ],
143
+ "annotations": [
144
+ { "id": …, "image_id": <local_image_id>, "category_id": 1..7,
145
+ "bbox": [x, y, w, h], "segmentation": [[…polygon…]],
146
+ "iscrowd": 0, "area": 0.0, "mask": {"counts": [], "size": []}, "auxiliary": {} }
147
+ ]
148
+ }
149
+ ```
150
+
151
+ The annotations are **semantic masks**, not instance-level. Individual objects
152
+ of the same class in the same frame share a polygon contour, not separate
153
+ instance ids.
154
+
155
+ ### `splits.csv` columns
156
+
157
+ | column | meaning |
158
+ |---|---|
159
+ | `day` | `day2` / `day3` / `day4` |
160
+ | `subfolder` | capture-session timestamp |
161
+ | `cu3s_path` | path inside this repo, e.g. `data/day2/2026_03_03_13-58-04_2.cu3s` |
162
+ | `json_path` | matching per-cu3s COCO path |
163
+ | `local_image_id` | 0..N-1 inside the merged `.cu3s` |
164
+ | `global_image_id` | 0..(day_total-1), in time order across the whole day — join key to `annotations_canonical/day*_global_coco.json` and to `asai2_singlefile_splits.csv` |
165
+ | `camera_frame_num` | raw camera frame counter (matches `.info`) |
166
+ | `camera_name` | `Auto_000_<n>` — single-cu3s identifier used by the original asai2 split |
167
+ | `split` | `train` / `val` / `test` |
168
+ | `group_id` | 4-frame lighting-quad group; all 4 frames of a group share one split |
169
+ | `group_index` | 0..3, position inside the lighting quad |
170
+ | `has_annotation` | 1 if the frame contains any foreign-object annotation, else 0 |
171
+ | `category_labels` | semicolon-separated category ids present in the frame (empty for normal frames) |
172
+
173
+ ## Splits
174
+
175
+ | split | frames | annotated frames | objects |
176
+ |---|---:|---:|---:|
177
+ | train | 808 | 500 | — |
178
+ | validation | 148 | 84 | — |
179
+ | test | 180 | 112 | — |
180
+
181
+ The split was originally generated on the single-cu3s form of the data using
182
+ stratified group-aware splitting (lighting quads kept intact, category balance
183
+ preserved across splits). The original single-cu3s assignment is preserved
184
+ verbatim in `asai2_singlefile_splits.csv`. The `splits.csv` file in this repo
185
+ remaps each single-cu3s row to its position inside the corresponding merged
186
+ `.cu3s` file. See `splits_verification.md` for the seven-check proof that this
187
+ remapping is bit-faithful (coverage, per-day counts, per-subfolder counts,
188
+ annotation equivalence, split distribution, no-group-leakage, and a physical
189
+ round-trip through `cuvis.SessionFile`).
190
+
191
+ ## How to load
192
+
193
+ ### List the test set
194
+
195
+ ```python
196
+ import csv
197
+ from huggingface_hub import hf_hub_download
198
+
199
+ splits_csv = hf_hub_download(
200
+ repo_id="cubert-gmbh/XMR_Industrial_Foreign_Object_Detection_Lentils",
201
+ repo_type="dataset",
202
+ filename="splits.csv",
203
+ )
204
+ with open(splits_csv) as f:
205
+ rows = [r for r in csv.DictReader(f) if r["split"] == "test"]
206
+ print(len(rows), "test frames")
207
+ ```
208
+
209
+ ### Stream one cu3s + annotations
210
+
211
+ ```python
212
+ from huggingface_hub import hf_hub_download
213
+
214
+ repo = "cubert-gmbh/XMR_Industrial_Foreign_Object_Detection_Lentils"
215
+ sub = "data/day4/2026_03_17_11-11-50"
216
+ cu3s = hf_hub_download(repo_id=repo, repo_type="dataset", filename=f"{sub}.cu3s")
217
+ info = hf_hub_download(repo_id=repo, repo_type="dataset", filename=f"{sub}.info")
218
+ js = hf_hub_download(repo_id=repo, repo_type="dataset", filename=f"{sub}.json")
219
+
220
+ import cuvis, json
221
+ cuvis.init()
222
+ sess = cuvis.SessionFile(cu3s)
223
+ print("frames in cube:", sess.get_size())
224
+ mesu = sess.get_measurement(0)
225
+ print("cube shape:", mesu.cube.array.shape) # (1000, 1080, 61)
226
+
227
+ anns = json.load(open(js))
228
+ print("annotated frames:", sum(any(a['image_id']==im['id'] for a in anns['annotations'])
229
+ for im in anns['images']))
230
+ ```
231
+
232
+ ### Mirror everything to a local directory
233
+
234
+ ```bash
235
+ huggingface-cli download \
236
+ cubert-gmbh/XMR_Industrial_Foreign_Object_Detection_Lentils \
237
+ --repo-type=dataset \
238
+ --local-dir=./lentils_full \
239
+ --local-dir-use-symlinks=False
240
+ ```
241
+
242
+ Or programmatically with `snapshot_download(...)` and `allow_patterns=` to fetch
243
+ only specific days / files.
244
+
245
+ ## Citation
246
+
247
+ ```bibtex
248
+ @techreport{raj2026lentilshsi,
249
+ title = {Spectral Foreign Object Detection in Lentils Using a Compact Hyperspectral Channel Selector},
250
+ author = {Raj, Anish},
251
+ institution = {Cubert GmbH},
252
+ year = {2026},
253
+ note = {Whitepaper, draft v0.1, May 2026}
254
+ }
255
+ ```
256
+
257
+ ## License
258
+
259
+ This dataset is released under the [**Creative Commons Attribution 4.0 International (CC BY 4.0)**](https://creativecommons.org/licenses/by/4.0/) license.
260
+
261
+ You are free to share and adapt the material for any purpose, even commercially,
262
+ provided you give appropriate credit (cite the whitepaper above and link to this
263
+ dataset), indicate if changes were made, and do not apply legal or technological
264
+ restrictions that prevent others from doing the same.
265
+
266
+ The whitepaper draft mentioned Apache 2.0 as the planned license; the final
267
+ choice for the dataset is CC BY 4.0 (the more standard license for data),
268
+ chosen by the dataset author.