import tensorflow as tf from tensorflow.keras.preprocessing import image import matplotlib.pyplot as plt from keras.models import load_model import numpy as np def load_image(img, show=False): #img = img.reshape((-1, 224, 224, 3)) #img = image.load_img(img_path, target_size=(224, 224)) img_tensor = image.img_to_array(img) img_tensor = np.expand_dims(img_tensor, axis=0) img_tensor /= 255 if show: plt.imshow(img_tensor[0]) plt.axis('off') plt.show() return img_tensor def run_model(img): model = load_model("res.h5") #img_path = '/content/Indian/9/1020.jpg' new_image = load_image(img) #result = model.predict(new_image) classes = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] img = img.reshape((-1, 224, 224, 3)) result = model.predict(img) results = dict(zip(classes, result[0])) return max(results, key = results.get) title = "Indian Sign Language Classifier" description = "

Classifies images from 0-9, A-Z made using Indian Sign Language" examples = ['5.jpg','9.jpg','A.jpg','L.jpg','P.jpg'] import gradio as gr gr.Interface(fn=run_model, inputs=gr.inputs.Image(shape=(224,224)), outputs='text', title=title, description=description, examples=examples).launch()