masszhou commited on
Commit
d969553
·
1 Parent(s): 97b5bfb

hello world

Browse files
Files changed (2) hide show
  1. app.py +19 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import pipeline
4
+
5
+ pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")
6
+
7
+ def predict(text):
8
+ return pipe(text)[0]["translation_text"]
9
+
10
+ title = "English to French Translation"
11
+
12
+ iface = gr.Interface(
13
+ fn=predict,
14
+ inputs=[gr.Textbox(label="text", lines=3)],
15
+ outputs='text',
16
+ title=title,
17
+ )
18
+
19
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ sentencepiece
3
+ transformers