cats-and-dogs /
yourusername's picture
:bug: fix a name
import pickle
from pathlib import Path
from typing import List
import datasets
logger = datasets.logging.get_logger(__name__)
_URL = ""
_URLS = {
"train": _URL + "",
_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 = {},
edition = {Proceedings of 14th ACM Conference on Computer and Communications Security (CCS)},
class CatsAndDogs(datasets.GeneratorBasedBuilder):
def _info(self):
return datasets.DatasetInfo(
"img_bytes": datasets.Value("binary"),
"labels": datasets.features.ClassLabel(names=["cat", "dog"]),
supervised_keys=("img_bytes", "labels"),
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
downloaded_files = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form.""""generating examples from = %s", filepath)
with Path(filepath).open("rb") as f:
examples = pickle.load(f)
for i, ex in enumerate(examples):
yield str(i), ex