Datasets:
Update README for flattened single-split structure with embedded videos and inline boxes
Browse files
README.md
CHANGED
|
@@ -16,85 +16,93 @@ configs:
|
|
| 16 |
- config_name: default
|
| 17 |
data_files:
|
| 18 |
- split: train
|
| 19 |
-
path: data/train-*
|
| 20 |
-
dataset_info:
|
| 21 |
-
features:
|
| 22 |
-
- name: video
|
| 23 |
-
dtype:
|
| 24 |
-
video:
|
| 25 |
-
decode: false
|
| 26 |
-
- name: video_id
|
| 27 |
-
dtype: string
|
| 28 |
-
- name: patient_id
|
| 29 |
-
dtype: int64
|
| 30 |
-
- name: boxes
|
| 31 |
-
struct:
|
| 32 |
-
- name: track_id
|
| 33 |
-
list: int64
|
| 34 |
-
- name: frame
|
| 35 |
-
list: int64
|
| 36 |
-
- name: label
|
| 37 |
-
list: string
|
| 38 |
-
- name: xtl
|
| 39 |
-
list: float32
|
| 40 |
-
- name: ytl
|
| 41 |
-
list: float32
|
| 42 |
-
- name: xbr
|
| 43 |
-
list: float32
|
| 44 |
-
- name: ybr
|
| 45 |
-
list: float32
|
| 46 |
-
- name: occluded
|
| 47 |
-
list: int64
|
| 48 |
-
- name: outside
|
| 49 |
-
list: int64
|
| 50 |
-
- name: keyframe
|
| 51 |
-
list: int64
|
| 52 |
-
- name: z_order
|
| 53 |
-
list: int64
|
| 54 |
-
- name: n_boxes
|
| 55 |
-
dtype: int64
|
| 56 |
-
- name: histological_type
|
| 57 |
-
dtype: string
|
| 58 |
-
- name: num_frames
|
| 59 |
-
dtype: int64
|
| 60 |
-
- name: light_mode
|
| 61 |
-
dtype: string
|
| 62 |
-
splits:
|
| 63 |
-
- name: train
|
| 64 |
-
num_bytes: 4327196551
|
| 65 |
-
num_examples: 173
|
| 66 |
-
download_size: 4327526548
|
| 67 |
-
dataset_size: 4327196551
|
| 68 |
---
|
| 69 |
|
| 70 |
# Cystoscopy Tumor Detection
|
| 71 |
|
| 72 |
-
Cystoscopic video dataset with per-frame `tumor` bounding-box annotations,
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
##
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
| `data/videos/` | 173 raw cystoscopy `.mp4` tracks (~4 GB). Filename pattern `P{NN}_cystoscopy_track_{NNN}.mp4`. |
|
| 79 |
-
| `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`. |
|
| 80 |
-
| `data/clinical_info.parquet` | One row per patient (n=30). Columns: `patient_id, histological_type, num_frames, light_mode`. |
|
| 81 |
-
| `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. |
|
| 82 |
|
| 83 |
-
##
|
| 84 |
|
| 85 |
-
|
| 86 |
-
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
## Loading
|
| 90 |
|
| 91 |
```python
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
```
|
| 97 |
|
| 98 |
-
##
|
| 99 |
|
| 100 |
-
|
|
|
|
|
|
| 16 |
- config_name: default
|
| 17 |
data_files:
|
| 18 |
- split: train
|
| 19 |
+
path: data/train-*.parquet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
---
|
| 21 |
|
| 22 |
# Cystoscopy Tumor Detection
|
| 23 |
|
| 24 |
+
Cystoscopic video dataset with per-frame `tumor` bounding-box annotations,
|
| 25 |
+
paired with patient-level clinical metadata. Flattened into a single `train`
|
| 26 |
+
split with one row per video; videos are embedded in the Parquet shards as HF
|
| 27 |
+
`Video` features and bounding boxes are stored inline.
|
| 28 |
|
| 29 |
+
## Why no splits
|
| 30 |
|
| 31 |
+
This dataset ships **one `train` split only**. Use the `patient_id` column to
|
| 32 |
+
build your own patient-grouped splits to prevent leakage. 30 unique patients.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
## Columns
|
| 35 |
|
| 36 |
+
| Column | Type | Description |
|
| 37 |
+
|---|---|---|
|
| 38 |
+
| `video` | `Video` | Embedded video bytes (`decode=False` — returns `{bytes, path}`; cast to `Video(decode=True)` to decode frames, requires `torchcodec`). |
|
| 39 |
+
| `video_id` | `string` | Filename stem, e.g. `P000_cystoscopy_track_000`. |
|
| 40 |
+
| `patient_id` | `int64` | Patient id — use this for group-aware splitting. |
|
| 41 |
+
| `boxes` | `struct` | Per-box annotations as parallel lists (see below). `n = len(boxes["frame"])` boxes for this video. |
|
| 42 |
+
| `n_boxes` | `int64` | Number of boxes for this video. |
|
| 43 |
+
| `histological_type` | `string` | Patient-level histology (e.g. `Urothelial carcinoma pTaLG`). |
|
| 44 |
+
| `num_frames` | `int64` | Patient-level total annotated frames. |
|
| 45 |
+
| `light_mode` | `string` | Imaging light mode (e.g. `CLARA + CHROMA`). |
|
| 46 |
+
|
| 47 |
+
### `boxes` struct fields
|
| 48 |
+
|
| 49 |
+
Each field is a list of length `n_boxes`; index `i` across all fields
|
| 50 |
+
describes one box.
|
| 51 |
+
|
| 52 |
+
| Field | Type | Description |
|
| 53 |
+
|---|---|---|
|
| 54 |
+
| `track_id` | `int64` | Annotation track within the video. |
|
| 55 |
+
| `frame` | `int64` | Frame number the box belongs to. |
|
| 56 |
+
| `label` | `string` | Box label (always `tumor`). |
|
| 57 |
+
| `xtl`, `ytl`, `xbr`, `ybr` | `float32` | Absolute pixel coordinates (CVAT format). |
|
| 58 |
+
| `occluded` | `int64` | Occlusion flag. |
|
| 59 |
+
| `outside` | `int64` | Outside flag. |
|
| 60 |
+
| `keyframe` | `int64` | Keyframe flag. |
|
| 61 |
+
| `z_order` | `int64` | Z-order. |
|
| 62 |
+
|
| 63 |
+
## Contents
|
| 64 |
+
|
| 65 |
+
- 173 cystoscopy `.mp4` videos (~4 GB, embedded).
|
| 66 |
+
- 69 108 bounding boxes across 444 annotation tracks.
|
| 67 |
+
- 30 patients with clinical metadata.
|
| 68 |
|
| 69 |
## Loading
|
| 70 |
|
| 71 |
```python
|
| 72 |
+
from datasets import load_dataset
|
| 73 |
+
ds = load_dataset("milkyroad/B", split="train")
|
| 74 |
+
# video is not decoded by default (no torchcodec required to load)
|
| 75 |
+
print(ds[0]["video"]) # {'bytes': ..., 'path': 'P000_cystoscopy_track_000.mp4'}
|
| 76 |
+
print(ds[0]["n_boxes"]) # 233
|
| 77 |
+
boxes = ds[0]["boxes"]
|
| 78 |
+
print(boxes["frame"][0], boxes["label"][0], boxes["xtl"][0])
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### Decode video frames
|
| 82 |
+
|
| 83 |
+
To decode frames, install `torchcodec` and cast the column:
|
| 84 |
+
|
| 85 |
+
```python
|
| 86 |
+
from datasets import Video
|
| 87 |
+
ds = ds.cast_column("video", Video(decode=True))
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
## Group-aware split example
|
| 91 |
+
|
| 92 |
+
```python
|
| 93 |
+
import random
|
| 94 |
+
ds = load_dataset("milkyroad/B", split="train")
|
| 95 |
+
pids = sorted({r["patient_id"] for r in ds})
|
| 96 |
+
random.Random(42).shuffle(pids)
|
| 97 |
+
n_test, n_val = 3, 3
|
| 98 |
+
test_pids = set(pids[:n_test])
|
| 99 |
+
val_pids = set(pids[n_test:n_test + n_val])
|
| 100 |
+
train = ds.filter(lambda r: r["patient_id"] not in test_pids and r["patient_id"] not in val_pids)
|
| 101 |
+
val = ds.filter(lambda r: r["patient_id"] in val_pids)
|
| 102 |
+
test = ds.filter(lambda r: r["patient_id"] in test_pids)
|
| 103 |
```
|
| 104 |
|
| 105 |
+
## Notes
|
| 106 |
|
| 107 |
+
- Box coordinates are absolute pixel coordinates in the source video frames (CVAT format).
|
| 108 |
+
- Splits should be by **patient** to prevent leakage; `patient_id` is provided for this purpose.
|