ejschwartz commited on
Commit
2370f1a
·
verified ·
1 Parent(s): 2498cf4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -1,7 +1,14 @@
1
  from transformers import pipeline
2
  import gradio as gr
 
3
 
4
- pipe = pipeline("translation", model="ejschwartz/decaf-v1-22b")
5
 
6
- demo = gr.Interface.from_pipeline(pipe)
7
- demo.launch()
 
 
 
 
 
 
 
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()