Spaces:
Runtime error
Runtime error
File size: 627 Bytes
60eab06 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
import gradio as grad
text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
def text2text_translation(text):
inp = "translate English to German:: "+text
enc = text2text_tkn(inp, return_tensors="pt")
tokens = mdl.generate(**enc)
response=text2text_tkn.batch_decode(tokens)
return response
para=grad.Textbox(lines=1, label="English Text", placeholder="Text in English")
out=grad.Textbox(lines=1, label="German Translation")
grad.Interface(text2text_translation, inputs=para,
outputs=out).launch() |