realmanise commited on
Commit
e082e2e
·
verified ·
1 Parent(s): 45c8bc2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import tensorflow as tf
4
+
5
+ lookup = {0:"Cardboard", 1:"Glass", 2:"Metal", 3:"Paper", 4:"Plastic", 5:"Trash"}
6
+
7
+ def predict(image):
8
+ img_array = tf.image.resize(image, [224, 224])
9
+ img_array = tf.expand_dims(img_array, 0)
10
+ predictions = model_loaded.predict({'resnet_input': img_array, 'vgg_input': img_array})
11
+ class_idx = int(np.argmax(predictions))
12
+ return lookup.get(class_idx, "Unknown")
13
+
14
+ demo = gr.Interface(fn=predict, inputs=gr.Image(), outputs="text")
15
+ demo.launch()