File size: 463 Bytes
e61023b
a56a393
c443201
a56a393
 
572d241
a56a393
c443201
a56a393
11e3f47
 
 
 
c443201
 
a56a393
e61023b
 
572d241
c443201
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import pipeline

translator = pipeline(
    "text2text-generation",
    model="t5-small"
)

def translate(text):
    return translator(
        "translate English to Spanish: " + text,
        max_length=64
    )[0]["generated_text"]

demo = gr.Interface(
    fn=translate,
    inputs=gr.Textbox(label="English Input"),
    outputs=gr.Textbox(label="Spanish Output"),
    title="Working Demo (T5 base model)"
)

demo.launch()