Created
November 13, 2022 13:10
-
-
Save Sachin-crypto/4c421a7bf76218cffc011765a5cd9aed 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
# 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