Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,14 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
-
pipe = pipeline("translation", model="
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
+
import spaces
|
| 4 |
|
| 5 |
+
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
|
| 6 |
|
| 7 |
+
@spaces.GPU
|
| 8 |
+
def translate(text):
|
| 9 |
+
# Move pipeline to GPU inside the GPU context (if available)
|
| 10 |
+
pipe.model.to("cuda")
|
| 11 |
+
return pipe(text)[0]["translation_text"]
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(fn=translate, inputs="text", outputs="text")
|
| 14 |
+
demo.launch()
|