Spaces:
Build error
Build error
update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,16 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def envit5_translation(text):
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def my_translation(text):
|
| 11 |
return "My Translation"
|
|
@@ -20,20 +25,27 @@ def translation(text):
|
|
| 20 |
|
| 21 |
return (output1, output2, output3)
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio.mix import Parallel, Series
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
envit5_translater = pipeline("translation", model="VietAI/envit5-translation")
|
| 6 |
|
| 7 |
def envit5_translation(text):
|
| 8 |
+
res = envit5_translater(
|
| 9 |
+
text,
|
| 10 |
+
max_length=512,
|
| 11 |
+
early_stopping=True,
|
| 12 |
+
)[0]['translation_text'][3:]
|
| 13 |
+
return res
|
| 14 |
|
| 15 |
def my_translation(text):
|
| 16 |
return "My Translation"
|
|
|
|
| 25 |
|
| 26 |
return (output1, output2, output3)
|
| 27 |
|
| 28 |
+
description = """
|
| 29 |
+
<p>
|
| 30 |
+
<center>
|
| 31 |
+
Multi-domain Translation Between English and Vietnamese
|
| 32 |
+
Using VietAI Translation
|
| 33 |
+
</center>
|
| 34 |
+
</p>
|
| 35 |
+
"""
|
| 36 |
+
examples = [
|
| 37 |
+
["Dear God, thank you for granting us the evergreen garden of this world", "en->vi"],
|
| 38 |
+
["Thuốc này đã bị cấm sử dụng trong ngành thú y tại Ấn Độ.", "vi->en"]
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
iface = gr.Interface(
|
| 42 |
+
fn=translation,
|
| 43 |
+
title="Co Gai Mo Duong",
|
| 44 |
+
description=description,
|
| 45 |
+
examples=examples,
|
| 46 |
+
inputs=[
|
| 47 |
+
gr.inputs.Textbox(lines=5, placeholder="Enter text (maximum 5 lines)", label="Input"),
|
| 48 |
+
],
|
| 49 |
+
outputs=["text", "text", "text"])
|
| 50 |
+
|
| 51 |
+
iface.launch(enable_queue=True)
|