Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Define the directory with real image data
data_dir = './data/' # Data
resized_data_dir = "./resized_data" # folder for saving resized data
# Resize images into 128x128
preprocess = True # set to False if no resizing
if preprocess == True:
# Create resized folder if not exist
if not os.path.exists(resized_data_dir):
for each in os.listdir(data_dir):
# Read the image
image = cv2.imread(os.path.join(data_dir, each))
image = cv2.resize(image, (128, 128))
cv2.imwrite(os.path.join(resized_data_dir, each), image)
# Explore the images
show_images = 5
data_images = helper.get_batch(glob(os.path.join(resized_data_dir, '*.jpg'))[:show_images], 64, 64, 'RGB')
plt.imshow(helper.images_square_grid(data_images, 'RGB'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment