Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
generate=pipeline("translation_en_to_fr",model="t5-large")
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
title=""" <hi> Translate English text to French</h1>"""
|
6 |
+
|
7 |
+
description="""<h5> This app is for english french language translation</h5>"""
|
8 |
+
|
9 |
+
def en_fr(english_text):
|
10 |
+
|
11 |
+
fr=generate(english_text)
|
12 |
+
|
13 |
+
translation=fr[0]["translation_text"]
|
14 |
+
|
15 |
+
return translation
|
16 |
+
|
17 |
+
demo =gr.Interface(fn=en_fr,
|
18 |
+
inputs=gr.Textbox(label="English"),
|
19 |
+
outputs=gr.Textbox(label="French"),
|
20 |
+
title=title,
|
21 |
+
description=description,
|
22 |
+
examples=[["Hello! My name is Abubakar"], ["How are you?"]])
|
23 |
+
|
24 |
+
if __name__ =="__main__":
|
25 |
+
demo.launch()
|