luigi12345 commited on
Commit
74d3d9b
β€’
1 Parent(s): c73c262
Files changed (1) hide show
  1. app.py +6 -56
app.py CHANGED
@@ -208,8 +208,9 @@ def main():
208
 
209
  st.markdown("### πŸ“Š Processing Stats")
210
  if 'processed_count' in st.session_state:
211
- st.metric("Images Processed", st.session_state.processed_count)
212
-
 
213
  st.markdown("---")
214
 
215
  # Add batch size limit
@@ -256,59 +257,8 @@ def main():
256
  results = process_batch(model, images_data, progress_bar)
257
 
258
  if results:
259
- # Add summary statistics
260
- st.markdown("### πŸ“Š Summary Statistics")
261
- glaucoma_count = sum(1 for r in results if r['diagnosis'] == 'Glaucoma')
262
- normal_count = len(results) - glaucoma_count
263
-
264
- cols = st.columns(4)
265
- with cols[0]:
266
- st.metric("Total Processed", len(results))
267
- with cols[1]:
268
- st.metric("Glaucoma Detected", glaucoma_count)
269
- with cols[2]:
270
- st.metric("Normal", normal_count)
271
- with cols[3]:
272
- avg_conf = sum(r['confidence'] for r in results) / len(results)
273
- st.metric("Avg Confidence", f"{avg_conf:.1f}%")
274
-
275
- # Add filter options
276
- st.markdown("### πŸ” Filter Results")
277
- show_only = st.multiselect(
278
- "Show cases:",
279
- ["All", "Glaucoma", "Normal"],
280
- default=["All"]
281
- )
282
-
283
- # Filter results based on selection
284
- filtered_results = results
285
- if "All" not in show_only:
286
- filtered_results = [
287
- r for r in results
288
- if (r['diagnosis'] == 'Glaucoma' and 'Glaucoma' in show_only) or
289
- (r['diagnosis'] == 'Normal' and 'Normal' in show_only)
290
- ]
291
-
292
- # Display filtered results
293
- for result in filtered_results:
294
- with st.expander(
295
- f"πŸ“‹ {result['file_name']} - {result['diagnosis']} ({result['confidence']:.1f}% confidence)"
296
- ):
297
- cols = st.columns(3)
298
- with cols[0]:
299
- st.image(result['processed_image'], caption="Segmentation", use_column_width=True)
300
- with cols[1]:
301
- st.image(result['cropped_image'], caption="ROI", use_column_width=True)
302
- with cols[2]:
303
- st.write("### Metrics")
304
- st.write(f"Diagnosis: {result['diagnosis']}")
305
- st.write(f"Confidence: {result['confidence']:.1f}%")
306
- st.write(f"VCDR: {result['vcdr']:.3f}")
307
- st.write(f"Cup Confidence: {result['cup_conf']:.1f}%")
308
- st.write(f"Disc Confidence: {result['disc_conf']:.1f}%")
309
-
310
- # Update session state
311
- st.session_state.processed_count += len(results)
312
 
313
  # Add export options
314
  st.markdown("### πŸ“₯ Export Options")
@@ -316,7 +266,7 @@ def main():
316
  with col1:
317
  st.download_button(
318
  label="πŸ“₯ Download All Results (ZIP)",
319
- data=zip_data,
320
  file_name=f"glaucoma_screening_{datetime.now().strftime('%Y%m%d_%H%M%S')}.zip",
321
  mime="application/zip"
322
  )
 
208
 
209
  st.markdown("### πŸ“Š Processing Stats")
210
  if 'processed_count' in st.session_state:
211
+ # Replace st.metric with regular markdown
212
+ st.markdown(f"**Images Processed:** {st.session_state.processed_count}")
213
+
214
  st.markdown("---")
215
 
216
  # Add batch size limit
 
257
  results = process_batch(model, images_data, progress_bar)
258
 
259
  if results:
260
+ # Generate ZIP with results
261
+ zip_data = save_results(results, original_images)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
 
263
  # Add export options
264
  st.markdown("### πŸ“₯ Export Options")
 
266
  with col1:
267
  st.download_button(
268
  label="πŸ“₯ Download All Results (ZIP)",
269
+ data=zip_data, # Now zip_data is properly defined
270
  file_name=f"glaucoma_screening_{datetime.now().strftime('%Y%m%d_%H%M%S')}.zip",
271
  mime="application/zip"
272
  )