pr28416 commited on
Commit
2ab4518
Β·
1 Parent(s): d1f1b61

Add upload debugging and backup options for large files

Browse files
Files changed (1) hide show
  1. streamlit_app.py +34 -7
streamlit_app.py CHANGED
@@ -54,19 +54,46 @@ except:
54
  st.caption("πŸ”§ Upload limit: Using default configuration")
55
 
56
  # Upload first with better error handling
 
57
  uploaded = st.file_uploader(
58
- "Upload .tif/.tiff image",
59
  type=["tif", "tiff"],
60
- help="Large files (>500MB) may take several minutes to upload. Please be patient."
61
  )
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  # Show upload progress for large files
64
  if uploaded is not None:
65
- file_size_mb = len(uploaded.getvalue()) / (1024 * 1024)
66
- if file_size_mb > 200:
67
- st.info(f"πŸ“ Large file detected ({file_size_mb:.1f}MB). Processing may take a few minutes...")
68
- elif file_size_mb > 500:
69
- st.warning(f"⚠️ Very large file ({file_size_mb:.1f}MB). Upload and processing will take time. Please keep the browser tab open.")
 
 
 
 
 
 
 
 
 
 
 
70
 
71
 
72
  # Helper to render settings panel next to slice preview
 
54
  st.caption("πŸ”§ Upload limit: Using default configuration")
55
 
56
  # Upload first with better error handling
57
+ st.markdown("### πŸ“ File Upload")
58
  uploaded = st.file_uploader(
59
+ "Upload .tif/.tiff image",
60
  type=["tif", "tiff"],
61
+ help="Large files (>500MB) may take several minutes to upload. Please be patient.",
62
  )
63
 
64
+ # Show alternative for very large files
65
+ col1, col2 = st.columns([3, 1])
66
+ with col2:
67
+ with st.expander("πŸ’» Large files?"):
68
+ st.markdown("""
69
+ **Having upload issues?**
70
+
71
+ For files >500MB, consider:
72
+ 1. [Run locally](https://github.com/pr28416/cell-detection)
73
+ 2. Try a smaller test file first
74
+ 3. Use stable internet connection
75
+ """)
76
+ with col1:
77
+ pass # File uploader is above
78
+
79
  # Show upload progress for large files
80
  if uploaded is not None:
81
+ try:
82
+ file_size_mb = len(uploaded.getvalue()) / (1024 * 1024)
83
+ st.success(f"βœ… Upload successful! File size: {file_size_mb:.1f}MB")
84
+
85
+ if file_size_mb > 200:
86
+ st.info(
87
+ f"πŸ“ Large file detected ({file_size_mb:.1f}MB). Processing may take a few minutes..."
88
+ )
89
+ elif file_size_mb > 500:
90
+ st.warning(
91
+ f"⚠️ Very large file ({file_size_mb:.1f}MB). Upload and processing will take time. Please keep the browser tab open."
92
+ )
93
+ except Exception as e:
94
+ st.error(f"❌ Upload error: {str(e)}")
95
+ st.error("Please try a smaller file or refresh the page and try again.")
96
+ uploaded = None
97
 
98
 
99
  # Helper to render settings panel next to slice preview