Spaces:
Sleeping
Sleeping
Adding app.py
Browse filesAdding app file
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
def clasifica_imagen(inp):
|
5 |
+
inp = inp.resize((224,224))
|
6 |
+
inp = np.asarray(inp)[:,:,:3]
|
7 |
+
inp = inp.reshape(-1,224,224,3)
|
8 |
+
inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
|
9 |
+
prediction = inception_net.predict(inp).flatten()
|
10 |
+
confidences = {etiquetas[i] : float(prediction[i]) for i in range(len(etiquetas)-1)}
|
11 |
+
return confidences
|
12 |
+
|
13 |
+
demo=gr.Interface(fn= clasifica_imagen,
|
14 |
+
inputs=gr.Image(type='pil',height=200, width = 200),
|
15 |
+
outputs = gr.Label(num_top_classes = 3)
|
16 |
+
)
|
17 |
+
demo.launch(share=True)
|