Spaces:
Sleeping
Sleeping
Commit ·
c0062d3
1
Parent(s): 7fd1156
Correction in app file
Browse filesChange the model_path from local to the one in the hub
app.py
CHANGED
|
@@ -2,12 +2,12 @@ from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 9 |
|
| 10 |
# Diccionario de etiquetas
|
|
|
|
| 11 |
label_map = {0: "No sexista", 1: "Sexista"}
|
| 12 |
|
| 13 |
def predict(text):
|
|
@@ -17,6 +17,13 @@ def predict(text):
|
|
| 17 |
probs = torch.nn.functional.softmax(logits, dim=1)
|
| 18 |
return {label_map[i]: float(p) for i, p in enumerate(probs[0])}
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
iface.launch()
|
|
|
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
# Carga del modelo desde Hugging Face Hub
|
| 6 |
+
model = AutoModelForSequenceClassification.from_pretrained("diana-salgado/Detector-Sexismo-Espanol")
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained("diana-salgado/Detector-Sexismo-Espanol")
|
|
|
|
| 8 |
|
| 9 |
# Diccionario de etiquetas
|
| 10 |
+
|
| 11 |
label_map = {0: "No sexista", 1: "Sexista"}
|
| 12 |
|
| 13 |
def predict(text):
|
|
|
|
| 17 |
probs = torch.nn.functional.softmax(logits, dim=1)
|
| 18 |
return {label_map[i]: float(p) for i, p in enumerate(probs[0])}
|
| 19 |
|
| 20 |
+
iface = gr.Interface(
|
| 21 |
+
fn=predict,
|
| 22 |
+
inputs=gr.Textbox(lines=3, placeholder="Escribe tu texto aquí..."),
|
| 23 |
+
outputs=gr.Label(num_top_classes=2),
|
| 24 |
+
title="Clasificador de Tweets: Sexista vs No Sexista",
|
| 25 |
+
description="Este modelo clasifica oraciones en español como sexistas o no sexistas.",
|
| 26 |
+
article="Este modelo fue fine-tuned usando `delarosajav95/HateSpeech-BETO-cased-v2` sobre el corpus de EXIST 2024."
|
| 27 |
+
)
|
| 28 |
|
| 29 |
iface.launch()
|