Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| from value import value | |
| translater = pipeline("translation", model="VietAI/envit5-translation") | |
| def translate(inp, direction): | |
| if direction == 'en->vi': | |
| text = "en: " + value | |
| else: | |
| text = "vi: " + value | |
| res = translater( | |
| text, | |
| max_length=999999999, | |
| early_stopping=False, | |
| )[0]['translation_text'][3:] | |
| return res | |
| description = """ | |
| <p> | |
| <center> | |
| Multi-domain Translation Between English and Vietnamese | |
| </center> | |
| </p> | |
| """ | |
| article = "<p style='text-align: center'><a href='http://translate.vietai.org' target='_blank'>by VietAI Research</a> | <a href='https://github.com/vietai/mTet' target='_blank'>Github</a> | Contact: <a href='mailto:[email protected]' target='_blank'>Hieu Tran</a></p></center></p>" | |
| examples = [ | |
| ["Dear God, thank you for granting us the evergreen garden of this world", "en->vi"], | |
| ["Thuốc này đã bị cấm sử dụng trong ngành thú y tại Ấn Độ.", "vi->en"] | |
| ] | |
| iface = gr.Interface( | |
| fn=translate, | |
| title="🌸MTet Translation🌸", | |
| description=description, | |
| article=article, | |
| examples=examples, | |
| inputs=[ | |
| gr.inputs.Textbox(placeholder="Enter text (maximum 100 lines)", label="Input"), | |
| gr.inputs.Radio( | |
| choices=[ | |
| 'en->vi', | |
| 'vi->en'], | |
| default='en->vi', | |
| label='Direction'), | |
| ], | |
| outputs="text") | |
| iface.launch(enable_queue=True) |