{"id":21229320,"url":"https://github.com/ndrplz/cifar-10","last_synced_at":"2025-07-10T02:38:32.357Z","repository":{"id":151167999,"uuid":"154894166","full_name":"ndrplz/CIFAR-10","owner":"ndrplz","description":"Python plug-and-play wrapper to CIFAR-10 dataset. ","archived":false,"fork":false,"pushed_at":"2018-10-28T19:31:34.000Z","size":3627,"stargazers_count":10,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T14:51:16.615Z","etag":null,"topics":["cifar","cifar-10","cifar10","computer-vision","convolutional-neural-networks","dataset","deep-learning","machine-learning","python36","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ndrplz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-26T21:02:58.000Z","updated_at":"2024-12-19T14:36:09.000Z","dependencies_parsed_at":"2023-05-02T16:00:37.179Z","dependency_job_id":null,"html_url":"https://github.com/ndrplz/CIFAR-10","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ndrplz/CIFAR-10","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrplz%2FCIFAR-10","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrplz%2FCIFAR-10/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrplz%2FCIFAR-10/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrplz%2FCIFAR-10/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ndrplz","download_url":"https://codeload.github.com/ndrplz/CIFAR-10/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrplz%2FCIFAR-10/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264519719,"owners_count":23621858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cifar","cifar-10","cifar10","computer-vision","convolutional-neural-networks","dataset","deep-learning","machine-learning","python36","wrapper"],"created_at":"2024-11-20T23:26:41.319Z","updated_at":"2025-07-10T02:38:32.345Z","avatar_url":"https://github.com/ndrplz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CIFAR-10\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"docs/cifar_banner.png\" width=\"900\"\u003e\u003c/p\u003e\n\n## Usage\nAs simple as:\n```python\nfrom cifar import CIFAR10\n\n# Instantiate the dataset. If the dataset is not found in `dataset_root`,\n#  the first time it is automatically downloaded and extracted there.\ndataset = CIFAR10(dataset_root='./cifar10')\n```\nand you're done.\n\n## Why this wrapper?\n\nThe [CIFAR-10 dataset](https://www.cs.toronto.edu/~kriz/cifar.html) consists of 60000 32x32 colour images in 10 classes, with 6000 images per class. It's kind of famous in the computer vision community and it is often used as (toy) benchmark. It's a nice dataset to play with. It's a bit like [MNIST](http://yann.lecun.com/exdb/mnist/), but there are cats and dogs and frogs! And there are colors too!\n\nDespite its fame, I did not find any easy plug-and-play wrapper around it. Of course, there are wrappers to CIFAR-10 in most deep learning frameworks ([TensorFlow](https://github.com/tensorflow/models/tree/master/tutorials/image/cifar10), [PyTorch](https://pytorch.org/docs/stable/torchvision/datasets.html)) but you know I usually don't want to get into a whole deep learning framework just to play with 32x32 cat images. So here's why. And yes, I also wanted to have some fun learning [`pathlib`](https://docs.python.org/3/library/pathlib.html).\n\n#### [video] How the dataset looks like, by the way?\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.youtube.com/watch?v=pRiRrGk0_DY\"\u003e\u003cimg src=\"http://img.youtube.com/vi/pRiRrGk0_DY/0.jpg\" alt=\"video_results\" width=\"50%\" height=\"40%\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\n* *No installation required.* You can just clone / download / copypaste this repository.\n* I'm wondering if adding it to PyPI might be useful...\n\n## Requirements\n* Python \u003e= 3.6\n\n## Hello World\n```python\nfrom cifar import CIFAR10\n\n# Instantiate the dataset. If the dataset is not found in `dataset_root`,\n#  the first time it is automatically downloaded and extracted there.\ndataset = CIFAR10(dataset_root='./cifar10')\n\n# That's it. Now all examples are in `dataset.samples` dictionary. There\n#  are 50000 train examples and 10000 test examples.\nprint(dataset.samples['train'].shape)           # (50000,)\nprint(dataset.samples['test'].shape)            # (10000,)\n\n# Each example is constituted by a 32x32 RGB image and its\n#  corresponding label, both numeric and human readable.\nprint(dataset.samples['train'][0].image.shape)  # (32, 32, 3)\nprint(dataset.samples['train'][0].label)        # 6\nprint(dataset.samples['train'][0].label_hr)     # frog\nprint(dataset.samples['train'][0].filename)     # leptodactylus_pentadactylus_s_000004.png\n\n# You can also directly print the example\nprint(dataset.samples['train'][0])              # [frog] - leptodactylus_pentadactylus_s_000004.png\n\n# You can convert the CIFARSamples to ndarray. Images are possibly flattened\n#  and/or normalized to be centered on zero (i.e. in range [-0.5, 0.5])\nx_train, y_train = CIFAR10.to_ndarray(dataset.samples['train'], normalize=True, flatten=True)\nx_test, y_test = CIFAR10.to_ndarray(dataset.samples['test'], normalize=True, flatten=True)\n\nprint(x_train.shape, y_train.shape)             # (50000, 3072)  (50000,)\nprint(x_test.shape, y_test.shape)               # (10000, 3072)  (10000,)\n```\n\n## Issues\nPlease feel free do open an issue if something doesn't look quite right!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndrplz%2Fcifar-10","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndrplz%2Fcifar-10","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndrplz%2Fcifar-10/lists"}