Spaces:
Runtime error
Runtime error
Add MADLAD model
Browse files
app.py
CHANGED
|
@@ -173,14 +173,14 @@ def translate_text(
|
|
| 173 |
#translated_text_Helsinki = translate_with_Helsinki(
|
| 174 |
# chunks, src_lang, tgt_lang, input_max_length, output_max_length)
|
| 175 |
translated_text_m2m100 = translate_with_m2m100(chunks, src_lang, tgt_lang)
|
| 176 |
-
|
| 177 |
translated_text_google_translate = GoogleTranslator(
|
| 178 |
source='auto', target='en').translate(text=text)
|
| 179 |
|
| 180 |
return (
|
| 181 |
#translated_text_Helsinki,
|
| 182 |
translated_text_m2m100,
|
| 183 |
-
|
| 184 |
translated_text_google_translate
|
| 185 |
)
|
| 186 |
|
|
@@ -206,14 +206,14 @@ with gr.Blocks() as demo:
|
|
| 206 |
#)
|
| 207 |
output_text_m2m100 = gr.Textbox(
|
| 208 |
lines=6,
|
| 209 |
-
label="Facebook m2m100 translation model (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
render=False
|
| 211 |
)
|
| 212 |
-
#output_text_MADLAD = gr.Textbox(
|
| 213 |
-
# lines=6,
|
| 214 |
-
# label="Google MADLAD translation model (**small**)",
|
| 215 |
-
# render=False
|
| 216 |
-
#)
|
| 217 |
output_text_google_translate = gr.Textbox(
|
| 218 |
lines=6,
|
| 219 |
label="Google Translate",
|
|
@@ -243,23 +243,23 @@ with gr.Blocks() as demo:
|
|
| 243 |
|
| 244 |
gr.Interface(
|
| 245 |
fn=translate_text,
|
| 246 |
-
inputs=[input_text, src_lang
|
| 247 |
outputs=[
|
| 248 |
#output_text_Helsinki,
|
| 249 |
output_text_m2m100,
|
| 250 |
-
|
| 251 |
output_text_google_translate,
|
| 252 |
],
|
| 253 |
additional_inputs=[sentences_per_chunk,],
|
| 254 |
#clear_btn=None, # Unfortunately, clear_btn also reset the additional inputs. Hence disabling for now.
|
| 255 |
allow_flagging="never",
|
| 256 |
examples=examples,
|
| 257 |
-
cache_examples=
|
| 258 |
)
|
| 259 |
|
| 260 |
with gr.Accordion("Documentation", open=False):
|
| 261 |
gr.Markdown("""
|
| 262 |
-
- Models: serving
|
| 263 |
- Basic: processing of long paragraph / document to be enhanced.
|
| 264 |
- Most examples are copy/pasted from BBC news international web sites.
|
| 265 |
""")
|
|
|
|
| 173 |
#translated_text_Helsinki = translate_with_Helsinki(
|
| 174 |
# chunks, src_lang, tgt_lang, input_max_length, output_max_length)
|
| 175 |
translated_text_m2m100 = translate_with_m2m100(chunks, src_lang, tgt_lang)
|
| 176 |
+
translated_text_MADLAD = translate_with_MADLAD(chunks, tgt_lang)
|
| 177 |
translated_text_google_translate = GoogleTranslator(
|
| 178 |
source='auto', target='en').translate(text=text)
|
| 179 |
|
| 180 |
return (
|
| 181 |
#translated_text_Helsinki,
|
| 182 |
translated_text_m2m100,
|
| 183 |
+
translated_text_MADLAD,
|
| 184 |
translated_text_google_translate
|
| 185 |
)
|
| 186 |
|
|
|
|
| 206 |
#)
|
| 207 |
output_text_m2m100 = gr.Textbox(
|
| 208 |
lines=6,
|
| 209 |
+
label="Facebook m2m100 translation model (1.2B)",
|
| 210 |
+
render=False
|
| 211 |
+
)
|
| 212 |
+
output_text_MADLAD = gr.Textbox(
|
| 213 |
+
lines=6,
|
| 214 |
+
label="Google MADLAD translation model (3B)",
|
| 215 |
render=False
|
| 216 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
output_text_google_translate = gr.Textbox(
|
| 218 |
lines=6,
|
| 219 |
label="Google Translate",
|
|
|
|
| 243 |
|
| 244 |
gr.Interface(
|
| 245 |
fn=translate_text,
|
| 246 |
+
inputs=[input_text, src_lang],
|
| 247 |
outputs=[
|
| 248 |
#output_text_Helsinki,
|
| 249 |
output_text_m2m100,
|
| 250 |
+
output_text_MADLAD,
|
| 251 |
output_text_google_translate,
|
| 252 |
],
|
| 253 |
additional_inputs=[sentences_per_chunk,],
|
| 254 |
#clear_btn=None, # Unfortunately, clear_btn also reset the additional inputs. Hence disabling for now.
|
| 255 |
allow_flagging="never",
|
| 256 |
examples=examples,
|
| 257 |
+
cache_examples=False
|
| 258 |
)
|
| 259 |
|
| 260 |
with gr.Accordion("Documentation", open=False):
|
| 261 |
gr.Markdown("""
|
| 262 |
+
- Models: serving Facebook M2M100 and Google MADLAD models.
|
| 263 |
- Basic: processing of long paragraph / document to be enhanced.
|
| 264 |
- Most examples are copy/pasted from BBC news international web sites.
|
| 265 |
""")
|