Update rsna-atd.py
Browse files- rsna-atd.py +18 -15
rsna-atd.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import datasets
|
2 |
import pandas as pd
|
|
|
3 |
|
4 |
_CITATION = """\
|
5 |
@InProceedings{huggingface:dataset,
|
@@ -30,8 +31,6 @@ class RSNAATD(datasets.GeneratorBasedBuilder):
|
|
30 |
description=_DESCRIPTION,
|
31 |
features=datasets.Features(
|
32 |
{
|
33 |
-
"image_path": datasets.Value("string"),
|
34 |
-
"mask_path": datasets.Value("string")
|
35 |
# "patient_id": datasets.Value("int64"),
|
36 |
# "series_id": datasets.Value("int64"),
|
37 |
# "aortic_hu": datasets.Value("float64"),
|
@@ -50,8 +49,8 @@ class RSNAATD(datasets.GeneratorBasedBuilder):
|
|
50 |
# "spleen_low": datasets.Value("int64"),
|
51 |
# "spleen_high": datasets.Value("int64"),
|
52 |
# "any_injury": datasets.Value("int64"),
|
53 |
-
|
54 |
-
|
55 |
}
|
56 |
),
|
57 |
supervised_keys=None,
|
@@ -80,16 +79,20 @@ class RSNAATD(datasets.GeneratorBasedBuilder):
|
|
80 |
|
81 |
def _generate_examples(self, images, masks, metadata):
|
82 |
df = pd.read_csv(metadata)
|
|
|
|
|
83 |
|
84 |
-
|
85 |
-
# row = df.loc[df["path"] == image_path.lower().replace("images/", "")]
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
1 |
import datasets
|
2 |
import pandas as pd
|
3 |
+
import hickle as hkl
|
4 |
|
5 |
_CITATION = """\
|
6 |
@InProceedings{huggingface:dataset,
|
|
|
31 |
description=_DESCRIPTION,
|
32 |
features=datasets.Features(
|
33 |
{
|
|
|
|
|
34 |
# "patient_id": datasets.Value("int64"),
|
35 |
# "series_id": datasets.Value("int64"),
|
36 |
# "aortic_hu": datasets.Value("float64"),
|
|
|
49 |
# "spleen_low": datasets.Value("int64"),
|
50 |
# "spleen_high": datasets.Value("int64"),
|
51 |
# "any_injury": datasets.Value("int64"),
|
52 |
+
"image": datasets.Array3D(shape=(None, 512, 512)),
|
53 |
+
"mask": datasets.Array3D(shape=(None, 512, 512)),
|
54 |
}
|
55 |
),
|
56 |
supervised_keys=None,
|
|
|
79 |
|
80 |
def _generate_examples(self, images, masks, metadata):
|
81 |
df = pd.read_csv(metadata)
|
82 |
+
for idx, data in df.to_numpy():
|
83 |
+
image, mask = hkl.load(f"images/{data[0]}"), hkl.load(f"masks/{data[0]}")
|
84 |
|
85 |
+
yield idx, {"image": image, "mask": mask}
|
|
|
86 |
|
87 |
+
# for idx, ((image_path), (mask_path)) in enumerate(zip(images, masks)):
|
88 |
+
# # row = df.loc[df["path"] == image_path.lower().replace("images/", "")]
|
89 |
+
|
90 |
+
# yield idx, {
|
91 |
+
# "image_path": image_path,
|
92 |
+
# "mask_path": mask_path
|
93 |
+
# # "patient_id": row["patient_id"].values[0],
|
94 |
+
# # "series_id": row["series_id"].values[0],
|
95 |
+
# # "frame_id": row["frame_id"].values[0],
|
96 |
+
# # "image": {"path": image_path, "bytes": image.read()},
|
97 |
+
# # "mask": {"path": mask_path, "bytes": mask.read()},
|
98 |
+
# }
|