I have trained a model with Keras and Tensorflow and generated an .h5 file where the model is saved. Here is my code (I have only included the model and not the data processing snippet so that it will be more readable):
ts = 0.3 # Percentage of images that we want to use for testing. The rest is used for training.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=ts, random_state=42)
# Import of keras model and hidden layers for our convolutional network
from keras.models import Sequential
from keras.layers.convolutional import Conv2D, MaxPooling2D
from keras.layers import Dense, Flatten
from tensorflow.python.client import device_lib
from keras import backend as K
# Construction of model
model = Sequential()
model.add(Conv2D(32, (5, 5), activation='relu', input_shape=(120, 320, 1)))
model.add(MaxPooling2D((2, 2)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dense(10, activation='softmax'))
# Configures the model for training
model.compile(optimizer='adam', # Optimization routine, which tells the computer how to adjust the parameter values to minimize the loss function.
loss='sparse_categorical_crossentropy', # Loss function, which tells us how bad our predictions are.
metrics=['accuracy']) # List of metrics to be evaluated by the model during training and testing.
# Trains the model for a given number of epochs (iterations on a dataset) and validates it.
model.fit(X_train, y_train, epochs=5, batch_size=64, verbose=2, validation_data=(X_test, y_test))
# Save entire model to a HDF5 file
model.save('handrecognition_model.h5')
I have trained my model on this data set which contains photos of hand gestures. Now I have a photo which I have taken with laptop camera, lets say it is called "thumbs_up.jpg" and it contains a picture of me doing a thumbs up. I wanna put this picture on the model I trained to see if it will predict it correctly. I know I am probably missing something extremently basic here, but how can I do this? Should I use the .h5 file somehow? Sorry if my question is super basic/obvious I am just legit confused and dont know what to do. Thanks in advance