jo-valer commited on
Commit
fe0f8b9
·
verified ·
1 Parent(s): 34f9902

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,3 +1,24 @@
1
  import gradio as gr
 
2
 
3
- gr.load("models/jo-valer/nllb-multi").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ examples = [
5
+ "Where is she?",
6
+ "I would like to test this new model for machine translation",
7
+ "All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience..."
8
+ ]
9
+
10
+ generator = pipeline("text2text-generation", model="jo-valer/nllb-multi")
11
+
12
+ def translate(text):
13
+ return generator(text)[0]["generated_text"]
14
+
15
+ interface = gr.Interface(
16
+ fn=translate,
17
+ inputs=gr.Textbox(lines=3, placeholder="Enter English/Italian Text Here...", label="Input text"),
18
+ outputs=gr.Textbox(label="Ladin Translation", show_copy_button=True),
19
+ title="Ladin Machine Translation",
20
+ allow_flagging="never",
21
+ examples=examples,
22
+ cache_examples=True,
23
+ )
24
+ interface.launch()