Spaces:
Runtime error
Runtime error
hrishikesh commited on
Commit ·
665c9c2
1
Parent(s): 02c5470
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
translation_pipeline = pipeline("translation_en_to_fr")
|
| 5 |
+
|
| 6 |
+
result = translation_pipeline("I like mathematics and computers")
|
| 7 |
+
|
| 8 |
+
result[0]["translation_text"]
|
| 9 |
+
|
| 10 |
+
def translate_gradio(input):
|
| 11 |
+
result = translation_pipeline(input)
|
| 12 |
+
return result[0]['translation_text']
|
| 13 |
+
|
| 14 |
+
translate_interface = gr.Interface(fn = translate_gradio,
|
| 15 |
+
inputs="text",
|
| 16 |
+
outputs="text")
|
| 17 |
+
|
| 18 |
+
translate_interface.launch()
|