Skip to content

Instantly share code, notes, and snippets.

@Sachin-crypto
Created November 13, 2022 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sachin-crypto/4c421a7bf76218cffc011765a5cd9aed to your computer and use it in GitHub Desktop.
Save Sachin-crypto/4c421a7bf76218cffc011765a5cd9aed to your computer and use it in GitHub Desktop.
# Importing required libs
from keras.models import load_model
from keras.utils import img_to_array
import numpy as np
from PIL import Image
# Loading model
model = load_model("D:/SACHIN/Models/Hand-Sign-Digit-Language/digit_model.h5")
# Preparing and pre-processing the image
def preprocess_img(img_path):
op_img = Image.open(img_path)
img_resize = op_img.resize((224, 224))
img2arr = img_to_array(img_resize) / 255.0
img_reshape = img2arr.reshape(1, 224, 224, 3)
return img_reshape
# Predicting function
def predict_result(predict):
pred = model.predict(predict)
return np.argmax(pred[0], axis=-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment