def save_data_list(inpath, outpath, filenames, filename_bbox): for size in IMG_SIZES: print('Processing images of size %d' % size) cnt = 0 images = np.ndarray(shape=(len(filenames), size, size, 3), dtype=np.uint8) for idx, key in enumerate(filenames): bbox = filename_bbox[key] f_name = '%s/CUB_200_2011/images/%s.jpg' % (inpath, key) img = get_image(f_name, LOAD_SIZE, is_crop=True, bbox=bbox) img = img.astype('uint8') img = img.astype('uint8') if size != LOAD_SIZE: img = scipy.misc.imresize(img, [size, size], 'bicubic') images[idx, :, :, :] = np.array(img) cnt += 1 if cnt % 100 == 0: print('\rLoad %d......' % cnt, end="", flush=True) print('Images processed: %d', len(filenames)) outfile = outpath + str(size) + 'images_cvs.pickle' joblib.dump(images, outfile) print('save to: ', outfile)
def save_data_list(inpath, outpath, filenames): hr_images = [] lr_images = [] lr_size = int(LOAD_SIZE / LR_HR_RETIO) cnt = 0 for key in filenames: f_name = '%s/%s.jpg' % (inpath, key) img = get_image(f_name, LOAD_SIZE, is_crop=False) img = img.astype('uint8') hr_images.append(img) lr_img = scipy.misc.imresize(img, [lr_size, lr_size], 'bicubic') lr_images.append(lr_img) cnt += 1 if cnt % 100 == 0: print('Load %d......' % cnt) # print('images', len(hr_images), hr_images[0].shape, lr_images[0].shape) outfile = outpath + str(LOAD_SIZE) + 'images.pickle' with open(outfile, 'wb') as f_out: pickle.dump(hr_images, f_out) print('save to: ', outfile) # outfile = outpath + str(lr_size) + 'images.pickle' with open(outfile, 'wb') as f_out: pickle.dump(lr_images, f_out) print('save to: ', outfile)