Commit
·
97ca765
1
Parent(s):
985a670
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,11 @@ import gradio as gr
|
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
|
4 |
tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
|
5 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("./
|
6 |
|
7 |
def text_processing(text):
|
|
|
|
|
8 |
inputs = [text]
|
9 |
|
10 |
# Tokenize and prepare the inputs for model
|
@@ -20,7 +22,7 @@ def text_processing(text):
|
|
20 |
return decoded_output[0]
|
21 |
|
22 |
examples = [
|
23 |
-
["
|
24 |
["都什么年代了 还在抽传统香烟"]
|
25 |
]
|
26 |
|
|
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
|
4 |
tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
|
5 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("./model/")
|
6 |
|
7 |
def text_processing(text):
|
8 |
+
|
9 |
+
text = text + ' ' if text[-2:] != ' ' else text # 在末尾加上空格有利于模型预测
|
10 |
inputs = [text]
|
11 |
|
12 |
# Tokenize and prepare the inputs for model
|
|
|
22 |
return decoded_output[0]
|
23 |
|
24 |
examples = [
|
25 |
+
["我们的价值观是 富强 民主 文明 和谐"],
|
26 |
["都什么年代了 还在抽传统香烟"]
|
27 |
]
|
28 |
|