Update app.py
Browse files
app.py
CHANGED
@@ -18,11 +18,11 @@ translation_models = {
|
|
18 |
# Initialize summarization pipelines with specified models
|
19 |
summarization_models = {
|
20 |
'Scientific': "facebook/bart-large-cnn",
|
21 |
-
'Literature': "
|
22 |
}
|
23 |
|
24 |
# Initialize tokenizer
|
25 |
-
tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-cnn")
|
26 |
|
27 |
# Initialize summarization pipelines
|
28 |
summarizers = {model: pipeline("summarization", model=model) for model in summarization_models.values()}
|
@@ -60,7 +60,7 @@ def summarize_text(text, model):
|
|
60 |
summaries = []
|
61 |
for chunk in chunks:
|
62 |
try:
|
63 |
-
summary = summarizers[model](chunk, max_length=150, min_length=
|
64 |
summaries.append(summary)
|
65 |
except Exception as e:
|
66 |
print(f"Error summarizing chunk: {chunk}\nError: {e}")
|
@@ -142,3 +142,4 @@ iface.launch()
|
|
142 |
|
143 |
|
144 |
|
|
|
|
18 |
# Initialize summarization pipelines with specified models
|
19 |
summarization_models = {
|
20 |
'Scientific': "facebook/bart-large-cnn",
|
21 |
+
'Literature': "allenai/scibert_scivocab_cased"
|
22 |
}
|
23 |
|
24 |
# Initialize tokenizer
|
25 |
+
tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-cnn")
|
26 |
|
27 |
# Initialize summarization pipelines
|
28 |
summarizers = {model: pipeline("summarization", model=model) for model in summarization_models.values()}
|
|
|
60 |
summaries = []
|
61 |
for chunk in chunks:
|
62 |
try:
|
63 |
+
summary = summarizers[model](chunk, max_length=150, min_length=20, do_sample=False)[0]['summary_text']
|
64 |
summaries.append(summary)
|
65 |
except Exception as e:
|
66 |
print(f"Error summarizing chunk: {chunk}\nError: {e}")
|
|
|
142 |
|
143 |
|
144 |
|
145 |
+
|