Datasets:
Update README for flattened single-split structure with embedded videos and inline boxes
Browse files15 unmodified lines16171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910015 unmodified lines- config_name: defaultdata_files:- split: trainpath: data/train-*dataset_info:features:- name: videodtype:video:decode: false- name: video_iddtype: string- name: patient_iddtype: int64- name: boxesstruct:- name: track_idlist: int64- name: framelist: int64- name: labellist: string- name: xtllist: float32- name: ytllist: float32- name: xbrlist: float32- name: ybrlist: float32- name: occludedlist: int64- name: outsidelist: int64- name: keyframelist: int64- name: z_orderlist: int64- name: n_boxesdtype: int64- name: histological_typedtype: string- name: num_framesdtype: int64- name: light_modedtype: stringsplits:- name: trainnum_bytes: 4327196551num_examples: 173download_size: 4327526548dataset_size: 4327196551---# Cystoscopy Tumor DetectionCystoscopic video dataset with per-frame `tumor` bounding-box annotations, paired with patient-level clinical metadata.## Contents| Path | Description ||---|---|| `data/videos/` | 173 raw cystoscopy `.mp4` tracks (~4 GB). Filename pattern `P{NN}_cystoscopy_track_{NNN}.mp4`. || `data/annotations.parquet` | Long-format bounding boxes: one row per box (69 108 rows, 444 tracks). Columns: `video_id, patient_id, track_id, frame, label, xtl, ytl, xbr, ybr, occluded, outside, keyframe, z_order`. || `data/clinical_info.parquet` | One row per patient (n=30). Columns: `patient_id, histological_type, num_frames, light_mode`. || `splits/{train,val,test}.txt` | Patient-grouped video-id lists (seeded shuffle, seed=42). 24 / 3 / 3 patients → 132 / 18 / 23 videos. No patient appears in more than one split. |## Notes- Box coordinates are absolute pixel coordinates in the source video frames (CVAT format).- `annotated_videos/` (boxes burned into the pixels) is **not** shipped — it is fully reproducible from `annotations.parquet` + `data/videos/` via the included `overlay_boxes.ipynb`.- Splits are by **patient** to prevent leakage; adjust by editing `splits/*.txt`.## Loading```pythonimport pandas as pd, pathlibann = pd.read_parquet("hf://datasets/milkyroad/B/data/annotations.parquet")cli = pd.read_parquet("hf://datasets/milkyroad/B/data/clinical_info.parquet")train_ids = pathlib.Path("hf://datasets/milkyroad/B/splits/train.txt").read_text().split()```## ReproducibilitySplits generated with `random.Random(42)` over the sorted patient-id list (0–29).15 unmodified lines16171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710815 unmodified lines- config_name: defaultdata_files:- split: trainpath: data/train-*.parquet---# Cystoscopy Tumor DetectionCystoscopic video dataset with per-frame `tumor` bounding-box annotations,paired with patient-level clinical metadata. Flattened into a single `train`split with one row per video; videos are embedded in the Parquet shards as HF`Video` features and bounding boxes are stored inline.## Why no splitsThis dataset ships **one `train` split only**. Use the `patient_id` column tobuild your own patient-grouped splits to prevent leakage. 30 unique patients.## Columns| Column | Type | Description ||---|---|---|| `video` | `Video` | Embedded video bytes (`decode=False` — returns `{bytes, path}`; cast to `Video(decode=True)` to decode frames, requires `torchcodec`). || `video_id` | `string` | Filename stem, e.g. `P000_cystoscopy_track_000`. || `patient_id` | `int64` | Patient id — use this for group-aware splitting. || `boxes` | `struct` | Per-box annotations as parallel lists (see below). `n = len(boxes["frame"])` boxes for this video. || `n_boxes` | `int64` | Number of boxes for this video. || `histological_type` | `string` | Patient-level histology (e.g. `Urothelial carcinoma pTaLG`). || `num_frames` | `int64` | Patient-level total annotated frames. || `light_mode` | `string` | Imaging light mode (e.g. `CLARA + CHROMA`). |### `boxes` struct fieldsEach field is a list of length `n_boxes`; index `i` across all fieldsdescribes one box.| Field | Type | Description ||---|---|---|| `track_id` | `int64` | Annotation track within the video. || `frame` | `int64` | Frame number the box belongs to. || `label` | `string` | Box label (always `tumor`). || `xtl`, `ytl`, `xbr`, `ybr` | `float32` | Absolute pixel coordinates (CVAT format). || `occluded` | `int64` | Occlusion flag. || `outside` | `int64` | Outside flag. || `keyframe` | `int64` | Keyframe flag. || `z_order` | `int64` | Z-order. |## Contents- 173 cystoscopy `.mp4` videos (~4 GB, embedded).- 69 108 bounding boxes across 444 annotation tracks.- 30 patients with clinical metadata.## Loading```pythonfrom datasets import load_datasetds = load_dataset("milkyroad/B", split="train")# video is not decoded by default (no torchcodec required to load)print(ds[0]["video"]) # {'bytes': ..., 'path': 'P000_cystoscopy_track_000.mp4'}print(ds[0]["n_boxes"]) # 233boxes = ds[0]["boxes"]print(boxes["frame"][0], boxes["label"][0], boxes["xtl"][0])```### Decode video framesTo decode frames, install `torchcodec` and cast the column:```pythonfrom datasets import Videods = ds.cast_column("video", Video(decode=True))```## Group-aware split example```pythonimport randomds = load_dataset("milkyroad/B", split="train")pids = sorted({r["patient_id"] for r in ds})random.Random(42).shuffle(pids)n_test, n_val = 3, 3test_pids = set(pids[:n_test])val_pids = set(pids[n_test:n_test + n_val])train = ds.filter(lambda r: r["patient_id"] not in test_pids and r["patient_id"] not in val_pids)val = ds.filter(lambda r: r["patient_id"] in val_pids)test = ds.filter(lambda r: r["patient_id"] in test_pids)```## Notes- Box coordinates are absolute pixel coordinates in the source video frames (CVAT format).- Splits should be by **patient** to prevent leakage; `patient_id` is provided for this purpose.
README.md+75-67