Skip to content

Instantly share code, notes, and snippets.

@merishnaSuwal
Created October 17, 2020 11:01
Show Gist options
  • Save merishnaSuwal/883794cc167c2e3082252c0ecd3455a7 to your computer and use it in GitHub Desktop.
Save merishnaSuwal/883794cc167c2e3082252c0ecd3455a7 to your computer and use it in GitHub Desktop.
# 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):
os.mkdir(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