Created
March 7, 2017 12:17
-
-
Save jokla/13673a47c17502eae74584f15d551fdc 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
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img | |
import matplotlib.pyplot as plt | |
# Visualizations will be shown in the notebook. | |
%matplotlib inline | |
import random | |
import numpy as np | |
datagen = ImageDataGenerator( | |
rotation_range=40, | |
width_shift_range=0.2, | |
height_shift_range=0.2, | |
shear_range=0.2, | |
zoom_range=0.2, | |
horizontal_flip=False, | |
dim_ordering='tf', | |
fill_mode='nearest') | |
# reshape to be [samples][pixels][width][height] | |
print(X_test.shape) | |
# convert from int to float | |
X_test_ = X_test.astype('float32') | |
image = X_test[0].squeeze() | |
plt.figure(figsize=(4,4)) | |
plt.imshow(image) | |
plt.figure(figsize=(9,9)) | |
# fit parameters from data | |
datagen.fit(X_test_) | |
# configure batch size and retrieve one batch of images | |
for X_batch in datagen.flow(X_test_, batch_size=9): | |
# create a grid of 3x3 images | |
for i in range(0, 9): | |
plt.subplot(330 + 1 + i) | |
plt.imshow(X_batch[i]) | |
# show the plot | |
plt.show() | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a question. How can determine how many images will be create ?