jaimin commited on
Commit
d7b30ce
·
1 Parent(s): 387fc77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,7 +1,25 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "HEllo " + name + "!!!!!!!!! :)"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ from transformers import pipeline
 
4
 
5
+ pipe = pipeline("translation", model="t5-base")
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
+ german = gr.Textbox(label="German Text")
19
+
20
+ translate_btn.click(translate, inputs=english, outputs=german)
21
+ examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
22
+ inputs=[english])
23
+
24
+ if __name__ == "__main__":
25
+ demo.launch()