Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -235,34 +235,7 @@ def main():
|
|
| 235 |
# Individual Summaries Section
|
| 236 |
st.header("📝 Individual Paper Summaries")
|
| 237 |
|
| 238 |
-
|
| 239 |
-
try:
|
| 240 |
-
with st.spinner("Generating summaries..."):
|
| 241 |
-
# Load summarization model
|
| 242 |
-
model, tokenizer = load_model("summarize")
|
| 243 |
-
|
| 244 |
-
# Process abstracts with real-time updates
|
| 245 |
-
summaries = []
|
| 246 |
-
progress_bar = st.progress(0)
|
| 247 |
-
summary_display = st.empty()
|
| 248 |
-
|
| 249 |
-
for i, (_, row) in enumerate(df.iterrows()):
|
| 250 |
-
summary = generate_summary(row['Abstract'], model, tokenizer)
|
| 251 |
-
summaries.append(summary)
|
| 252 |
-
|
| 253 |
-
# Update progress and show current summary
|
| 254 |
-
progress = (i + 1) / len(df)
|
| 255 |
-
progress_bar.progress(progress)
|
| 256 |
-
summary_display.write(f"Processing paper {i+1}/{len(df)}:\n{row['Article Title']}")
|
| 257 |
-
|
| 258 |
-
st.session_state.summaries = summaries
|
| 259 |
-
|
| 260 |
-
# Cleanup first model
|
| 261 |
-
cleanup_model(model, tokenizer)
|
| 262 |
-
|
| 263 |
-
except Exception as e:
|
| 264 |
-
st.error(f"Error generating summaries: {str(e)}")
|
| 265 |
-
|
| 266 |
# Display summaries with improved sorting
|
| 267 |
if st.session_state.summaries is not None:
|
| 268 |
col1, col2 = st.columns(2)
|
|
@@ -278,24 +251,65 @@ def main():
|
|
| 278 |
display_df['Publication Year'] = display_df['Publication Year'].astype(int)
|
| 279 |
sorted_df = display_df.sort_values(by=sort_column, ascending=ascending)
|
| 280 |
|
| 281 |
-
# Apply custom
|
| 282 |
st.markdown("""
|
| 283 |
<style>
|
| 284 |
-
.
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
}
|
| 287 |
-
.
|
| 288 |
-
|
| 289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
}
|
| 291 |
</style>
|
| 292 |
""", unsafe_allow_html=True)
|
| 293 |
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
# Question-focused Summary Section (only if question provided)
|
| 301 |
if question.strip():
|
|
|
|
| 235 |
# Individual Summaries Section
|
| 236 |
st.header("📝 Individual Paper Summaries")
|
| 237 |
|
| 238 |
+
# Replace the display section in main() with this:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
# Display summaries with improved sorting
|
| 240 |
if st.session_state.summaries is not None:
|
| 241 |
col1, col2 = st.columns(2)
|
|
|
|
| 251 |
display_df['Publication Year'] = display_df['Publication Year'].astype(int)
|
| 252 |
sorted_df = display_df.sort_values(by=sort_column, ascending=ascending)
|
| 253 |
|
| 254 |
+
# Apply custom styling
|
| 255 |
st.markdown("""
|
| 256 |
<style>
|
| 257 |
+
.paper-info {
|
| 258 |
+
border: 1px solid #ddd;
|
| 259 |
+
padding: 15px;
|
| 260 |
+
margin-bottom: 20px;
|
| 261 |
+
border-radius: 5px;
|
| 262 |
+
}
|
| 263 |
+
.paper-section {
|
| 264 |
+
margin-bottom: 10px;
|
| 265 |
+
}
|
| 266 |
+
.section-header {
|
| 267 |
+
font-weight: bold;
|
| 268 |
+
color: #555;
|
| 269 |
+
margin-bottom: 8px;
|
| 270 |
}
|
| 271 |
+
.paper-title {
|
| 272 |
+
margin-top: 5px;
|
| 273 |
+
margin-bottom: 10px;
|
| 274 |
+
}
|
| 275 |
+
.paper-meta {
|
| 276 |
+
font-size: 0.9em;
|
| 277 |
+
color: #666;
|
| 278 |
+
}
|
| 279 |
+
.doi-link {
|
| 280 |
+
color: #0366d6;
|
| 281 |
}
|
| 282 |
</style>
|
| 283 |
""", unsafe_allow_html=True)
|
| 284 |
|
| 285 |
+
# Display papers in side-by-side layout
|
| 286 |
+
for _, row in sorted_df.iterrows():
|
| 287 |
+
paper_info_cols = st.columns([1, 1])
|
| 288 |
+
|
| 289 |
+
with paper_info_cols[0]: # PAPER column
|
| 290 |
+
st.markdown('<div class="paper-section"><div class="section-header">PAPER</div>', unsafe_allow_html=True)
|
| 291 |
+
st.markdown(f"""
|
| 292 |
+
<div class="paper-info">
|
| 293 |
+
<div class="paper-title">{row['Article Title']}</div>
|
| 294 |
+
<div class="paper-meta">
|
| 295 |
+
<strong>Authors:</strong> {row['Authors']}<br>
|
| 296 |
+
<strong>Source:</strong> {row['Source Title']}<br>
|
| 297 |
+
<strong>Publication Year:</strong> {row['Publication Year']}<br>
|
| 298 |
+
<strong>DOI:</strong> {row['DOI'] if pd.notna(row['DOI']) else 'None'}
|
| 299 |
+
</div>
|
| 300 |
+
</div>
|
| 301 |
+
""", unsafe_allow_html=True)
|
| 302 |
+
|
| 303 |
+
with paper_info_cols[1]: # SUMMARY column
|
| 304 |
+
st.markdown('<div class="paper-section"><div class="section-header">SUMMARY</div>', unsafe_allow_html=True)
|
| 305 |
+
st.markdown(f"""
|
| 306 |
+
<div class="paper-info">
|
| 307 |
+
{row['Summary']}
|
| 308 |
+
</div>
|
| 309 |
+
""", unsafe_allow_html=True)
|
| 310 |
+
|
| 311 |
+
# Add some spacing between papers
|
| 312 |
+
st.markdown("<div style='margin-bottom: 20px;'></div>", unsafe_allow_html=True)
|
| 313 |
|
| 314 |
# Question-focused Summary Section (only if question provided)
|
| 315 |
if question.strip():
|