Spaces:
Runtime error
Runtime error
Fix slider
Browse files
app.py
CHANGED
|
@@ -10,9 +10,10 @@ model = AutoModelForSeq2SeqLM.from_pretrained(CKPT)
|
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained(CKPT)
|
| 11 |
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
def translate(text, src_lang, tgt_lang, max_length=400):
|
|
|
|
|
|
|
|
|
|
| 16 |
translation_pipeline = pipeline(TASK,
|
| 17 |
model=model,
|
| 18 |
tokenizer=tokenizer,
|
|
@@ -30,8 +31,8 @@ gr.Interface(
|
|
| 30 |
gr.inputs.Textbox(label="Text"),
|
| 31 |
gr.inputs.Dropdown(label="Source Language", choices=LANGS),
|
| 32 |
gr.inputs.Dropdown(label="Target Language", choices=LANGS),
|
| 33 |
-
gr.inputs.
|
| 34 |
-
|
| 35 |
],
|
| 36 |
["text"],
|
| 37 |
# examples=examples,
|
|
@@ -39,4 +40,4 @@ gr.Interface(
|
|
| 39 |
cache_examples=False,
|
| 40 |
title=title,
|
| 41 |
description=description
|
| 42 |
-
).launch()
|
|
|
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained(CKPT)
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
| 13 |
def translate(text, src_lang, tgt_lang, max_length=400):
|
| 14 |
+
"""
|
| 15 |
+
Translate the text from source lang to target lang
|
| 16 |
+
"""
|
| 17 |
translation_pipeline = pipeline(TASK,
|
| 18 |
model=model,
|
| 19 |
tokenizer=tokenizer,
|
|
|
|
| 31 |
gr.inputs.Textbox(label="Text"),
|
| 32 |
gr.inputs.Dropdown(label="Source Language", choices=LANGS),
|
| 33 |
gr.inputs.Dropdown(label="Target Language", choices=LANGS),
|
| 34 |
+
gr.inputs.Slider(label="Max Length", minimum=8,
|
| 35 |
+
maximum=512, value=400, step=8)
|
| 36 |
],
|
| 37 |
["text"],
|
| 38 |
# examples=examples,
|
|
|
|
| 40 |
cache_examples=False,
|
| 41 |
title=title,
|
| 42 |
description=description
|
| 43 |
+
).launch()
|