Spaces:
Runtime error
Runtime error
Download app.py from wayne0019/gradioopusenzh: direct link, hf CLI and curl.
- Browser
- Download file 671 Bytes
-
https://huggingface.co/spaces/wayne0019/gradioopusenzh/resolve/main/app.py
- Command line
-
hf download hf://spaces/wayne0019/gradioopusenzh/app.py
-
curl -L -o app.py https://huggingface.co/spaces/wayne0019/gradioopusenzh/resolve/main/app.py
671 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-zh") | |
| def main(in_text): | |
| print(in_text) | |
| answer = pipe(in_text) | |
| print(answer) | |
| return answer[0]["translation_text"] | |
| with gr.Blocks() as demo: | |
| gr.Markdown("""# Translation Engine""") | |
| with gr.Row(): | |
| with gr.Column(): | |
| text1 = gr.Textbox( | |
| label="Input Text", | |
| lines=1, | |
| ) | |
| output = gr.Textbox(label="Output Text") | |
| b1 = gr.Button("Translate") | |
| b1.click(main, inputs=[text1], outputs=output) | |
| gr.Markdown("""#### powered by OpenCSG""") | |
| if __name__ == "__main__": | |
| demo.launch(debug=True) |