File size: 1,161 Bytes
c510d8a
8863a3f
 
d6a85e3
 
c510d8a
 
12c5b62
 
c510d8a
 
 
12c5b62
c510d8a
3287afb
 
 
 
 
 
 
 
12c5b62
 
 
3287afb
12c5b62
 
 
 
 
 
 
 
d6a85e3
12c5b62
758e43f
d6a85e3
12c5b62
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

from util import load_model
from util import pipeline

import gradio as gr
cp_aug = 'minnehwg/finetune-newwiki-summarization-ver-augmented2'

def get_model(cp):
    checkpoint = cp
    tokenizer, model = load_model(checkpoint)
    return tokenizer, model

tokenizer, model = get_model(cp_aug)

# demo = gr.Interface(
#     fn=generate_summary,
#     inputs=gr.Textbox(lines=2, placeholder="Enter your URL..."),
#     outputs=gr.Textbox(label="Generated Text"),
#     title="Chào mừng đến với hệ thống tóm tắt của Minne >.<",
#     description="Enter the URL to summarize and click 'Submit' to generate the summary."
# )

def generate_summary(url):
    summary = pipeline(url, model, tokenizer)
    return summary

# Tạo interface Gradio với hàm generate_summary
demo = gr.Interface(
    fn=generate_summary,
    inputs=gr.Textbox(lines=2, placeholder="Enter your URL..."),
    outputs=gr.Textbox(label="Generated Text"),
    title="Chào mừng đến với hệ thống tóm tắt của Minne >.<",
    description="Enter the URL to summarize and click 'Submit' to generate the summary."
)

# Chạy interface
demo.launch(share=True)