cbensimon HF Staff commited on
Commit
9ab1399
·
1 Parent(s): 710b9e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1,10 +1,13 @@
1
  import gradio as gr
2
  import torch
 
3
 
4
  print(f'{torch.cuda.is_available()=}')
5
 
6
- def greet(name):
7
- return "Hello " + name + "!!"
8
 
9
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
10
  iface.launch()
 
1
  import gradio as gr
2
  import torch
3
+ from transformers import pipeline
4
 
5
  print(f'{torch.cuda.is_available()=}')
6
 
7
+ pipe = pipeline('translation_en_to_fr', device=0)
 
8
 
9
+ def translate(text):
10
+ return pipe(text)[0]['translation_text']
11
+
12
+ iface = gr.Interface(fn=translate, inputs="text", outputs="text")
13
  iface.launch()