Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ tokenizer = T5Tokenizer.from_pretrained(model_name)
|
|
9 |
# 翻译功能
|
10 |
def translate_text(input_text):
|
11 |
# 使用 T5 模型进行翻译
|
12 |
-
inputs = tokenizer.encode("
|
13 |
outputs = model.generate(inputs, max_length=1024, num_beams=4, early_stopping=True)
|
14 |
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
15 |
|
|
|
9 |
# 翻译功能
|
10 |
def translate_text(input_text):
|
11 |
# 使用 T5 模型进行翻译
|
12 |
+
inputs = tokenizer.encode("翻译成中文: " + input_text, return_tensors="pt", max_length=512, truncation=True)
|
13 |
outputs = model.generate(inputs, max_length=1024, num_beams=4, early_stopping=True)
|
14 |
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
15 |
|