mbarnig commited on
Commit
14b1706
1 Parent(s): c49e437

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -1,12 +1,15 @@
1
  import gradio as gr
2
  import numpy as np
3
  from huggingface_hub import hf_hub_download
 
4
 
5
  REPO_ID_NLLB = "facebook/nllb-200-distilled-600M"
6
  REPO_ID_MARIANNMT_en = "mbarnig/MarianNMT-tatoeba-en-lb"
7
  REPO_ID_MARIANNMT_lb = "mbarnig/MarianNMT-tatoeba-lb-en"
8
  REPO_ID_T5MT5 = "mbarnig/T5-mt5-tatoeba-en-lb"
9
 
 
 
10
  my_title = "🇫🇷 Mir iwwersetzen vun an op Lëtzebuergesch ! 🇬🇧"
11
  my_description = "English-Luxembourgish machine translation (MT) demo based on 3 transforemr models: NLLB, MarianNMT & T5/mt5."
12
 
@@ -21,4 +24,18 @@ TRANSLATION_DIRECTION = [
21
  "lb -> en"
22
  ]
23
 
24
- EXAMPLE = "..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import numpy as np
3
  from huggingface_hub import hf_hub_download
4
+ from transformers import pipeline
5
 
6
  REPO_ID_NLLB = "facebook/nllb-200-distilled-600M"
7
  REPO_ID_MARIANNMT_en = "mbarnig/MarianNMT-tatoeba-en-lb"
8
  REPO_ID_MARIANNMT_lb = "mbarnig/MarianNMT-tatoeba-lb-en"
9
  REPO_ID_T5MT5 = "mbarnig/T5-mt5-tatoeba-en-lb"
10
 
11
+ translator = pipeline("translation", model=REPO_ID_NLLB)
12
+
13
  my_title = "🇫🇷 Mir iwwersetzen vun an op Lëtzebuergesch ! 🇬🇧"
14
  my_description = "English-Luxembourgish machine translation (MT) demo based on 3 transforemr models: NLLB, MarianNMT & T5/mt5."
15
 
 
24
  "lb -> en"
25
  ]
26
 
27
+ EXAMPLE = "..."
28
+
29
+ my_input = gr.Textbox(label="Input")
30
+ my_output = gr.Textbox(label="Translation")
31
+
32
+ def iwwersetz(source_text):
33
+ translation = translator(source_text)
34
+ return translation
35
+
36
+ demo=gr.Interface(
37
+ fn=iwwersetz,
38
+ inputs=my_input,
39
+ outputs=my_output
40
+ )
41
+ demo.launch()