Jellyfish042 commited on
Commit
97ca765
1 Parent(s): 985a670

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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("./checkpoint-15000/")
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