项目作者: knjcode

项目描述 :
Convert CIFAR-10 and CIFAR-100 datasets into PNG images
高级语言: Python
项目地址: git://github.com/knjcode/cifar2png.git
创建时间: 2018-06-14T10:06:49Z
项目社区:https://github.com/knjcode/cifar2png

开源协议:

下载


cifar2png

Convert CIFAR-10 or CIFAR-100 dataset into PNG images.

Install

  1. $ pip install cifar2png

Usage

$ cifar2png <dataset> <output_dir> [--name-with-batch-index]

  • dataset: Specify cifar10 or cifar100 or cifar100superclass
  • output_dir: Path to save PNG converted dataset (The directory will be created automatically).
  • --name-with-batch-index: (optional) Name image files based on batch name and index of cifar10/cifar100 dataset.

Automatically download cifar-10-python.tar.gz or cifar-100-python.tar.gz to the current directory from CIFAR-10 and CIFAR-100 datasets when you run this tool.

Examples

CIFAR-10

$ cifar2png cifar10 path/to/cifar10png

CIFAR-10 with naming option

$ cifar2png cifar10 path/to/cifar10png --name-with-batch-index

CIFAR-100

$ cifar2png cifar100 path/to/cifar100png

CIFAR-100 with superclass

$ cifar2png cifar100superclass path/to/cifar100png

Structure of output directory

CIFAR-10 and CIFAR-100

PNG images of CIFAR-10 are saved in 10 subdirectories of each label under the test and train directories as below.
(CIFAR-100 are saved in the same way with 100 subdirectories)

  1. $ tree -d path/to/cifar10png
  2. path/to/cifar10png
  3. ├── test
  4. ├── airplane
  5. ├── automobile
  6. ├── bird
  7. ├── cat
  8. ├── deer
  9. ├── dog
  10. ├── frog
  11. ├── horse
  12. ├── ship
  13. └── truck
  14. └── train
  15. ├── airplane
  16. ├── automobile
  17. ├── bird
  18. ├── cat
  19. ├── deer
  20. ├── dog
  21. ├── frog
  22. ├── horse
  23. ├── ship
  24. └── truck
  1. $ tree path/to/cifar10png/test/airplane
  2. path/to/cifar10png/test/airplane
  3. ├── 0001.png
  4. ├── 0002.png
  5. ├── 0003.png
  6. (..snip..)
  7. ├── 0998.png
  8. ├── 0999.png
  9. └── 1000.png

When dataset created using the --name-with-batch-index option.

  1. $ tree path/to/cifar10png/train/airplane
  2. path/to/cifar10png/train/airplane
  3. ├── data_batch_1_index_0029.png
  4. ├── data_batch_1_index_0030.png
  5. ├── data_batch_1_index_0035.png
  6. (..snip..)
  7. ├── data_batch_5_index_9941.png
  8. ├── data_batch_5_index_9992.png
  9. └── data_batch_5_index_9994.png

CIFAR-100 with superclass

PNG images of CIFAR-100 with superclass are saved in each label directories under the superclass subdirectories under the test and train directories as below.

  1. $ tree -d path/to/cifar100png
  2. path/to/cifar100png
  3. ├── test
  4. ├── aquatic_mammals
  5. ├── beaver
  6. ├── dolphin
  7. ├── otter
  8. ├── seal
  9. └── whale
  10. ├── fish
  11. ├── aquarium_fish
  12. ├── flatfish
  13. ├── ray
  14. ├── shark
  15. └── trout
  16. ├── flowers
  17. ├── orchid
  18. ├── poppy
  19. ├── rose
  20. ├── sunflower
  21. └── tulip
  22. (..snip..)
  23. ├── trees
  24. ├── maple_tree
  25. ├── oak_tree
  26. ├── palm_tree
  27. ├── pine_tree
  28. └── willow_tree
  29. ├── vehicles_1
  30. ├── bicycle
  31. ├── bus
  32. ├── motorcycle
  33. ├── pickup_truck
  34. └── train
  35. └── vehicles_2
  36. ├── lawn_mower
  37. ├── rocket
  38. ├── streetcar
  39. ├── tank
  40. └── tractor