CIFAR-100 をpngで出力
先日読み込んで見たけど今度はpng形式で出力してみた。 png出力先のパスに'train'と'test'ディレクトリを作成してそれぞれの画像を出力する。 import os , pickle from PIL import Image class Cifar100: topdirname = 'cifar-100-python' width , height = 32 , 32 def __init__ ( self , extractedpath): dirpath = os.path.join(extractedpath , Cifar100.topdirname) with open (os.path.join(dirpath , 'meta' ) , 'rb' ) as fp: self .meta = pickle.load(fp) with open (os.path.join(dirpath , 'train' ) , 'rb' ) as fp: self .train = pickle.load(fp , encoding = 'latin-1' ) with open (os.path.join(dirpath , 'test' ) , 'rb' ) as fp: self .test = pickle.load(fp , encoding = 'latin-1' ) def _out_images( self , path , data , filename): for (d , f) in zip (data , filename): im = Image.new( 'RGB' , (Cifar100.width , Cifar100.height) , ( 0xff , 0xff , 0xff )) putd