Salvatore7262 commited on
Commit
c375479
·
verified ·
1 Parent(s): 11bff91

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 tensorflow as tf
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ model = tf.keras.models.load_model("model.h5")
7
+
8
+ def predict(img):
9
+ img = img.resize((224, 224))
10
+ img_array = np.expand_dims(np.array(img) / 255.0, axis=0)
11
+ preds = model.predict(img_array)
12
+ labels = ["cool", "neutral", "warm"]
13
+ return {labels[i]: float(preds[0][i]) for i in range(3)}
14
+
15
+ gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label()).launch()