Spaces:
Runtime error
Runtime error
Commit ·
8d9bce5
1
Parent(s): 84f1f93
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
modelo =tf.keras.models.load_model('Models_flowers/model_0.h5')
|
| 5 |
+
#modelo.load_weights("Models_flowers/model_0_weights.h5")
|
| 6 |
+
classes=['daisy','dandelion','roses','sunflowers','tulips']
|
| 7 |
+
|
| 8 |
+
def classifier(image):
|
| 9 |
+
pred_img = model.predict(tf.expand_dims(image,axis=0))
|
| 10 |
+
pred_img = tf.squeeze(tf.round(pred_img))
|
| 11 |
+
texto = f'Predicted label: {class_id[(np.argmax(pred_img))]}'
|
| 12 |
+
return texto
|
| 13 |
+
|
| 14 |
+
interface = gr.Interface(fn=classifier,
|
| 15 |
+
gr.inputs.Image(shape=(1024,1024)),
|
| 16 |
+
outputs = "text",
|
| 17 |
+
description="classifier of images of daisy plants, dandelion, roses, sunflowers, and tulips.")
|
| 18 |
+
interface.launch(inline=False)
|
| 19 |
+
|