File size: 777 Bytes
ed9c614
6e05fea
ed9c614
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e05fea
 
 
 
ed9c614
 
e59973f
6e05fea
 
 
ed9c614
 
 
 
5f75b38
ed9c614
 
 
 
 
 
 
 
 
6e05fea
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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()