Spaces:
Sleeping
Sleeping
Commit
·
21c3307
1
Parent(s):
8faab1f
segunda correcion
Browse files
app.py
CHANGED
@@ -1,33 +1,3 @@
|
|
1 |
-
import tensorflow as tf
|
2 |
-
|
3 |
-
inception_net = tf.keras.applications.MobileNetV2()
|
4 |
-
|
5 |
-
import requests
|
6 |
-
|
7 |
-
respuesta = requests.get("https://git.io/JJkYN")
|
8 |
-
etiquetas = respuesta.text.split("\n")
|
9 |
-
# Obteniendo las labels de "https://git.io/JJkYN"
|
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 |
-
import gradio as gr
|
19 |
-
from transformers import pipeline
|
20 |
-
|
21 |
-
trans = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish")
|
22 |
-
clasificador = pipeline("text-classification", model="pysentimiento/robertuito-sentiment-analysis")
|
23 |
-
|
24 |
-
def audio_a_text(audio):
|
25 |
-
text = trans(audio)["text"]
|
26 |
-
return text
|
27 |
-
|
28 |
-
def texto_a_sentimiento(text):
|
29 |
-
return clasificador(text)[0]["label"]
|
30 |
-
|
31 |
|
32 |
demo = gr.Blocks()
|
33 |
|
@@ -46,16 +16,12 @@ with demo:
|
|
46 |
label = gr.Label()
|
47 |
b2 = gr.Button("sentimiento porfa")
|
48 |
|
49 |
-
|
50 |
-
with gr.Row():
|
51 |
-
imagen = gr.Image(shape=(224,224))
|
52 |
-
label1 = gr.Label(num_top_classes=3)
|
53 |
-
b3 = gr.Button("clasifica")
|
54 |
|
55 |
|
56 |
b1.click(audio_a_text, inputs = audio, outputs = transcripcion)
|
57 |
b2.click(texto_a_sentimiento, inputs = texto, outputs = label)
|
58 |
-
b3.click(clasifica_imagen, inputs = imagen, outputs=label1)
|
59 |
|
60 |
|
61 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
demo = gr.Blocks()
|
3 |
|
|
|
16 |
label = gr.Label()
|
17 |
b2 = gr.Button("sentimiento porfa")
|
18 |
|
19 |
+
|
|
|
|
|
|
|
|
|
20 |
|
21 |
|
22 |
b1.click(audio_a_text, inputs = audio, outputs = transcripcion)
|
23 |
b2.click(texto_a_sentimiento, inputs = texto, outputs = label)
|
24 |
+
#b3.click(clasifica_imagen, inputs = imagen, outputs=label1)
|
25 |
|
26 |
|
27 |
demo.launch()
|