NawinCom commited on
Commit
1ce439e
1 Parent(s): 1eecf75

Upload Eye_diabetic.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. Eye_diabetic.py +84 -0
Eye_diabetic.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import datasets
4
+ from datasets.tasks import ImageClassification
5
+
6
+
7
+ _HOMEPAGE = "https://github.com/AI-Lab-Makerere/ibean/"
8
+
9
+ _CITATION = """\
10
+ @ONLINE {beansdata,
11
+ author="Makerere AI Lab",
12
+ title="Bean disease dataset",
13
+ month="January",
14
+ year="2020",
15
+ url="https://github.com/AI-Lab-Makerere/ibean/"
16
+ }
17
+ """
18
+
19
+ _DESCRIPTION = """\
20
+ Beans is a dataset of images of beans taken in the field using smartphone
21
+ cameras. It consists of 3 classes: 2 disease classes and the healthy class.
22
+ Diseases depicted include Angular Leaf Spot and Bean Rust. Data was annotated
23
+ by experts from the National Crops Resources Research Institute (NaCRRI) in
24
+ Uganda and collected by the Makerere AI research lab.
25
+ """
26
+
27
+ _URLS = {
28
+ "train": "https://huggingface.co/datasets/NawinCom/Eye_diabetic/resolve/main/train_val2/train.zip",
29
+ "validation": "https://huggingface.co/datasets/NawinCom/Eye_diabetic/resolve/main/train_val2/val.zip"
30
+ }
31
+
32
+ _NAMES = ["0", "1", "2", "3", "4"]
33
+
34
+
35
+ class Beans(datasets.GeneratorBasedBuilder):
36
+ """Beans plant leaf images dataset."""
37
+
38
+ def _info(self):
39
+ return datasets.DatasetInfo(
40
+ description=_DESCRIPTION,
41
+ features=datasets.Features(
42
+ {
43
+ "image_file_path": datasets.Value("string"),
44
+ "image": datasets.Image(),
45
+ "labels": datasets.features.ClassLabel(names=_NAMES),
46
+ }
47
+ ),
48
+ supervised_keys=("image", "labels"),
49
+ citation=_CITATION,
50
+ task_templates=[ImageClassification(image_column="image", label_column="labels")],
51
+ )
52
+
53
+ def _split_generators(self, dl_manager):
54
+ data_files = dl_manager.download_and_extract(_URLS)
55
+ return [
56
+ datasets.SplitGenerator(
57
+ name=datasets.Split.TRAIN,
58
+ gen_kwargs={
59
+ "files": dl_manager.iter_files([data_files["train"]]),
60
+ },
61
+ ),
62
+ datasets.SplitGenerator(
63
+ name=datasets.Split.VALIDATION,
64
+ gen_kwargs={
65
+ "files": dl_manager.iter_files([data_files["validation"]]),
66
+ },
67
+ ),
68
+ datasets.SplitGenerator(
69
+ name=datasets.Split.TEST,
70
+ gen_kwargs={
71
+ "files": dl_manager.iter_files([data_files["test"]]),
72
+ },
73
+ ),
74
+ ]
75
+
76
+ def _generate_examples(self, files):
77
+ for i, path in enumerate(files):
78
+ file_name = os.path.basename(path)
79
+ if file_name.endswith(".jpg"):
80
+ yield i, {
81
+ "image_file_path": path,
82
+ "image": path,
83
+ "labels": os.path.basename(os.path.dirname(path)).lower(),
84
+ }