minnehwg commited on
Commit
12c5b62
·
verified ·
1 Parent(s): 460c4fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -5,12 +5,12 @@ from util import pipeline
5
  import gradio as gr
6
  cp_aug = 'minnehwg/finetune-newwiki-summarization-ver-augmented2'
7
 
8
- def get_model():
9
- checkpoint = cp_aug
10
  tokenizer, model = load_model(checkpoint)
11
  return tokenizer, model
12
 
13
- tokenizer, model = get_model()
14
 
15
  # demo = gr.Interface(
16
  # fn=generate_summary,
@@ -20,16 +20,21 @@ tokenizer, model = get_model()
20
  # description="Enter the URL to summarize and click 'Submit' to generate the summary."
21
  # )
22
 
23
- def generate(text):
24
- return pipeline(text, model, tokenizer)
 
25
 
26
- with gr.Blocks() as demo:
27
- gr.Markdown("Start typing below and then click **Run** to see the output.")
28
- with gr.Row():
29
- inp = gr.Textbox(placeholder="Enter your URL")
30
- out = gr.Textbox()
31
- btn = gr.Button("Run")
32
- btn.click(fn=generate, inputs=inp, outputs=out)
 
33
 
 
34
  demo.launch()
35
 
 
 
 
5
  import gradio as gr
6
  cp_aug = 'minnehwg/finetune-newwiki-summarization-ver-augmented2'
7
 
8
+ def get_model(cp):
9
+ checkpoint = cp
10
  tokenizer, model = load_model(checkpoint)
11
  return tokenizer, model
12
 
13
+ tokenizer, model = get_model(cp_aug)
14
 
15
  # demo = gr.Interface(
16
  # fn=generate_summary,
 
20
  # description="Enter the URL to summarize and click 'Submit' to generate the summary."
21
  # )
22
 
23
+ def generate_summary(url):
24
+ summary = pipeline(url, model, tokenizer)
25
+ return summary
26
 
27
+ # Tạo interface Gradio với hàm generate_summary
28
+ demo = gr.Interface(
29
+ fn=generate_summary,
30
+ inputs=gr.Textbox(lines=2, placeholder="Enter your URL..."),
31
+ outputs=gr.Textbox(label="Generated Text"),
32
+ title="Chào mừng đến với hệ thống tóm tắt của Minne >.<",
33
+ description="Enter the URL to summarize and click 'Submit' to generate the summary."
34
+ )
35
 
36
+ # Chạy interface
37
  demo.launch()
38
 
39
+
40
+