TedYeh commited on
Commit
abbaadb
1 Parent(s): 0cbca3d

update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -1,6 +1,14 @@
1
  import gradio as gr
2
- def cged_correction(sentence):
3
- return sentence
 
 
 
 
 
 
 
 
4
 
5
  with gr.Blocks() as demo:
6
  #設定輸入元件
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer, T5ForConditionalGeneration
3
+ tokenizer = AutoTokenizer.from_pretrained("CodeTed/traditional_CSC_t5")
4
+ model = T5ForConditionalGeneration.from_pretrained("CodeTed/traditional_CSC_t5")
5
+
6
+
7
+ def cged_correction(sentence = '糾正句子裡的錯字: 為了降低少子化,政府可以堆動獎勵生育的政策。'):
8
+ input_ids = tokenizer(sentence, return_tensors="pt").input_ids
9
+ outputs = model.generate(input_ids, max_length=256)
10
+ edited_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
11
+ return edited_text
12
 
13
  with gr.Blocks() as demo:
14
  #設定輸入元件