Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import numpy as np
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
import tensorflow as tf
|
6 |
+
from tensorflow.keras.models import load_model
|
7 |
+
|
8 |
+
model = load_model('model.keras')
|
9 |
+
labels = ["bird", "cat", "deer", "dog"]
|
10 |
+
|
11 |
+
def pred(input_img):
|
12 |
+
prediction = model.predict(np.array([input_img])/255) #/255 to normalize (rgb)
|
13 |
+
prediction = np.argmax(prediction)
|
14 |
+
prediction = labels[prediction]
|
15 |
+
return prediction
|
16 |
+
|
17 |
+
demo = gr.Interface(pred, gr.Image(), "text")
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
demo.launch()
|