Spaces:
Sleeping
Sleeping
Commit
·
5389890
1
Parent(s):
15b206d
Update app.py
Browse files
app.py
CHANGED
@@ -148,10 +148,10 @@ import gradio as grad
|
|
148 |
text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
|
149 |
mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
|
150 |
def text2text_translation(text):
|
151 |
-
inp = "translate English to Portuguese
|
152 |
-
enc = text2text_tkn(inp, return_tensors="pt")
|
153 |
-
tokens = mdl.generate(**enc)
|
154 |
-
response=text2text_tkn.
|
155 |
return response
|
156 |
para=grad.Textbox(lines=1, label="English Text", placeholder="Text in English")
|
157 |
out=grad.Textbox(lines=1, label="Portuguese Translation")
|
|
|
148 |
text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
|
149 |
mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
|
150 |
def text2text_translation(text):
|
151 |
+
inp = "translate English to Portuguese: "+text
|
152 |
+
enc = text2text_tkn(inp, return_tensors="pt", max_length=512, truncation=True)
|
153 |
+
tokens = mdl.generate(**enc, max_length=100, num_return_sequences=1, early_stopping=True)
|
154 |
+
response=text2text_tkn.decode(tokens[0], skip_special_tokens=True)
|
155 |
return response
|
156 |
para=grad.Textbox(lines=1, label="English Text", placeholder="Text in English")
|
157 |
out=grad.Textbox(lines=1, label="Portuguese Translation")
|