Datasets:
Delete loading script
Browse files- MyoQuant-SDH-Data.py +0 -130
MyoQuant-SDH-Data.py
DELETED
@@ -1,130 +0,0 @@
|
|
1 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
"""MyoQuant-SDH-Data: The MyoQuant SDH Model Data."""
|
15 |
-
|
16 |
-
|
17 |
-
import csv
|
18 |
-
import json
|
19 |
-
import os
|
20 |
-
|
21 |
-
import datasets
|
22 |
-
|
23 |
-
|
24 |
-
_CITATION = """\
|
25 |
-
@InProceedings{Meyer,
|
26 |
-
title = {MyoQuant SDH Data},
|
27 |
-
author={Corentin Meyer},
|
28 |
-
year={2022}
|
29 |
-
}
|
30 |
-
"""
|
31 |
-
_NAMES = ["control", "sick"]
|
32 |
-
|
33 |
-
_DESCRIPTION = """\
|
34 |
-
This dataset is used to train the SDH model of MyoQuant to detect and quantify anomaly in the mitochondria repartition in SDH stained muscle fiber with myopathy disorders.
|
35 |
-
"""
|
36 |
-
|
37 |
-
_HOMEPAGE = "https://huggingface.co/datasets/corentinm7/MyoQuant-SDH-Data"
|
38 |
-
|
39 |
-
_LICENSE = "agpl-3.0"
|
40 |
-
|
41 |
-
_URLS = {
|
42 |
-
"SDH_16k": "https://huggingface.co/datasets/corentinm7/MyoQuant-SDH-Data/resolve/main/SDH_16k/SDH_16k.zip"
|
43 |
-
}
|
44 |
-
_METADATA_URL = {
|
45 |
-
"SDH_16k_metadata": "https://huggingface.co/datasets/corentinm7/MyoQuant-SDH-Data/resolve/main/SDH_16k/metadata.jsonl"
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
class SDH_16k(datasets.GeneratorBasedBuilder):
|
50 |
-
"""This dataset is used to train the SDH model of MyoQuant to detect and quantify anomaly in the mitochondria repartition in SDH stained muscle fiber with myopathy disorders."""
|
51 |
-
|
52 |
-
VERSION = datasets.Version("1.0.0")
|
53 |
-
|
54 |
-
# This is an example of a dataset with multiple configurations.
|
55 |
-
# If you don't want/need to define several sub-sets in your dataset,
|
56 |
-
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
57 |
-
|
58 |
-
# If you need to make complex sub-parts in the datasets with configurable options
|
59 |
-
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
60 |
-
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
61 |
-
|
62 |
-
# You will be able to load one or the other configurations in the following list with
|
63 |
-
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
64 |
-
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
65 |
-
|
66 |
-
DEFAULT_CONFIG_NAME = "SDH_16k" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
67 |
-
|
68 |
-
def _info(self):
|
69 |
-
return datasets.DatasetInfo(
|
70 |
-
description=_DESCRIPTION,
|
71 |
-
features=datasets.Features(
|
72 |
-
{
|
73 |
-
"image": datasets.Image(),
|
74 |
-
"label": datasets.ClassLabel(num_classes=2, names=_NAMES),
|
75 |
-
}
|
76 |
-
),
|
77 |
-
supervised_keys=("image", "label"),
|
78 |
-
homepage=_HOMEPAGE,
|
79 |
-
citation=_CITATION,
|
80 |
-
license=_LICENSE,
|
81 |
-
)
|
82 |
-
|
83 |
-
def _split_generators(self, dl_manager):
|
84 |
-
archive_path = dl_manager.download(_URLS)
|
85 |
-
split_metadata_path = dl_manager.download(_METADATA_URL)
|
86 |
-
files_metadata = {}
|
87 |
-
with open(split_metadata_path["SDH_16k_metadata"], encoding="utf-8") as f:
|
88 |
-
for lines in f.read().splitlines():
|
89 |
-
file_json_metdata = json.loads(lines)
|
90 |
-
files_metadata.setdefault(file_json_metdata["split"], []).append(
|
91 |
-
file_json_metdata
|
92 |
-
)
|
93 |
-
downloaded_files = dl_manager.download_and_extract(archive_path)
|
94 |
-
return [
|
95 |
-
datasets.SplitGenerator(
|
96 |
-
name=datasets.Split.TRAIN,
|
97 |
-
gen_kwargs={
|
98 |
-
"download_path": downloaded_files["SDH_16k"],
|
99 |
-
"metadata": files_metadata["train"],
|
100 |
-
},
|
101 |
-
),
|
102 |
-
datasets.SplitGenerator(
|
103 |
-
name=datasets.Split.VALIDATION,
|
104 |
-
gen_kwargs={
|
105 |
-
"download_path": downloaded_files["SDH_16k"],
|
106 |
-
"metadata": files_metadata["validation"],
|
107 |
-
},
|
108 |
-
),
|
109 |
-
datasets.SplitGenerator(
|
110 |
-
name=datasets.Split.TEST,
|
111 |
-
gen_kwargs={
|
112 |
-
"download_path": downloaded_files["SDH_16k"],
|
113 |
-
"metadata": files_metadata["test"],
|
114 |
-
},
|
115 |
-
),
|
116 |
-
]
|
117 |
-
|
118 |
-
def _generate_examples(self, download_path, metadata):
|
119 |
-
"""Generate images and labels for splits."""
|
120 |
-
for i, single_metdata in enumerate(metadata):
|
121 |
-
img_path = os.path.join(
|
122 |
-
download_path,
|
123 |
-
single_metdata["split"],
|
124 |
-
single_metdata["label"],
|
125 |
-
single_metdata["file_name"],
|
126 |
-
)
|
127 |
-
yield i, {
|
128 |
-
"image": img_path,
|
129 |
-
"label": single_metdata["label"],
|
130 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|