Commit
·
86dcc30
1
Parent(s):
3870681
Update test_dataset.py
Browse files- test_dataset.py +20 -27
test_dataset.py
CHANGED
@@ -12,45 +12,44 @@
|
|
12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
# See the License for the specific language governing permissions and
|
14 |
# limitations under the License.
|
15 |
-
"""
|
16 |
|
17 |
import os
|
18 |
|
19 |
import datasets
|
|
|
20 |
from datasets.tasks import ImageClassification
|
21 |
|
22 |
|
23 |
-
_HOMEPAGE = "https://
|
24 |
|
25 |
_CITATION = """\
|
26 |
-
@ONLINE {
|
27 |
-
author="
|
28 |
-
title="Bean disease dataset",
|
29 |
-
month="January",
|
30 |
-
year="2020",
|
31 |
-
url="https://github.com/AI-Lab-Makerere/ibean/"
|
32 |
}
|
33 |
"""
|
34 |
|
35 |
_DESCRIPTION = """\
|
36 |
-
|
37 |
-
cameras. It consists of 3 classes: 2 disease classes and the healthy class.
|
38 |
-
Diseases depicted include Angular Leaf Spot and Bean Rust. Data was annotated
|
39 |
-
by experts from the National Crops Resources Research Institute (NaCRRI) in
|
40 |
-
Uganda and collected by the Makerere AI research lab.
|
41 |
"""
|
42 |
|
43 |
_URLS = {
|
44 |
-
"train": "https://
|
45 |
-
"
|
46 |
-
"test": "https://huggingface.co/datasets/beans/resolve/main/data/test.zip",
|
47 |
}
|
48 |
|
49 |
-
_NAMES = ["
|
50 |
|
51 |
|
52 |
-
class
|
53 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
def _info(self):
|
56 |
return datasets.DatasetInfo(
|
@@ -77,12 +76,6 @@ class Beans(datasets.GeneratorBasedBuilder):
|
|
77 |
"files": dl_manager.iter_files([data_files["train"]]),
|
78 |
},
|
79 |
),
|
80 |
-
datasets.SplitGenerator(
|
81 |
-
name=datasets.Split.VALIDATION,
|
82 |
-
gen_kwargs={
|
83 |
-
"files": dl_manager.iter_files([data_files["validation"]]),
|
84 |
-
},
|
85 |
-
),
|
86 |
datasets.SplitGenerator(
|
87 |
name=datasets.Split.TEST,
|
88 |
gen_kwargs={
|
@@ -94,9 +87,9 @@ class Beans(datasets.GeneratorBasedBuilder):
|
|
94 |
def _generate_examples(self, files):
|
95 |
for i, path in enumerate(files):
|
96 |
file_name = os.path.basename(path)
|
97 |
-
if file_name.endswith(".
|
98 |
yield i, {
|
99 |
"image_file_path": path,
|
100 |
"image": path,
|
101 |
"labels": os.path.basename(os.path.dirname(path)).lower(),
|
102 |
-
}
|
|
|
12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
# See the License for the specific language governing permissions and
|
14 |
# limitations under the License.
|
15 |
+
"""chensu test animal classification dataset with images of cats and dogs"""
|
16 |
|
17 |
import os
|
18 |
|
19 |
import datasets
|
20 |
+
from datasets import load_dataset
|
21 |
from datasets.tasks import ImageClassification
|
22 |
|
23 |
|
24 |
+
_HOMEPAGE = "https://oss.console.aliyun.com/bucket/oss-cn-beijing/340788/object"
|
25 |
|
26 |
_CITATION = """\
|
27 |
+
@ONLINE {
|
28 |
+
author="chensu"
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
"""
|
31 |
|
32 |
_DESCRIPTION = """\
|
33 |
+
This is a test dataset used to demonstrate the process of creating a hugging face dataset
|
|
|
|
|
|
|
|
|
34 |
"""
|
35 |
|
36 |
_URLS = {
|
37 |
+
"train": "https://340788.oss-cn-beijing.aliyuncs.com/train.zip",
|
38 |
+
"test": "https://340788.oss-cn-beijing.aliyuncs.com/test.zip",
|
|
|
39 |
}
|
40 |
|
41 |
+
_NAMES = ["cat", "dog"]
|
42 |
|
43 |
|
44 |
+
class TestDataset(datasets.GeneratorBasedBuilder):
|
45 |
+
"""Test classification dataset."""
|
46 |
+
VERSION = datasets.Version("1.1.0")
|
47 |
+
BUILDER_CONFIGS = [
|
48 |
+
datasets.BuilderConfig(name="cat", version=VERSION,
|
49 |
+
description="This part of my cat dataset"),
|
50 |
+
datasets.BuilderConfig(name="dog", version=VERSION,
|
51 |
+
description="This part of my dog dataset"),
|
52 |
+
]
|
53 |
|
54 |
def _info(self):
|
55 |
return datasets.DatasetInfo(
|
|
|
76 |
"files": dl_manager.iter_files([data_files["train"]]),
|
77 |
},
|
78 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
datasets.SplitGenerator(
|
80 |
name=datasets.Split.TEST,
|
81 |
gen_kwargs={
|
|
|
87 |
def _generate_examples(self, files):
|
88 |
for i, path in enumerate(files):
|
89 |
file_name = os.path.basename(path)
|
90 |
+
if file_name.endswith(".jpeg"):
|
91 |
yield i, {
|
92 |
"image_file_path": path,
|
93 |
"image": path,
|
94 |
"labels": os.path.basename(os.path.dirname(path)).lower(),
|
95 |
+
}
|