Spaces:
Runtime error
Runtime error
gabrielwithhappy
commited on
Commit
•
e187645
1
Parent(s):
c3bcc3d
fix null article exception
Browse files
app.py
CHANGED
@@ -17,12 +17,19 @@ def get_summary(input_text):
|
|
17 |
summary_model = BartForConditionalGeneration.from_pretrained("ainize/kobart-news")
|
18 |
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
19 |
summary_text_ids = summary_model.generate(
|
20 |
-
|
21 |
-
|
22 |
-
max_length=
|
23 |
-
min_length=
|
24 |
-
num_beams=
|
25 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return tokenizer.decode(summary_text_ids[0], skip_special_tokens=True)
|
27 |
|
28 |
|
@@ -60,7 +67,8 @@ class news_collector:
|
|
60 |
|
61 |
for news_url in news_links:
|
62 |
article = self.get_new_parser(news_url)
|
63 |
-
|
|
|
64 |
|
65 |
|
66 |
|
@@ -97,8 +105,8 @@ with gr.Blocks(theme='pseudolab/huggingface-korea-theme') as demo:
|
|
97 |
|
98 |
with gr.Tab("데모"):
|
99 |
Link_TXT = gr.Textbox(label="뉴스 내용", placeholder = "뉴스 기사 내용을 입력하세요.")
|
100 |
-
|
101 |
-
gr.load("models/Hyeonseo/ko-finance_news_classifier",
|
102 |
inputs = Link_TXT)
|
103 |
Link_URL = gr.Textbox(label="뉴스 URL")
|
104 |
|
|
|
17 |
summary_model = BartForConditionalGeneration.from_pretrained("ainize/kobart-news")
|
18 |
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
19 |
summary_text_ids = summary_model.generate(
|
20 |
+
length_penalty=0,
|
21 |
+
top_p=0.9,
|
22 |
+
max_length=128,
|
23 |
+
min_length=12,
|
24 |
+
num_beams=4,
|
25 |
)
|
26 |
+
# "task_specific_params": {
|
27 |
+
# "summarization": {
|
28 |
+
# "length_penalty": 1.0,
|
29 |
+
# "max_length": 128,
|
30 |
+
# "min_length": 12,
|
31 |
+
# "num_beams": 4
|
32 |
+
# }
|
33 |
return tokenizer.decode(summary_text_ids[0], skip_special_tokens=True)
|
34 |
|
35 |
|
|
|
67 |
|
68 |
for news_url in news_links:
|
69 |
article = self.get_new_parser(news_url)
|
70 |
+
if article.text:
|
71 |
+
self.examples_text.append([get_summary(article.text[:1500]), news_url])
|
72 |
|
73 |
|
74 |
|
|
|
105 |
|
106 |
with gr.Tab("데모"):
|
107 |
Link_TXT = gr.Textbox(label="뉴스 내용", placeholder = "뉴스 기사 내용을 입력하세요.")
|
108 |
+
gr.load("models/gabrielyang/finance_news_classifier-KR_v7",
|
109 |
+
# gr.load("models/Hyeonseo/ko-finance_news_classifier",
|
110 |
inputs = Link_TXT)
|
111 |
Link_URL = gr.Textbox(label="뉴스 URL")
|
112 |
|