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