Spaces:
Sleeping
Sleeping
Add upload debugging and backup options for large files
Browse files- 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 |
-
|
| 66 |
-
|
| 67 |
-
st.
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|