Commit
·
18dbafb
1
Parent(s):
06dcddf
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,18 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
inputs=gr.inputs.Textbox(lines=1, label="Input Text"),
|
| 7 |
theme="peach",
|
| 8 |
title='🌽 Spanish to Nahuatl Automatic Translation',
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoModelForSeq2SeqLM
|
| 3 |
+
from transformers import AutoTokenizer
|
| 4 |
|
| 5 |
+
model = AutoModelForSeq2SeqLM.from_pretrained('hackathon-pln-es/t5-small-spanish-nahuatl')
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained('hackathon-pln-es/t5-small-spanish-nahuatl')
|
| 7 |
+
|
| 8 |
+
def predict(input):
|
| 9 |
+
input_ids = tokenizer('translate Spanish to Nahuatl: ' + sentence, return_tensors='pt').input_ids
|
| 10 |
+
outputs = model.generate(input_ids)
|
| 11 |
+
outputs = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
|
| 12 |
+
return outputs
|
| 13 |
+
|
| 14 |
+
gr.Interface(
|
| 15 |
+
fn=predict,
|
| 16 |
inputs=gr.inputs.Textbox(lines=1, label="Input Text"),
|
| 17 |
theme="peach",
|
| 18 |
title='🌽 Spanish to Nahuatl Automatic Translation',
|