Spaces:
Running
on
Zero
Running
on
Zero
fixes for nltk and transformers updates
#6
by
davanstrien
HF staff
- opened
app.py
CHANGED
@@ -6,7 +6,7 @@ import platform
|
|
6 |
import torch
|
7 |
import nltk
|
8 |
|
9 |
-
nltk.download("
|
10 |
|
11 |
REMOVED_TARGET_LANGUAGES = {"Ligurian", "Lombard", "Sicilian"}
|
12 |
|
@@ -55,7 +55,7 @@ def translate(text: str, src_lang: str, tgt_lang: str):
|
|
55 |
)
|
56 |
translated_chunk = model.generate(
|
57 |
input_ids=torch.tensor([input_tokens]).to(device),
|
58 |
-
forced_bos_token_id=tokenizer.
|
59 |
max_length=len(input_tokens) + 50,
|
60 |
num_return_sequences=1,
|
61 |
)
|
@@ -93,4 +93,4 @@ with gr.Blocks() as demo:
|
|
93 |
inputs=[input_text, src_lang, target_lang],
|
94 |
outputs=output,
|
95 |
)
|
96 |
-
demo.launch()
|
|
|
6 |
import torch
|
7 |
import nltk
|
8 |
|
9 |
+
nltk.download("punkt_tab")
|
10 |
|
11 |
REMOVED_TARGET_LANGUAGES = {"Ligurian", "Lombard", "Sicilian"}
|
12 |
|
|
|
55 |
)
|
56 |
translated_chunk = model.generate(
|
57 |
input_ids=torch.tensor([input_tokens]).to(device),
|
58 |
+
forced_bos_token_id=tokenizer.convert_tokens_to_ids(code_mapping[tgt_lang]),
|
59 |
max_length=len(input_tokens) + 50,
|
60 |
num_return_sequences=1,
|
61 |
)
|
|
|
93 |
inputs=[input_text, src_lang, target_lang],
|
94 |
outputs=output,
|
95 |
)
|
96 |
+
demo.launch()
|