Delete cats_vs_dogs_sample.py
Browse files- cats_vs_dogs_sample.py +0 -71
cats_vs_dogs_sample.py
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
-
#
|
4 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
# you may not use this file except in compliance with the License.
|
6 |
-
# You may obtain a copy of the License at
|
7 |
-
#
|
8 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
-
#
|
10 |
-
# Unless required by applicable law or agreed to in writing, software
|
11 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
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 |
-
"""Sample of the Microsoft Cats vs. Dogs dataset"""
|
16 |
-
|
17 |
-
from pathlib import Path
|
18 |
-
from typing import List
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
|
22 |
-
|
23 |
-
logger = datasets.logging.get_logger(__name__)
|
24 |
-
|
25 |
-
_URL = "https://huggingface.co/datasets/hf-internal-testing/cats_vs_dogs_sample/resolve/main/cats_and_dogs_sample.zip"
|
26 |
-
|
27 |
-
_HOMEPAGE = "https://www.microsoft.com/en-us/download/details.aspx?id=54765"
|
28 |
-
|
29 |
-
_DESCRIPTION = "A 50 image sample of microsoft's cats vs. dogs dataset for unit testing."
|
30 |
-
|
31 |
-
_CITATION = """\\n@Inproceedings (Conference){asirra-a-captcha-that-exploits-interest-aligned-manual-image-categorization,
|
32 |
-
author = {Elson, Jeremy and Douceur, John (JD) and Howell, Jon and Saul, Jared},
|
33 |
-
title = {Asirra: A CAPTCHA that Exploits Interest-Aligned Manual Image Categorization},
|
34 |
-
booktitle = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)},
|
35 |
-
year = {2007},
|
36 |
-
month = {October},
|
37 |
-
publisher = {Association for Computing Machinery, Inc.},
|
38 |
-
url = {https://www.microsoft.com/en-us/research/publication/asirra-a-captcha-that-exploits-interest-aligned-manual-image-categorization/},
|
39 |
-
edition = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)},
|
40 |
-
}
|
41 |
-
"""
|
42 |
-
|
43 |
-
|
44 |
-
class CatsVsDogs(datasets.GeneratorBasedBuilder):
|
45 |
-
def _info(self):
|
46 |
-
return datasets.DatasetInfo(
|
47 |
-
description=_DESCRIPTION,
|
48 |
-
features=datasets.Features(
|
49 |
-
{
|
50 |
-
"image": datasets.Image(),
|
51 |
-
"labels": datasets.features.ClassLabel(names=["cat", "dog"]),
|
52 |
-
}
|
53 |
-
),
|
54 |
-
supervised_keys=("image", "labels"),
|
55 |
-
homepage=_HOMEPAGE,
|
56 |
-
citation=_CITATION,
|
57 |
-
)
|
58 |
-
|
59 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
60 |
-
images_path = Path(dl_manager.download_and_extract(_URL)) / "PetImagesSample"
|
61 |
-
return [
|
62 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"images_path": images_path}),
|
63 |
-
]
|
64 |
-
|
65 |
-
def _generate_examples(self, images_path):
|
66 |
-
logger.info("generating examples from = %s", images_path)
|
67 |
-
for i, filepath in enumerate(sorted(images_path.glob("**/*.jpg"))):
|
68 |
-
yield str(i), {
|
69 |
-
"image": str(filepath),
|
70 |
-
"labels": filepath.parent.name.lower(),
|
71 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|