--- license: apache-2.0 pretty_name: XMR Industrial Foreign Object Detection — Lentils (Hyperspectral) task_categories: - object-detection - image-segmentation tags: - hyperspectral - hsi - food-quality - food-safety - industrial-inspection - anomaly-detection - foreign-object-detection - lentils - cuvis - cubert size_categories: - 1K.cu3s # hyperspectral cube (merged capture session) .info # sensor sidecar (frame indexing) .json # per-cu3s COCO annotations (image_ids are local 0..N-1) … # 6 subfolders for day2 day3/ # 6 subfolders for day3 day4/ # 3 subfolders for day4 ``` `` is the capture-session timestamp `YYYY_MM_DD_HH-MM-SS` (with `_1`/`_2` suffix when the camera was restarted at the same wall-clock second). ### Per-`.json` COCO schema Standard COCO with extra per-image fields for hyperspectral and traceability: ```jsonc { "info": { "subfolder": "…", "day": "…", "frame_count": N, "annotation_count": M }, "categories": [ { "id": 0..7, "name": "Unlabeled|stem_k|…|rubber" } ], "images": [ { "id": , // 0..N-1, matches index inside the .cu3s "file_name": ".cu3s", "width": 1080, "height": 1000, "global_frame_id": , // 0..(day_total-1) — keys to splits.csv & canonical day COCO "camera_frame_num": , // raw camera frame counter (matches `.info`) "camera_name": "Auto_000_" } ], "annotations": [ { "id": …, "image_id": , "category_id": 1..7, "bbox": [x, y, w, h], "segmentation": [[…polygon…]], "iscrowd": 0, "area": 0.0, "mask": {"counts": [], "size": []}, "auxiliary": {} } ] } ``` The annotations are **semantic masks**, not instance-level. Individual objects of the same class in the same frame share a polygon contour, not separate instance ids. ### `splits.csv` columns | column | meaning | |---|---| | `day` | `day2` / `day3` / `day4` | | `subfolder` | capture-session timestamp | | `cu3s_path` | path inside this repo, e.g. `data/day2/2026_03_03_13-58-04_2.cu3s` | | `json_path` | matching per-cu3s COCO path | | `local_image_id` | 0..N-1 inside the merged `.cu3s` | | `global_image_id` | 0..(day_total-1), in time order across the whole day — join key to `annotations_canonical/day*_global_coco.json` | | `camera_frame_num` | raw camera frame counter (matches `.info`) | | `camera_name` | `Auto_000_` — single-cu3s identifier used by the original asai2 split | | `split` | `train` / `val` / `test` | | `group_id` | 4-frame lighting-quad group; all 4 frames of a group share one split | | `group_index` | 0..3, position inside the lighting quad | | `has_annotation` | 1 if the frame contains any foreign-object annotation, else 0 | | `category_labels` | semicolon-separated category ids present in the frame (empty for normal frames) | ## Example frames (loaded from this repo via `huggingface_hub`) All three examples below were produced by downloading the `.cu3s` and matching `.json` from this dataset on Hugging Face, reading the cube via `cuvis.SessionFile` in `ProcessingMode.Reflectance`, and overlaying the COCO polygons directly. The generating script is `make_examples_remote.py` in this repo's release notes. ### Train · no foreign object (normal/background) `data/day2/2026_03_03_11-11-01.cu3s` · `image_id=0` · 0 annotations · split=`train` | RGB composite (650 / 550 / 450 nm) | CIR composite (860 / 670 / 560 nm) | |---|---| | ![](assets/examples/2026_03_03_11-11-01_id0000_rgb.png) | ![](assets/examples/2026_03_03_11-11-01_id0000_cir.png) | ### Train · 1 foreign object (stone) `data/day3/2026_03_10_10-58-55.cu3s` · `image_id=0` · 1 annotation (`stone`) · split=`train` | RGB + annotation | CIR + annotation | |---|---| | ![](assets/examples/2026_03_10_10-58-55_id0000_rgb_annotated.png) | ![](assets/examples/2026_03_10_10-58-55_id0000_cir_annotated.png) | ### Train · 3 foreign objects (alu_shard + fly + stone) `data/day4/2026_03_17_11-41-54.cu3s` · `image_id=40` · 3 annotations · split=`train` | RGB + annotations | CIR + annotations | |---|---| | ![](assets/examples/2026_03_17_11-41-54_id0040_rgb_annotated.png) | ![](assets/examples/2026_03_17_11-41-54_id0040_cir_annotated.png) | ### Split-loader sanity check The HF copy was verified to load the right frame for one example per split by downloading the cu3s via `huggingface_hub` and asserting `cuvis.SessionFile.get_measurement(splits.local_image_id).name` matches the `camera_name` predicted by `splits.csv`: | split | cu3s | `local_image_id` | expected `Auto_000_` | got | ok | |---|---|---:|---|---|---| | train | `data/day2/2026_03_03_11-11-01.cu3s` | 0 | `Auto_000_4261` | `Auto_000_4261` | ✅ | | val | `data/day2/2026_03_03_11-31-31.cu3s` | 14 | `Auto_000_1339` | `Auto_000_1339` | ✅ | | test | `data/day3/2026_03_10_10-58-55.cu3s` | 12 | `Auto_000_1370` | `Auto_000_1370` | ✅ | Polygon-bounds sanity: every annotation polygon vertex in the loaded frames lies inside the image rectangle `(0..1080, 0..1000)`. No clipping needed. ## Splits | split | frames | annotated frames | objects | |---|---:|---:|---:| | train | 808 | 500 | — | | validation | 148 | 84 | — | | test | 180 | 112 | — | The split was originally generated on the single-cu3s form of the data using stratified group-aware splitting (lighting quads kept intact, category balance preserved across splits). The `splits.csv` file in this repo remaps each single-cu3s row to its position inside the corresponding merged `.cu3s` file. See `splits_verification.md` for the seven-check proof that this remapping is bit-faithful (coverage, per-day counts, per-subfolder counts, annotation equivalence, split distribution, no-group-leakage, and a physical round-trip through `cuvis.SessionFile`). ## How to load ### List the test set ```python import csv from huggingface_hub import hf_hub_download splits_csv = hf_hub_download( repo_id="cubert-gmbh/XMR_Industrial_Foreign_Object_Detection_Lentils", repo_type="dataset", filename="splits.csv", ) with open(splits_csv) as f: rows = [r for r in csv.DictReader(f) if r["split"] == "test"] print(len(rows), "test frames") ``` ### Stream one cu3s + annotations ```python from huggingface_hub import hf_hub_download repo = "cubert-gmbh/XMR_Industrial_Foreign_Object_Detection_Lentils" sub = "data/day4/2026_03_17_11-11-50" cu3s = hf_hub_download(repo_id=repo, repo_type="dataset", filename=f"{sub}.cu3s") info = hf_hub_download(repo_id=repo, repo_type="dataset", filename=f"{sub}.info") js = hf_hub_download(repo_id=repo, repo_type="dataset", filename=f"{sub}.json") import cuvis, json cuvis.init() sess = cuvis.SessionFile(cu3s) print("frames in cube:", sess.get_size()) mesu = sess.get_measurement(0) print("cube shape:", mesu.cube.array.shape) # (1000, 1080, 61) anns = json.load(open(js)) print("annotated frames:", sum(any(a['image_id']==im['id'] for a in anns['annotations']) for im in anns['images'])) ``` ### Mirror everything to a local directory ```bash huggingface-cli download \ cubert-gmbh/XMR_Industrial_Foreign_Object_Detection_Lentils \ --repo-type=dataset \ --local-dir=./lentils_full \ --local-dir-use-symlinks=False ``` Or programmatically with `snapshot_download(...)` and `allow_patterns=` to fetch only specific days / files. ## Citation ```bibtex @techreport{raj2026lentilshsi, title = {Spectral Foreign Object Detection in Lentils Using a Compact Hyperspectral Channel Selector}, author = {Raj, Anish}, institution = {Cubert GmbH}, year = {2026}, note = {Whitepaper, draft v0.1, May 2026} } ``` ## License This dataset is released under the [**Apache License 2.0**](https://www.apache.org/licenses/LICENSE-2.0). You are free to use, modify, distribute, and redistribute this dataset for any purpose, including commercial use, subject to the terms of the Apache 2.0 license — primarily, retention of the copyright/license notice and a NOTICE-style attribution if you publish derivative works. Citing the whitepaper above is appreciated. This matches the licensing used across other Cubert public datasets on Hugging Face.