Lorefielle commited on
Commit
268afb1
·
verified ·
1 Parent(s): 82093fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -1,21 +1,25 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Usa un modelo que funcione con SentencePiece
5
  classifier = pipeline(
6
  "text-classification",
7
- model="finiteautomata/bertweet-base-sentiment-analysis", # Modelo alternativo
8
  device=-1
9
  )
10
 
 
11
  def classify_text(text):
12
  result = classifier(text)
13
- return "videojuegos" if result[0]['label'] == 'POS' else "películas" # Ajusta según el modelo
14
 
15
- iface = gr.Interface(
 
16
  fn=classify_text,
17
  inputs=gr.Textbox(lines=2, placeholder="Pega la noticia aquí..."),
18
  outputs="text",
19
- title="Filtro de Noticias: ¿Videojuego o Película?"
 
20
  )
21
- iface.launch()
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Carga el modelo
5
  classifier = pipeline(
6
  "text-classification",
7
+ model="finiteautomata/bertweet-base-sentiment-analysis",
8
  device=-1
9
  )
10
 
11
+ # Función de clasificación
12
  def classify_text(text):
13
  result = classifier(text)
14
+ return "videojuegos" if result[0]['label'] == 'POS' else "películas"
15
 
16
+ # Configuración de Gradio con endpoints API
17
+ app = gr.Interface(
18
  fn=classify_text,
19
  inputs=gr.Textbox(lines=2, placeholder="Pega la noticia aquí..."),
20
  outputs="text",
21
+ title="Filtro de Noticias: ¿Videojuego o Película?",
22
+ api_name="predict" # <--- ¡Clave para exponer la API!
23
  )
24
+
25
+ app.launch(show_api=True) # Muestra la documentación de la API