You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In short we only see rescale option in ImageDataGenerator. How do you do the following for pertained VGG16 network that needs the channels values preprocessed as follows:
im = cv2.resize(cv2.imread('cat.jpg'), (224, 224)).astype(np.float32)
im[:,:,0] -= 103.939
im[:,:,1] -= 116.779
im[:,:,2] -= 123.68
im = im.transpose((2,0,1))
im = np.expand_dims(im, axis=0)
Where do we specify these options in ImageDataGenerator?
Thanks
Dr
The text was updated successfully, but these errors were encountered:
There is a tread #3338 and gives a solution by adding a pipeline with fork of imageGenerator in keras. I think is that your looking for, sorry if I am wrong.
A more manual way of doing this is:
Pass the batches created in the form below trough a method that treats you data as you want it.
for e in range(nb_epoch):
print 'Epoch', e
batches = 0
for X_batch, Y_batch in datagen.flow(X_train, Y_train, batch_size=32):
loss = model.train(X_batch, Y_batch)
batches += 1
if batches >= len(X_train) / 32:
# we need to break the loop by hand because
# the generator loops indefinitely
break
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, but feel free to re-open it if needed.
In short we only see rescale option in ImageDataGenerator. How do you do the following for pertained VGG16 network that needs the channels values preprocessed as follows:
im = cv2.resize(cv2.imread('cat.jpg'), (224, 224)).astype(np.float32)
im[:,:,0] -= 103.939
im[:,:,1] -= 116.779
im[:,:,2] -= 123.68
im = im.transpose((2,0,1))
im = np.expand_dims(im, axis=0)
Where do we specify these options in ImageDataGenerator?
Thanks
Dr
The text was updated successfully, but these errors were encountered: