Datasets:
Tasks:
Image Segmentation
Modalities:
Image
Sub-tasks:
semantic-segmentation
Languages:
English
Size:
10K - 100K
License:
Upload dataset.py
Browse files- dataset.py +80 -0
dataset.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
_CITATION = """\
|
5 |
+
@InProceedings{huggingface:dataset,
|
6 |
+
title = {RSNA-ATD2023},
|
7 |
+
author = {Yeow Zi Qin},
|
8 |
+
year = {2023}
|
9 |
+
}
|
10 |
+
"""
|
11 |
+
|
12 |
+
_DESCRIPTION = """\
|
13 |
+
The dataset is the processed version of Kaggle Competition: RSNA 2023 Abdominal Trauma Detection.
|
14 |
+
It comprises of segmentation of 205 series of CT scans with 5 classes (liver, spleen, right_kidney,
|
15 |
+
left_kidney, bowel).
|
16 |
+
"""
|
17 |
+
|
18 |
+
_NAME = "RSNA-ATD2023"
|
19 |
+
|
20 |
+
_HOMEPAGE = f"https://huggingface.co/datasets/ziq/{_NAME}"
|
21 |
+
|
22 |
+
_LICENSE = "MIT"
|
23 |
+
|
24 |
+
_DATA = f"https://huggingface.co/datasets/ziq/{_NAME}/resolve/main/data/"
|
25 |
+
|
26 |
+
|
27 |
+
class PeopleTrackingDataset(datasets.GeneratorBasedBuilder):
|
28 |
+
"""Small sample of image-text pairs"""
|
29 |
+
|
30 |
+
def _info(self):
|
31 |
+
return datasets.DatasetInfo(
|
32 |
+
description=_DESCRIPTION,
|
33 |
+
features=datasets.Features(
|
34 |
+
{
|
35 |
+
"patient_id": datasets.Value("int32"),
|
36 |
+
"series_id": datasets.Value("int32"),
|
37 |
+
"frame_id": datasets.Value("int32"),
|
38 |
+
"image": datasets.Image(),
|
39 |
+
"mask": datasets.Image(),
|
40 |
+
}
|
41 |
+
),
|
42 |
+
supervised_keys=None,
|
43 |
+
homepage=_HOMEPAGE,
|
44 |
+
citation=_CITATION,
|
45 |
+
)
|
46 |
+
|
47 |
+
def _split_generators(self, dl_manager):
|
48 |
+
train_images = dl_manager.download(f"{_DATA}train.tar.gz")
|
49 |
+
train_masks = dl_manager.download(f"{_DATA}seg.tar.gz")
|
50 |
+
|
51 |
+
metadata = dl_manager.download(f"{_DATA}train.csv")
|
52 |
+
train_images = dl_manager.iter_archive(train_images)
|
53 |
+
train_masks = dl_manager.iter_archive(train_masks)
|
54 |
+
|
55 |
+
return [
|
56 |
+
datasets.SplitGenerator(
|
57 |
+
name=datasets.Split.TRAIN,
|
58 |
+
gen_kwargs={
|
59 |
+
"images": train_images,
|
60 |
+
"masks": train_masks,
|
61 |
+
"metadata": metadata,
|
62 |
+
},
|
63 |
+
),
|
64 |
+
]
|
65 |
+
|
66 |
+
def _generate_examples(self, images, masks, metadata):
|
67 |
+
df = pd.read_csv(metadata)
|
68 |
+
|
69 |
+
for idx, ((image_path, image), (mask_path, mask)) in enumerate(
|
70 |
+
zip(images, masks)
|
71 |
+
):
|
72 |
+
row = df.loc[df["path"] == image_path.lower()]
|
73 |
+
|
74 |
+
yield idx, {
|
75 |
+
"patient_id": row["patient_id"].values[0],
|
76 |
+
"series_id": row["series_id"].values[0],
|
77 |
+
"frame_id": row["frame_id"].values[0],
|
78 |
+
"image": {"path": image_path, "bytes": image.read()},
|
79 |
+
"mask": {"path": mask_path, "bytes": mask.read()},
|
80 |
+
}
|