paranitik commited on
Commit
de03de3
1 Parent(s): 5734ea9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import pipeline
4
+
5
+ pipe = pipeline("text-generation", model="ai-forever/mGPT-1.3B-turkmen")
6
+
7
+
8
+ def translate(text):
9
+ return pipe(text)[0]["translation_text"]
10
+
11
+
12
+ with gr.Blocks() as demo:
13
+ with gr.Row():
14
+ with gr.Column():
15
+ english = gr.Textbox(label="English text")
16
+ translate_btn = gr.Button(value="Translate")
17
+ with gr.Column():
18
+ russian = gr.Textbox(label="Russian Text")
19
+
20
+ translate_btn.click(translate, inputs=english, outputs=russian, api_name="translate-to-russian")
21
+ examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
22
+ inputs=[english])
23
+
24
+ demo.launch()