Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
+
import requests
|
5 |
|
6 |
+
labels = []
|
7 |
+
|
8 |
+
def classify_image(inp):
|
9 |
+
model = tf.keras.models.load('saved_model')
|
10 |
+
inp = inp.reshape((-1, 480, 480, 3))
|
11 |
+
inp = tf.divide(inp,255.0)
|
12 |
+
prediction = model.predict(inp).flatten()
|
13 |
+
return {labels[i]: float(prediction[i]) for i in range(36)}
|
14 |
+
|
15 |
+
image = gr.inputs.Image(shape=(480, 480))
|
16 |
+
label = gr.outputs.Label(num_top_classes=3)
|
17 |
+
|
18 |
+
gr.Interface(fn=classify_image, inputs=image, outputs=label, capture_session=True, theme = "grass", examples = [["cat.jpeg"]]).launch()
|