Datasets:
Tasks:
Image Classification
Modalities:
Image
Formats:
parquet
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
10K - 100K
License:
Update files from the datasets library (from 1.18.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.18.0
- cats_vs_dogs.py +16 -15
cats_vs_dogs.py
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
# limitations under the License.
|
15 |
"""The Microsoft Cats vs. Dogs dataset"""
|
16 |
|
17 |
-
|
18 |
from typing import List
|
19 |
|
20 |
import datasets
|
@@ -55,25 +55,26 @@ class CatsVsDogs(datasets.GeneratorBasedBuilder):
|
|
55 |
}
|
56 |
),
|
57 |
supervised_keys=("image", "labels"),
|
58 |
-
task_templates=[ImageClassification(image_column="image", label_column="labels"
|
59 |
homepage=_HOMEPAGE,
|
60 |
citation=_CITATION,
|
61 |
)
|
62 |
|
63 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
64 |
-
images_path =
|
65 |
return [
|
66 |
-
datasets.SplitGenerator(
|
|
|
|
|
67 |
]
|
68 |
|
69 |
-
def _generate_examples(self,
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
continue
|
|
|
14 |
# limitations under the License.
|
15 |
"""The Microsoft Cats vs. Dogs dataset"""
|
16 |
|
17 |
+
import os
|
18 |
from typing import List
|
19 |
|
20 |
import datasets
|
|
|
55 |
}
|
56 |
),
|
57 |
supervised_keys=("image", "labels"),
|
58 |
+
task_templates=[ImageClassification(image_column="image", label_column="labels")],
|
59 |
homepage=_HOMEPAGE,
|
60 |
citation=_CITATION,
|
61 |
)
|
62 |
|
63 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
64 |
+
images_path = os.path.join(dl_manager.download_and_extract(_URL), "PetImages")
|
65 |
return [
|
66 |
+
datasets.SplitGenerator(
|
67 |
+
name=datasets.Split.TRAIN, gen_kwargs={"files": dl_manager.iter_files([images_path])}
|
68 |
+
),
|
69 |
]
|
70 |
|
71 |
+
def _generate_examples(self, files):
|
72 |
+
for i, file in enumerate(files):
|
73 |
+
if os.path.basename(file).endswith(".jpg"):
|
74 |
+
with open(file, "rb") as f:
|
75 |
+
if b"JFIF" in f.peek(10):
|
76 |
+
yield str(i), {
|
77 |
+
"image_file_path": file,
|
78 |
+
"image": file,
|
79 |
+
"labels": os.path.basename(os.path.dirname(file)).lower(),
|
80 |
+
}
|
|