YanshekWoo commited on
Commit
47e97de
1 Parent(s): f67046d

Initial app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -17
app.py CHANGED
@@ -1,20 +1,25 @@
1
- import gradio as gr
2
- from transformers import BertTokenizer, BartForConditionalGeneration
3
-
4
-
5
- tokenizer = BertTokenizer.from_pretrained("HIT-TMG/dialogue-bart-large-chinese")
6
- model = BartForConditionalGeneration.from_pretrained("HIT-TMG/dialogue-bart-large-chinese")
7
-
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- def generate_reponse(history):
10
- history_prefix = "对话历史:"
11
- history = history_prefix + history
12
-
13
- input_ids = tokenizer(history, return_tensors='pt').input_ids
14
- output_ids = model.generate(input_ids)[0]
15
-
16
- return tokenizer.decode(output_ids, skip_special_tokens=True)
17
 
 
18
 
19
- iface = gr.Interface(fn=generate_reponse, inputs="text", outputs="text")
20
- iface.launch()
 
1
+ # import gradio as gr
2
+ # from transformers import BertTokenizer, BartForConditionalGeneration
3
+ #
4
+ #
5
+ # tokenizer = BertTokenizer.from_pretrained("HIT-TMG/dialogue-bart-large-chinese")
6
+ # model = BartForConditionalGeneration.from_pretrained("HIT-TMG/dialogue-bart-large-chinese")
7
+ #
8
+ #
9
+ # def generate_reponse(history):
10
+ # history_prefix = "对话历史:"
11
+ # history = history_prefix + history
12
+ #
13
+ # input_ids = tokenizer(history, return_tensors='pt').input_ids
14
+ # output_ids = model.generate(input_ids)[0]
15
+ #
16
+ # return tokenizer.decode(output_ids, skip_special_tokens=True)
17
+ #
18
+ #
19
+ # iface = gr.Interface(fn=generate_reponse, inputs="text", outputs="text")
20
+ # iface.launch()
21
 
 
 
 
 
 
 
 
 
22
 
23
+ import gradio as gr
24
 
25
+ gr.Interface.load("models/facebook/bart-large-cnn").launch()