File size: 1,219 Bytes
bbdb1b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6737762
bbdb1b1
 
 
629a599
bbdb1b1
 
 
 
 
 
 
7b6e24b
bbdb1b1
 
 
5006324
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
33
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("inc.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, 299, 299, 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 = ['6.jpg','q.jpg','c.jpg','3.jpg','n.jpg']


import gradio as gr
gr.Interface(fn=run_model, inputs=gr.inputs.Image(shape=(299,299)), outputs=gr.outputs.Label(num_top_classes=35), title=title, description=description, examples=examples).launch()