Spaces:
Runtime error
Runtime error
| # import gradio as gr | |
| # from transformers import pipeline | |
| # def translate(text,number): | |
| # model1='' | |
| # if number==1: | |
| # model1='Helsinki-NLP/opus-mt-en-es' | |
| # elif number==2: | |
| # model1='Helsinki-NLP/opus-mt-en-fr' | |
| # else: | |
| # model1='Helsinki-NLP/opus-mt-en-ru' | |
| # pipe=pipeline("translation", model=model1) | |
| # return pipe(text)[0]["translation_text"] | |
| # demo = gr.Interface(fn=translate, inputs=["text","number"], outputs="json") | |
| # demo.launch() | |
| # import gradio as gr | |
| # from transformers import pipeline | |
| # pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ru") | |
| # def predict(text): | |
| # return pipe(text)[0]["translation_text"] | |
| # demo = gr.Interface( | |
| # fn=predict, | |
| # inputs='text', | |
| # outputs='text', | |
| # ) | |
| # demo.launch() | |
| import gradio as gr | |
| with gr.Blocks() as demo: | |
| with gr.Tab("Translate to Spanish"): | |
| gr.load("gradio/helsinki_translation_en_es", src="spaces") | |
| with gr.Tab("Translate to French"): | |
| gr.load("abidlabs/en2fr", src="spaces") | |
| demo.launch() |