veronhii commited on
Commit
9c52842
·
1 Parent(s): 98d1d67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -1,7 +1,27 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as input
4
 
5
+ num_classes = 200
6
+ IMG_HEIGHT = 256
7
+ IMG_WIDTH = 256
8
 
9
+ def normalize_image(img):
10
+ img = tf.cast(img, tf.float32)/255.
11
+ img = tf.image.resize(img, (IMG_HEIGHT, IMG_WIDTH), method='bilinear')
12
+ return img
13
+
14
+
15
+ def predict_fn(img):
16
+ img = img.convert('RGB')
17
+ img_data = normalize_image(img)
18
+ x = np.array(img_data)
19
+ x = np.expand_dims(x, axis=0)
20
+ temp = model.predict(x)
21
+ return temp
22
+
23
+
24
+ model = tf.keras.models.load_model("model.h5")
25
+
26
+ interface = gr.Interface(predict_fn, gr.inputs.Image(type='PIL'), outputs='label', examples=path,)
27
+ interface.launch()