Spaces:
Runtime error
Runtime error
Update app.py
Browse filesT5 translation English to French
app.py
CHANGED
|
@@ -279,7 +279,7 @@
|
|
| 279 |
# grad.Interface(text2text_summary, inputs=para, outputs=out).launch()
|
| 280 |
|
| 281 |
#-----------------------------------------------------------------------------------
|
| 282 |
-
# 12. Text-to-Text Generation using the T5 model - Task 3
|
| 283 |
|
| 284 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
| 285 |
import gradio as grad
|
|
@@ -288,7 +288,10 @@ text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
|
|
| 288 |
mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
|
| 289 |
|
| 290 |
def text2text_translation(text):
|
| 291 |
-
|
|
|
|
|
|
|
|
|
|
| 292 |
enc = text2text_tkn(inp, return_tensors="pt")
|
| 293 |
tokens = mdl.generate(**enc)
|
| 294 |
response=text2text_tkn.batch_decode(tokens)
|
|
|
|
| 279 |
# grad.Interface(text2text_summary, inputs=para, outputs=out).launch()
|
| 280 |
|
| 281 |
#-----------------------------------------------------------------------------------
|
| 282 |
+
# 12. Text-to-Text Generation using the T5 model - Task 3 Translation.
|
| 283 |
|
| 284 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
| 285 |
import gradio as grad
|
|
|
|
| 288 |
mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
|
| 289 |
|
| 290 |
def text2text_translation(text):
|
| 291 |
+
# English to German
|
| 292 |
+
# inp = "translate English to German:: "+text
|
| 293 |
+
# English to Frendh
|
| 294 |
+
inp = "translate English to French:: " +text
|
| 295 |
enc = text2text_tkn(inp, return_tensors="pt")
|
| 296 |
tokens = mdl.generate(**enc)
|
| 297 |
response=text2text_tkn.batch_decode(tokens)
|