Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,14 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
|
5 |
+
def greet(text,task):
|
6 |
+
pipe = pipeline(task="translation_en_to_fr", model="google-t5/t5-small",max_length=128)
|
7 |
+
result=pipe(text)
|
8 |
+
return result[0]["translation_text"]
|
9 |
+
|
10 |
+
text = gr.Textbox(lines=5,label="输入文本",placeholder="请输入文本")
|
11 |
+
task = gr.Dropdown(label="翻译类型",choices=["translation_en_to_fr","translation_en_to_de","translation_en_to_fr","translation_en_to_ro"])
|
12 |
+
output_text = gr.Textbox(lines=5,label="翻译文本",placeholder="翻译文本")
|
13 |
+
demo=gr.Interface(fn=greet, inputs=[text,task], outputs=output_text)
|
14 |
+
demo.launch(share=True)
|