Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
!pip3 install torch torchvision torchaudio
|
| 2 |
+
!pip install transformers gradio --upgrade
|
| 3 |
+
|
| 4 |
+
import gradio as gr
|
| 5 |
+
from transformers import pipeline
|
| 6 |
+
|
| 7 |
+
translation = pipeline('translation_en_to_fr')
|
| 8 |
+
|
| 9 |
+
def translate(from_text):
|
| 10 |
+
result = translation(from_text)[0]['translation_text']
|
| 11 |
+
return result
|
| 12 |
+
|
| 13 |
+
interface = gr.Interface(fn = translate , inputs = gr.Textbox(lines=2 , placeholder="text to translate") , outputs="text" )
|
| 14 |
+
interface.launch()
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|