Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 =
|
| 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
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 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 |
+
|