File size: 1,570 Bytes
fabc674
 
 
 
 
 
0056c2d
 
fabc674
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f5a895
0056c2d
269500c
fabc674
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
34
35
36
37
import gradio as gr
import gradio.inputs
import numpy as np # linear algebra
import os #interacting with input and output directories
import tensorflow as tf #framework for creating the neural network

model = tf.keras.models.load_model(os.path.join(os.getcwd(), 'noteClassifierModel.h5'))

def fn(img):
    img = np.expand_dims(img, axis = 0)
    pred = model.predict(img)
    pred = np.argmax(pred)

    num_to_note_dict = {0: 'india_10', 1: 'india_100', 2: 'india_20',
                        3: 'india_200', 4: 'india_2000', 5: 'india_50',
                        6: 'india_500', 7: 'thai_100', 8: 'thai_1000',
                        9: 'thai_20', 10: 'thai_50', 11:'thai_500'}

    text_pred = num_to_note_dict[pred]

    return text_pred
    
description = "This interface can be used to classify Indian and Thai currency notes into their correct " \
              "denominations. For eg. if you upload an image of a Rs. 10 note, the output should be 'india_10'" \
              ", similarly a 500 Baht note will output 'thai_500'. So what are you waiting for, go ahead and " \
              "test the NoteClassifier..."
iface = gr.Interface(fn,
                     inputs= gradio.inputs.Image(tool="select", label = "Note Image", shape=(224, 224)),
                     outputs='text',
                     title="Note Classifier",
                     description=description,
                     theme="dark-seafoam",
                     allow_flagging="auto",
                     flagging_dir='flagging records')
iface.launch(inline=False, share = True)