File size: 1,217 Bytes
343b998
 
 
 
a98740b
50442b8
343b998
509d11b
343b998
 
 
 
 
 
 
 
 
ed3ed85
4a972f6
b58bd0e
343b998
 
509d11b
bccadc4
343b998
 
 
3e0f953
343b998
 
 
509d11b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
import json

def load_image(img):
    img_tensor = image.img_to_array(img)
    img_tensor = np.expand_dims(img_tensor, axis=0)
    img_tensor /= 255

    return img_tensor

def run_model(img):
    model = load_model("res.h5")

    new_image = load_image(img)
    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)
    return json.dumps(str(results))
    
title = "Indian Sign Language Classifier"
description = "<p style='text-align: center'>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=gr.outputs.Label(num_top_classes=35), title=title, description=description, examples=examples).launch()