-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add cats_vs_dogs dataset #2807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add cats_vs_dogs dataset #2807
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
85df23e
:sparkles: add cats_vs_dogs dataset
nateraw 28468c5
:lipstick: fix flake8 style
nateraw 249ac95
:memo: update cats_vs_dogs dataset card
nateraw 8dc8f49
:bento: update cats_vs_dogs dummy data
nateraw a56a4f7
:art: add a few final details
nateraw 88af405
:art: delete file after closing it
nateraw 3fcd7fb
Apply suggestions from code review
nateraw 5775861
Apply suggestions from code review
nateraw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| --- | ||
| annotations_creators: | ||
| - crowdsourced | ||
| language_creators: | ||
| - crowdsourced | ||
| languages: | ||
| - en | ||
| licenses: | ||
| - unknown | ||
| multilinguality: | ||
| - monolingual | ||
| pretty_name: Cats-vs-Dogs | ||
| size_categories: | ||
| - 10K<n<100K | ||
| source_datasets: | ||
| - original | ||
| task_categories: | ||
| - other | ||
| task_ids: | ||
| - other-other-image-classification | ||
| --- | ||
|
|
||
| # Dataset Card for Cats Vs. Dogs | ||
|
|
||
| ## Table of Contents | ||
| - [Table of Contents](#table-of-contents) | ||
| - [Dataset Description](#dataset-description) | ||
| - [Dataset Summary](#dataset-summary) | ||
| - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards) | ||
| - [Languages](#languages) | ||
| - [Dataset Structure](#dataset-structure) | ||
| - [Data Instances](#data-instances) | ||
| - [Data Fields](#data-fields) | ||
| - [Data Splits](#data-splits) | ||
| - [Dataset Creation](#dataset-creation) | ||
| - [Curation Rationale](#curation-rationale) | ||
| - [Source Data](#source-data) | ||
| - [Annotations](#annotations) | ||
| - [Personal and Sensitive Information](#personal-and-sensitive-information) | ||
| - [Considerations for Using the Data](#considerations-for-using-the-data) | ||
| - [Social Impact of Dataset](#social-impact-of-dataset) | ||
| - [Discussion of Biases](#discussion-of-biases) | ||
| - [Other Known Limitations](#other-known-limitations) | ||
| - [Additional Information](#additional-information) | ||
| - [Dataset Curators](#dataset-curators) | ||
| - [Licensing Information](#licensing-information) | ||
| - [Citation Information](#citation-information) | ||
| - [Contributions](#contributions) | ||
|
|
||
| ## Dataset Description | ||
|
|
||
| - **Homepage:** [Cats vs Dogs Dataset](https://www.microsoft.com/en-us/download/details.aspx?id=54765) | ||
| - **Repository:** N/A | ||
| - **Paper:** [Paper](https://www.microsoft.com/en-us/research/wp-content/uploads/2007/10/CCS2007.pdf) | ||
| - **Leaderboard:** N/A | ||
| - **Point of Contact:** N/A | ||
|
|
||
| ### Dataset Summary | ||
|
|
||
| A large set of images of cats and dogs. There are 1738 corrupted images that are dropped. | ||
|
|
||
| ### Supported Tasks and Leaderboards | ||
|
|
||
| - image-classification | ||
|
|
||
| ### Languages | ||
|
|
||
| English | ||
|
|
||
| ## Dataset Structure | ||
|
|
||
| ### Data Instances | ||
|
|
||
| A sample from the training set is provided below: | ||
|
|
||
| ``` | ||
| { | ||
| 'image': '/root/.cache/huggingface/datasets/downloads/extracted/6e1e8c9052e9f3f7ecbcb4b90860668f81c1d36d86cc9606d49066f8da8bfb4f/PetImages/Cat/1.jpg', | ||
| 'label': 0 | ||
| } | ||
| ``` | ||
|
|
||
| ### Data Fields | ||
|
|
||
| The data instances have the following fields: | ||
|
|
||
| - `image_file_path`: a `string` filepath to an image. | ||
| - `labels`: an `int` classification label. | ||
|
|
||
| Class Label Mappings: | ||
|
|
||
| ``` | ||
| { | ||
| "cat": 0, | ||
| "dog": 1, | ||
| } | ||
| ``` | ||
|
|
||
| ### Data Splits | ||
|
|
||
|
|
||
| | | train | | ||
| |---------------|------:| | ||
| | # of examples | 23410 | | ||
|
|
||
| ## Dataset Creation | ||
|
|
||
| ### Curation Rationale | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ### Source Data | ||
|
|
||
| #### Initial Data Collection and Normalization | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| #### Who are the source language producers? | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ### Annotations | ||
|
|
||
| #### Annotation process | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| #### Who are the annotators? | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ### Personal and Sensitive Information | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ## Considerations for Using the Data | ||
|
|
||
| ### Social Impact of Dataset | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ### Discussion of Biases | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ### Other Known Limitations | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ## Additional Information | ||
|
|
||
| ### Dataset Curators | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ### Licensing Information | ||
|
|
||
| [More Information Needed] | ||
|
|
||
| ### Citation Information | ||
|
|
||
| ``` | ||
| @Inproceedings (Conference){asirra-a-captcha-that-exploits-interest-aligned-manual-image-categorization, | ||
| author = {Elson, Jeremy and Douceur, John (JD) and Howell, Jon and Saul, Jared}, | ||
| title = {Asirra: A CAPTCHA that Exploits Interest-Aligned Manual Image Categorization}, | ||
| booktitle = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)}, | ||
| year = {2007}, | ||
| month = {October}, | ||
| publisher = {Association for Computing Machinery, Inc.}, | ||
| url = {https://www.microsoft.com/en-us/research/publication/asirra-a-captcha-that-exploits-interest-aligned-manual-image-categorization/}, | ||
| edition = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)}, | ||
| } | ||
| ``` | ||
|
|
||
| ### Contributions | ||
|
|
||
| Thanks to [@nateraw](https://github.com/nateraw) for adding this dataset. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # coding=utf-8 | ||
| # Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """The Microsoft Cats vs. Dogs dataset""" | ||
|
|
||
| from pathlib import Path | ||
| from typing import List | ||
|
|
||
| import datasets | ||
| from datasets.tasks import ImageClassification | ||
|
|
||
|
|
||
| logger = datasets.logging.get_logger(__name__) | ||
|
|
||
| _URL = "https://download.microsoft.com/download/3/E/1/3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_3367a.zip" | ||
|
|
||
| _HOMEPAGE = "https://www.microsoft.com/en-us/download/details.aspx?id=54765" | ||
|
|
||
| _DESCRIPTION = "A large set of images of cats and dogs. There are 1738 corrupted images that are dropped." | ||
|
|
||
| _CITATION = """\ | ||
| @Inproceedings (Conference){asirra-a-captcha-that-exploits-interest-aligned-manual-image-categorization, | ||
| author = {Elson, Jeremy and Douceur, John (JD) and Howell, Jon and Saul, Jared}, | ||
| title = {Asirra: A CAPTCHA that Exploits Interest-Aligned Manual Image Categorization}, | ||
| booktitle = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)}, | ||
| year = {2007}, | ||
| month = {October}, | ||
| publisher = {Association for Computing Machinery, Inc.}, | ||
| url = {https://www.microsoft.com/en-us/research/publication/asirra-a-captcha-that-exploits-interest-aligned-manual-image-categorization/}, | ||
| edition = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)}, | ||
| } | ||
| """ | ||
|
|
||
|
|
||
| class CatsVsDogs(datasets.GeneratorBasedBuilder): | ||
| def _info(self): | ||
| return datasets.DatasetInfo( | ||
| description=_DESCRIPTION, | ||
| features=datasets.Features( | ||
| { | ||
| "image_file_path": datasets.Value("string"), | ||
| "labels": datasets.features.ClassLabel(names=["cat", "dog"]), | ||
| } | ||
| ), | ||
| supervised_keys=("image_file_path", "labels"), | ||
| task_templates=[ | ||
| ImageClassification( | ||
| image_file_path_column="image_file_path", label_column="labels", labels=["Cat", "Dog"] | ||
nateraw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| ], | ||
| homepage=_HOMEPAGE, | ||
| citation=_CITATION, | ||
| ) | ||
|
|
||
| def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: | ||
| images_path = Path(dl_manager.download_and_extract(_URL)) / "PetImages" | ||
| return [ | ||
| datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"images_path": images_path}), | ||
| ] | ||
|
|
||
| def _generate_examples(self, images_path): | ||
| logger.info("generating examples from = %s", images_path) | ||
| for i, filepath in enumerate(images_path.glob("**/*.jpg")): | ||
| with filepath.open("rb") as f: | ||
| if b"JFIF" in f.peek(10): | ||
| yield str(i), { | ||
| "image_file_path": str(filepath), | ||
| "labels": filepath.parent.name.lower(), | ||
| } | ||
| continue | ||
| filepath.unlink() | ||
nateraw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"default": {"description": "A large set of images of cats and dogs. There are 1738 corrupted images that are dropped.", "citation": "@Inproceedings (Conference){asirra-a-captcha-that-exploits-interest-aligned-manual-image-categorization,\n author = {Elson, Jeremy and Douceur, John (JD) and Howell, Jon and Saul, Jared},\n title = {Asirra: A CAPTCHA that Exploits Interest-Aligned Manual Image Categorization},\n booktitle = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)},\n year = {2007},\n month = {October},\n publisher = {Association for Computing Machinery, Inc.},\n url = {https://www.microsoft.com/en-us/research/publication/asirra-a-captcha-that-exploits-interest-aligned-manual-image-categorization/},\n edition = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)},\n}\n", "homepage": "https://www.microsoft.com/en-us/download/details.aspx?id=54765", "license": "", "features": {"image_file_path": {"dtype": "string", "id": null, "_type": "Value"}, "labels": {"num_classes": 2, "names": ["cat", "dog"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": {"input": "image_file_path", "output": "labels"}, "task_templates": [{"task": "image-classification", "image_file_path_column": "image_file_path", "label_column": "labels", "labels": ["Cat", "Dog"]}], "builder_name": "cats_vs_dogs", "config_name": "default", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3701417, "num_examples": 23410, "dataset_name": "cats_vs_dogs"}}, "download_checksums": {"https://download.microsoft.com/download/3/E/1/3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_3367a.zip": {"num_bytes": 824894548, "checksum": "f9553e426bd725354ed3a27e3c6920caadb55c835d1ebd880d2e56d3f1fbb22b"}}, "download_size": 824894548, "post_processing_size": null, "dataset_size": 3701417, "size_in_bytes": 828595965}} | ||
nateraw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.