Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
import spaces
|
|
|
|
| 4 |
|
| 5 |
# 支持的语言选项
|
| 6 |
LANGUAGES = {
|
|
@@ -144,7 +145,8 @@ def translate_text(text, source_lang, target_lang):
|
|
| 144 |
)
|
| 145 |
translated_chunk = model.generate(
|
| 146 |
input_ids=torch.tensor([input_tokens]).to(device),
|
| 147 |
-
max_length=
|
|
|
|
| 148 |
num_return_sequences=1,
|
| 149 |
)
|
| 150 |
full_output = tokenizer.decode(translated_chunk[0], skip_special_tokens=True)
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
import spaces
|
| 4 |
+
import torch
|
| 5 |
|
| 6 |
# 支持的语言选项
|
| 7 |
LANGUAGES = {
|
|
|
|
| 145 |
)
|
| 146 |
translated_chunk = model.generate(
|
| 147 |
input_ids=torch.tensor([input_tokens]).to(device),
|
| 148 |
+
max_length=512,
|
| 149 |
+
num_beams=4,
|
| 150 |
num_return_sequences=1,
|
| 151 |
)
|
| 152 |
full_output = tokenizer.decode(translated_chunk[0], skip_special_tokens=True)
|