Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
def greet(text,task): | |
pipe = pipeline(task="translation_en_to_fr", model="google-t5/t5-small",max_length=128) | |
result=pipe(text) | |
return result[0]["translation_text"] | |
text = gr.Textbox(lines=5,label="输入文本",placeholder="请输入文本") | |
task = gr.Dropdown(label="翻译类型",choices=["translation_en_to_fr","translation_en_to_de","translation_en_to_fr","translation_en_to_ro"]) | |
output_text = gr.Textbox(lines=5,label="翻译文本",placeholder="翻译文本") | |
demo=gr.Interface(fn=greet, inputs=[text,task], outputs=output_text) | |
demo.launch(share=True) |