shauryaDugar commited on
Commit
fabc674
·
1 Parent(s): ca93ff7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import gradio.inputs
3
+ import numpy as np # linear algebra
4
+ import os #interacting with input and output directories
5
+ import tensorflow as tf #framework for creating the neural network
6
+
7
+ def fn(img):
8
+ img = np.expand_dims(img, axis = 0)
9
+ model = tf.keras.models.load_model(os.path.join(os.getcwd(), 'noteClassifierModel.h5'))
10
+ pred = model.predict(img)
11
+ pred = np.argmax(pred)
12
+
13
+ num_to_note_dict = {0: 'india_10', 1: 'india_100', 2: 'india_20',
14
+ 3: 'india_200', 4: 'india_2000', 5: 'india_50',
15
+ 6: 'india_500', 7: 'thai_100', 8: 'thai_1000',
16
+ 9: 'thai_20', 10: 'thai_50', 11:'thai_500'}
17
+
18
+ text_pred = num_to_note_dict[pred]
19
+
20
+ return text_pred
21
+
22
+ description = "This interface can be used to classify Indian and Thai currency notes into their correct " \
23
+ "denominations. For eg. if you upload an image of a Rs. 10 note, the output should be 'india_10'" \
24
+ ", similarly a 500 Baht note will output 'thai_500'. So what are you waiting for, go ahead and " \
25
+ "test the NoteClassifier..."
26
+ iface = gr.Interface(fn,
27
+ inputs= gradio.inputs.Image(tool="select", label = "Note Image", shape=(224, 224)),
28
+ outputs='text',
29
+ title="Note Classifier",
30
+ description=description,
31
+ theme="dark-seafoam",
32
+ allow_flagging="manual")
33
+ iface.launch(share=True)
34
+