RodrigoGariv commited on
Commit
73575e3
verified
1 Parent(s): 278053d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app_imagenes.py +26 -0
  2. app_sentiment.py +19 -0
app_imagenes.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from tensorflow.keras.applications.mobilenet_v2 import MobileNetV2, decode_predictions, preprocess_input
3
+ from tensorflow.keras.preprocessing import image
4
+ import numpy as np
5
+
6
+ model = MobileNetV2(weights="imagenet")
7
+
8
+ def clasificar_img(img):
9
+ img = img.resize((224, 224))
10
+ img_array = image.img_to_array(img)
11
+ img_array = np.expand_dims(img_array, axis=0)
12
+ img_array = preprocess_input(img_array)
13
+
14
+ preds = model.predict(img_array)
15
+ decoded = decode_predictions(preds, top=1)[0][0]
16
+ return f"Predicci贸n: {decoded[1]} (Confianza: {round(decoded[2] * 100, 2)}%)"
17
+
18
+ demo = gr.Interface(
19
+ fn=clasificar_img,
20
+ inputs=gr.Image(type="pil"),
21
+ outputs="text",
22
+ title="Clasificaci贸n de Im谩genes con MobileNetV2",
23
+ description="Sube una imagen y recibe una predicci贸n de su contenido."
24
+ )
25
+
26
+ demo.launch()
app_sentiment.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Cargar el pipeline de an谩lisis de sentimientos con tu modelo fine-tuned
5
+ classifier = pipeline("text-classification", model="tu_usuario/tu_modelo_de_sentimientos")
6
+
7
+ def analizar_sentimiento(texto):
8
+ resultado = classifier(texto)[0]
9
+ return f"Etiqueta: {resultado['label']} - Confianza: {round(resultado['score'] * 100, 2)}%"
10
+
11
+ demo = gr.Interface(
12
+ fn=analizar_sentimiento,
13
+ inputs=gr.Textbox(lines=3, placeholder="Escribe una rese帽a..."),
14
+ outputs="text",
15
+ title="Clasificador de Sentimientos",
16
+ description="Modelo fine-tuned para clasificar texto como positivo o negativo."
17
+ )
18
+
19
+ demo.launch()