ayoubkirouane
commited on
Commit
•
c0e2a7b
1
Parent(s):
beca1bb
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use a pipeline as a high-level helper
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
from transformers import pipeline
|
5 |
+
|
6 |
+
pipe = pipeline("translation", model="ayoubkirouane/Med_English2Spanish")
|
7 |
+
def predict(text):
|
8 |
+
return pipe(text)[0]["translation_text"]
|
9 |
+
|
10 |
+
with gr.Blocks() as demo:
|
11 |
+
english_inp = gr.Textbox(label="English Sentence")
|
12 |
+
spanish_op = gr.Textbox(label="Spanish Translation")
|
13 |
+
translate_btn = gr.Button("Translate")
|
14 |
+
translate_btn.click(fn=predict, inputs=english_inp, outputs=spanish_op)
|
15 |
+
|
16 |
+
demo.launch()
|