Jordan Myers commited on
Commit
2e7cfe8
1 Parent(s): 413dc1c

blocks test

Browse files
Files changed (1) hide show
  1. app.py +64 -21
app.py CHANGED
@@ -40,24 +40,59 @@ def translate(text, src_lang, tgt_lang, candidates:int):
40
 
41
  return output
42
 
43
- app = gr.Interface(
44
- fn=translate,
45
- inputs=[
46
- gr.components.Textbox(label="Text"),
47
- gr.components.Dropdown(label="Source Language", choices=list(LANG_CODES.keys())),
48
- gr.components.Dropdown(label="Target Language", choices=list(LANG_CODES.keys())),
49
- gr.Slider(label="Number of return sequences", value=3, minimum=1, maximum=12, step=1)
50
- ],
51
- outputs=["text"],
52
- examples=[
53
- ["Welcome to my translation app.", "English", "toki pona", 3],
54
- ["Its not always perfect, but its pretty okay!", "English", "toki pona", 3],
55
- ["ilo pi ante toki ni li pona a!", "toki pona", "English", 3],
56
- ["kijetesantakalu li pona", "toki pona", "English", 3],
57
- ["mi li toki e toki pona", "toki pona", "toki pona", 3]
58
- ],
59
- cache_examples=False,
60
- article="""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  # A simple English / toki pona Neural Machine Translation App!
62
 
63
  ### toki a! 💬
@@ -87,8 +122,16 @@ app = gr.Interface(
87
  the *quality of data* found on Tatoeba directly influences the perfomance of projects like this!
88
 
89
  If you wish to contribute, please simply add high quality and diverse translations to Tatoeba!
90
- """,
91
- title="English / toki pona Translation"
92
- )
 
 
 
 
 
 
 
 
93
 
94
  app.launch()
 
40
 
41
  return output
42
 
43
+ # app = gr.Interface(
44
+ # fn=translate,
45
+ # inputs=[
46
+ # gr.components.Textbox(label="Text"),
47
+ # gr.components.Dropdown(label="Source Language", choices=list(LANG_CODES.keys())),
48
+ # gr.components.Dropdown(label="Target Language", choices=list(LANG_CODES.keys())),
49
+ # gr.Slider(label="Number of return sequences", value=3, minimum=1, maximum=12, step=1)
50
+ # ],
51
+ # outputs=["text"],
52
+ # examples=[
53
+ # ["Welcome to my translation app.", "English", "toki pona", 3],
54
+ # ["Its not always perfect, but its pretty okay!", "English", "toki pona", 3],
55
+ # ["ilo pi ante toki ni li pona a!", "toki pona", "English", 3],
56
+ # ["kijetesantakalu li pona", "toki pona", "English", 3],
57
+ # ["mi li toki e toki pona", "toki pona", "toki pona", 3]
58
+ # ],
59
+ # cache_examples=False,
60
+ # article="""
61
+ # # A simple English / toki pona Neural Machine Translation App!
62
+
63
+ # ### toki a! 💬
64
+
65
+ # This is a simple english to toki pona / toki pona to english neural machine translation app.
66
+
67
+ # Input your text to translate, a source language and target language, and desired number of return sequences!
68
+
69
+ # ### Grammaticality / Regularization
70
+ # English -> English and/or toki pona -> toki pona will result in some form of regularization.
71
+
72
+ # This can approximate grammaticality, but it isn't always the best.
73
+
74
+ # For example, "mi li toki e toki pona" [src: toki pona, tgt: toki pona] will result in ['mi toki e toki pona.', 'mi toki pona.', 'mi toki e toki pona']
75
+ # (Thus, the ungrammatical "li" is dropped)
76
+
77
+ # ### Model and Data
78
+ # This app utilizes a fine-tuned version of Facebook/Meta AI's M2M100 418M param model.
79
+
80
+ # By leveraging the pretrained weights of the massively multilingual M2M100 model,
81
+ # we can jumpstart our transfer learning to accomplish machine translation for toki pona!
82
+
83
+ # The model was fine-tuned on the English/toki pona bitexts found at https://tatoeba.org/
84
+
85
+ # ### This app is a work in progress and obviously not all translations will be perfect.
86
+ # In addition to parameter quantity and the hyper-parameters used while training,
87
+ # the *quality of data* found on Tatoeba directly influences the perfomance of projects like this!
88
+
89
+ # If you wish to contribute, please simply add high quality and diverse translations to Tatoeba!
90
+ # """,
91
+ # title="English / toki pona Translation"
92
+ # )
93
+
94
+ with gr.Blocks() as app:
95
+ gr.Markdown("""
96
  # A simple English / toki pona Neural Machine Translation App!
97
 
98
  ### toki a! 💬
 
122
  the *quality of data* found on Tatoeba directly influences the perfomance of projects like this!
123
 
124
  If you wish to contribute, please simply add high quality and diverse translations to Tatoeba!
125
+ """
126
+ )
127
+ inputs=[
128
+ gr.components.Textbox(label="Text"),
129
+ gr.components.Dropdown(label="Source Language", choices=list(LANG_CODES.keys())),
130
+ gr.components.Dropdown(label="Target Language", choices=list(LANG_CODES.keys())),
131
+ gr.Slider(label="Number of return sequences", value=3, minimum=1, maximum=12, step=1)
132
+ ]
133
+
134
+ translate_btn = gr.Button("Translate! | o ante toki!")
135
+ translate_btn.click(translate, inputs=inputs, outputs=["text"])
136
 
137
  app.launch()