Update app.py
Browse files
app.py
CHANGED
@@ -17,10 +17,18 @@ repo_id = "islasher/mbart-spanishToQuechua"
|
|
17 |
|
18 |
# Cargar el modelo y el tokenizador
|
19 |
nombre_modelo = 'islasher/mbart-spanishToQuechua'
|
20 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(nombre_modelo)
|
21 |
-
tokenizer = AutoTokenizer.from_pretrained(nombre_modelo)
|
22 |
|
|
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
|
26 |
|
@@ -57,15 +65,19 @@ def compute_metrics(eval_preds):
|
|
57 |
|
58 |
|
59 |
|
|
|
|
|
|
|
|
|
60 |
|
61 |
#CAMBIAR LO QUE SE RETORNA Y PONER LO DEL DECODER.
|
62 |
|
63 |
|
64 |
-
def predict(frase):
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
# Creamos la interfaz y la lanzamos.
|
71 |
-
gr.Interface(fn=
|
|
|
17 |
|
18 |
# Cargar el modelo y el tokenizador
|
19 |
nombre_modelo = 'islasher/mbart-spanishToQuechua'
|
|
|
|
|
20 |
|
21 |
+
#tokenizer = AutoTokenizer.from_pretrained(nombre_modelo)
|
22 |
|
23 |
+
model_checkpoint = "facebook/mbart-large-50"
|
24 |
+
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
25 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
from transformers import DataCollatorForSeq2Seq
|
30 |
+
|
31 |
+
data_collator = DataCollatorForSeq2Seq(tokenizer) #para preparar los datos
|
32 |
|
33 |
|
34 |
|
|
|
65 |
|
66 |
|
67 |
|
68 |
+
from transformers import pipeline
|
69 |
+
neutralizer = pipeline('text2text-generation', model='islasher/mbart-spanishToQuechua')
|
70 |
+
|
71 |
+
|
72 |
|
73 |
#CAMBIAR LO QUE SE RETORNA Y PONER LO DEL DECODER.
|
74 |
|
75 |
|
76 |
+
# def predict(frase):
|
77 |
+
# inputs = tokenizer(frase, return_tensors="pt")
|
78 |
+
# outputs = model(**inputs)
|
79 |
+
# trad = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
80 |
+
# return trad
|
81 |
+
|
82 |
# Creamos la interfaz y la lanzamos.
|
83 |
+
gr.Interface(fn=neutralizer, inputs="text", outputs="text").launch(share=False)
|