Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,8 @@ import nltk
|
|
11 |
import pyclip
|
12 |
import pytesseract
|
13 |
from nltk.tokenize import sent_tokenize
|
14 |
-
from transformers import MarianMTModel, MarianTokenizer
|
|
|
15 |
|
16 |
nltk.download('punkt')
|
17 |
|
@@ -33,8 +34,11 @@ def model_choice(src, trg):
|
|
33 |
# https://huggingface.co/unicamp-dl/translation-en-pt-t5
|
34 |
model_name = f"unicamp-dl/translation-{src}-{trg}-t5" # 模型名称
|
35 |
|
36 |
-
tokenizer = MarianTokenizer.from_pretrained(model_name) # 分词器
|
37 |
-
model = MarianMTModel.from_pretrained(model_name) # 模型
|
|
|
|
|
|
|
38 |
|
39 |
return tokenizer, model
|
40 |
|
|
|
11 |
import pyclip
|
12 |
import pytesseract
|
13 |
from nltk.tokenize import sent_tokenize
|
14 |
+
#from transformers import MarianMTModel, MarianTokenizer
|
15 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
16 |
|
17 |
nltk.download('punkt')
|
18 |
|
|
|
34 |
# https://huggingface.co/unicamp-dl/translation-en-pt-t5
|
35 |
model_name = f"unicamp-dl/translation-{src}-{trg}-t5" # 模型名称
|
36 |
|
37 |
+
#tokenizer = MarianTokenizer.from_pretrained(model_name) # 分词器
|
38 |
+
#model = MarianMTModel.from_pretrained(model_name) # 模型
|
39 |
+
|
40 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
41 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
42 |
|
43 |
return tokenizer, model
|
44 |
|