GiladtheFixer commited on
Commit
ed9c614
1 Parent(s): 38cfb67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -13
app.py CHANGED
@@ -1,24 +1,44 @@
1
- import gradio as gr
2
 
3
- from transformers import pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
 
6
 
7
 
8
- def translate(text,number):
9
- model1=''
10
- if number==1:
11
- model1='Helsinki-NLP/opus-mt-en-es'
12
- elif number==2:
13
- model1='Helsinki-NLP/opus-mt-en-fr'
14
- else:
15
- model1='Helsinki-NLP/opus-mt-en-ru'
16
 
17
- pipe=pipeline("translation", model=model1)
18
- return pipe(text)[0]["translation_text"]
19
 
20
 
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- demo = gr.Interface(fn=translate, inputs=["text","number"], outputs="json")
24
  demo.launch()
 
1
+ # import gradio as gr
2
 
3
+ # from transformers import pipeline
4
+
5
+
6
+
7
+
8
+ # def translate(text,number):
9
+ # model1=''
10
+ # if number==1:
11
+ # model1='Helsinki-NLP/opus-mt-en-es'
12
+ # elif number==2:
13
+ # model1='Helsinki-NLP/opus-mt-en-fr'
14
+ # else:
15
+ # model1='Helsinki-NLP/opus-mt-en-ru'
16
+
17
+ # pipe=pipeline("translation", model=model1)
18
+ # return pipe(text)[0]["translation_text"]
19
 
20
 
21
 
22
 
23
+ # demo = gr.Interface(fn=translate, inputs=["text","number"], outputs="json")
24
+ # demo.launch()
 
 
 
 
 
 
25
 
 
 
26
 
27
 
28
 
29
+ import gradio as gr
30
+
31
+ from transformers import pipeline
32
+
33
+ pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
34
+
35
+ def predict(text):
36
+ return pipe(text)[0]["translation_text"]
37
+
38
+ demo = gr.Interface(
39
+ fn=predict,
40
+ inputs='text',
41
+ outputs='text',
42
+ )
43
 
 
44
  demo.launch()