espejelomar commited on
Commit
15e6e84
1 Parent(s): 295d7b9

Create new file

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import requests
3
+ import gradio as gr
4
+
5
+ inception_net = tf.keras.applications.MobileNetV2()
6
+
7
+ # Obteniendo las labels de "https://git.io/JJkYN"
8
+ respuesta = requests.get("https://git.io/JJkYN")
9
+ etiquetas = respuesta.text.split("\n")
10
+
11
+ def clasifica_imagen(inp):
12
+ inp = inp.reshape((-1, 224, 224, 3))
13
+ inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
14
+ prediction = inception_net.predict(inp).flatten()
15
+ confidences = {etiquetas[i]: float(prediction[i]) for i in range(1000)}
16
+ return confidences
17
+
18
+ demo = gr.Interface(fn=clasifica_imagen,
19
+ inputs=gr.Image(shape=(224, 224)),
20
+ outputs=gr.Label(num_top_classes=3)
21
+ )
22
+
23
+ demo.launch()