Spaces:
Runtime error
Runtime error
quyip
commited on
Commit
·
090f2d4
1
Parent(s):
e2ec8e0
fix
Browse files- utils/summary_utils.py +6 -8
utils/summary_utils.py
CHANGED
@@ -6,6 +6,7 @@ from transformers import pipeline
|
|
6 |
from utils.tag_utils import filter_tags
|
7 |
|
8 |
AiSummaryVersion = 2
|
|
|
9 |
summarization_pipeline = pipeline("summarization", model="csebuetnlp/mT5_multilingual_XLSum")
|
10 |
en_translation_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
|
11 |
classification_pipe = pipeline("text-classification", model="Yueh-Huan/news-category-classification-distilbert")
|
@@ -67,14 +68,11 @@ def get_tags(text: str):
|
|
67 |
if text is None:
|
68 |
return []
|
69 |
try:
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
tags = [tag.strip() for tag in tags]
|
76 |
-
tags = [tag for tag in tags if len(tag) > 2 and len(tag.split(' ')) == 1]
|
77 |
-
return tags
|
78 |
except:
|
79 |
return []
|
80 |
|
|
|
6 |
from utils.tag_utils import filter_tags
|
7 |
|
8 |
AiSummaryVersion = 2
|
9 |
+
MinTagScore = 0.7
|
10 |
summarization_pipeline = pipeline("summarization", model="csebuetnlp/mT5_multilingual_XLSum")
|
11 |
en_translation_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
|
12 |
classification_pipe = pipeline("text-classification", model="Yueh-Huan/news-category-classification-distilbert")
|
|
|
68 |
if text is None:
|
69 |
return []
|
70 |
try:
|
71 |
+
tags1 = [tag['label'] for tag in tag_gen_pipe_1(text) if tag['score'] >= MinTagScore]
|
72 |
+
tags2 = [tag['label'] for tag in tag_gen_pipe_2(text) if tag['score'] >= MinTagScore]
|
73 |
+
tags3 = [tag['label'] for tag in tag_gen_pipe_3(text) if tag['score'] >= MinTagScore]
|
74 |
+
print(tags1, tags2, tags3)
|
75 |
+
return tags1 + tags2 + tags3
|
|
|
|
|
|
|
76 |
except:
|
77 |
return []
|
78 |
|