Created
October 17, 2020 11:01
-
-
Save merishnaSuwal/883794cc167c2e3082252c0ecd3455a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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