Commit
•
c4a1496
1
Parent(s):
d1867ea
refactor
Browse files- README.md +3 -3
- amazonian_fish_classifier_data.py +14 -17
README.md
CHANGED
@@ -42,8 +42,8 @@ dataset_info:
|
|
42 |
'32': Tyttocharax
|
43 |
splits:
|
44 |
- name: train
|
45 |
-
num_bytes:
|
46 |
num_examples: 3068
|
47 |
-
download_size:
|
48 |
-
dataset_size:
|
49 |
---
|
|
|
42 |
'32': Tyttocharax
|
43 |
splits:
|
44 |
- name: train
|
45 |
+
num_bytes: 1068363405
|
46 |
num_examples: 3068
|
47 |
+
download_size: 330399200
|
48 |
+
dataset_size: 1068363405
|
49 |
---
|
amazonian_fish_classifier_data.py
CHANGED
@@ -14,9 +14,8 @@
|
|
14 |
"""TODO."""
|
15 |
|
16 |
|
17 |
-
import os
|
18 |
-
import pandas as pd
|
19 |
import datasets
|
|
|
20 |
|
21 |
_CITATION = """TODO"""
|
22 |
|
@@ -32,7 +31,6 @@ _LICENSE = "CC BY 4.0"
|
|
32 |
|
33 |
_URLS = {
|
34 |
"images": "https://smithsonian.figshare.com/ndownloader/files/31975544",
|
35 |
-
"labels": "https://smithsonian.figshare.com/ndownloader/files/31975646",
|
36 |
}
|
37 |
|
38 |
|
@@ -94,23 +92,22 @@ class AmazonianFish(datasets.GeneratorBasedBuilder):
|
|
94 |
)
|
95 |
|
96 |
def _split_generators(self, dl_manager):
|
97 |
-
images = dl_manager.
|
98 |
-
labels = dl_manager.download(_URLS["labels"])
|
99 |
-
df = pd.read_csv(labels)
|
100 |
-
labels = df.to_dict(orient="records")
|
101 |
return [
|
102 |
datasets.SplitGenerator(
|
103 |
name=datasets.Split.TRAIN,
|
104 |
-
gen_kwargs={
|
105 |
-
"images": os.path.join(images, "training_images"),
|
106 |
-
"labels": labels,
|
107 |
-
},
|
108 |
),
|
109 |
]
|
110 |
|
111 |
-
def _generate_examples(self,
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
14 |
"""TODO."""
|
15 |
|
16 |
|
|
|
|
|
17 |
import datasets
|
18 |
+
from pathlib import Path
|
19 |
|
20 |
_CITATION = """TODO"""
|
21 |
|
|
|
31 |
|
32 |
_URLS = {
|
33 |
"images": "https://smithsonian.figshare.com/ndownloader/files/31975544",
|
|
|
34 |
}
|
35 |
|
36 |
|
|
|
92 |
)
|
93 |
|
94 |
def _split_generators(self, dl_manager):
|
95 |
+
images = dl_manager.download(_URLS["images"])
|
|
|
|
|
|
|
96 |
return [
|
97 |
datasets.SplitGenerator(
|
98 |
name=datasets.Split.TRAIN,
|
99 |
+
gen_kwargs={"archive": dl_manager.iter_archive(images)},
|
|
|
|
|
|
|
100 |
),
|
101 |
]
|
102 |
|
103 |
+
def _generate_examples(self, archive):
|
104 |
+
id_ = 0
|
105 |
+
for fname, fobject in archive:
|
106 |
+
if fname.startswith("._"):
|
107 |
+
continue
|
108 |
+
if Path(fname).suffix != ".jpg":
|
109 |
+
continue
|
110 |
+
image = fobject.read()
|
111 |
+
label = str(Path(fname).parts[-2])
|
112 |
+
id_ += 1
|
113 |
+
yield id_, {"image": image, "label": label}
|