I want to perform transfer learning using VGG16.
Facing issue with the input shape in vgg which is (48,48,3). How do i change the dimensions so that i can fed it in the vgg model?
Solved!
@gabrieldemarmiesse Is implementing transfer learning using mnist worth a PR? Wrote a small pre processing program before feeding it to the pre-trained model.
I don't think a PR is necessary, thanks for the proposition.
For future readers, you can put you your code in this issue. Maybe that
will help others :)
On Mon, 24 Sep 2018, 09:34 Hasib Zunair, notifications@github.com wrote:
@gabrieldemarmiesse https://github.com/gabrieldemarmiesse is
implementing transfer learning using mnist worth a PR? Wrote a small pre
processing program before feeding it to the pre-trained model.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/keras-team/keras/issues/11208#issuecomment-423894922,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMS2K8-o_Rubn84y7EJ8FnabF8kv5KfDks5ueIr7gaJpZM4W1wud
.
Code snippet for pre-processing mnist data(grayscale to multi-channel) and feed it to a VGG16 pre-trained model.
(X_train, y_train), (X_test, y_test) = mnist.load_data()
print(X_train.shape)
print(y_train.shape)
dim = (48, 48)
#convert 28x28 grayscale to 48x48 rgb channels
def to_rgb(img):
img = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)
img_rgb = np.asarray(np.dstack((img, img, img)), dtype=np.uint8)
return img_rgb
rgb_list = []
#convert X_train data to 48x48 rgb values
for i in range(len(X_train)):
rgb = to_rgb(X_train[i])
rgb_list.append(rgb)
#print(rgb.shape)
rgb_arr = np.stack([rgb_list],axis=4)
rgb_arr_to_3d = np.squeeze(rgb_arr, axis=4)
print(rgb_arr_to_3d.shape)
@gabrieldemarmiesse tested VGG16 with different configurations on MNSIT with some fine tuning and pre processing, are these test helpful enough to be added in keras/examples. Can send the code for a review.
@gabrieldemarmiesse, implemented grayscale to multi-channel conversion(28, 28) -->> (28, 28, 3) and fed it to a VGG16 pre-trained model, worked(~99.87% on MNIST)! Hope it's useful. Requesting a review.
Found interest on this here
Thanks for posting your work here. We try not to bloat too much the examples directory (it's already pretty full). MNIST and transfer learning are already well documented in keras. Putting your work on a personal repo is a better approach in my opinion.
Alright, I will do that then. Thanks for the suggestion.
Most helpful comment
Code snippet for pre-processing mnist data(grayscale to multi-channel) and feed it to a VGG16 pre-trained model.