Spaces:
Sleeping
Sleeping
Force 1GB upload limit with multiple approaches + debug info
Browse files- README.md +2 -0
- packages.txt +2 -0
- startup.sh +23 -0
- streamlit_app.py +24 -0
README.md
CHANGED
|
@@ -6,6 +6,8 @@ colorTo: purple
|
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.28.0
|
| 8 |
app_file: streamlit_app.py
|
|
|
|
|
|
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
---
|
|
|
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.28.0
|
| 8 |
app_file: streamlit_app.py
|
| 9 |
+
startup_duration_timeout: 5m
|
| 10 |
+
suggested_hardware: cpu-basic
|
| 11 |
pinned: false
|
| 12 |
license: mit
|
| 13 |
---
|
packages.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# System packages required for the app
|
| 2 |
+
# This file is read by Hugging Face Spaces to install system dependencies
|
startup.sh
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Set Streamlit configuration for large uploads
|
| 4 |
+
export STREAMLIT_SERVER_MAX_UPLOAD_SIZE=1024
|
| 5 |
+
export STREAMLIT_SERVER_MAX_MESSAGE_SIZE=1024
|
| 6 |
+
|
| 7 |
+
# Create .streamlit directory if it doesn't exist
|
| 8 |
+
mkdir -p ~/.streamlit
|
| 9 |
+
|
| 10 |
+
# Create config file with large upload settings
|
| 11 |
+
cat > ~/.streamlit/config.toml << EOF
|
| 12 |
+
[server]
|
| 13 |
+
maxUploadSize = 1024
|
| 14 |
+
maxMessageSize = 1024
|
| 15 |
+
enableCORS = false
|
| 16 |
+
enableXsrfProtection = false
|
| 17 |
+
|
| 18 |
+
[browser]
|
| 19 |
+
gatherUsageStats = false
|
| 20 |
+
EOF
|
| 21 |
+
|
| 22 |
+
# Run the Streamlit app
|
| 23 |
+
streamlit run streamlit_app.py --server.port=7860 --server.address=0.0.0.0 --server.maxUploadSize=1024
|
streamlit_app.py
CHANGED
|
@@ -19,10 +19,34 @@ from PIL import Image # type: ignore
|
|
| 19 |
|
| 20 |
from main import inspect_and_preview, _count_dots_on_preview
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Configure Streamlit for large file uploads
|
| 23 |
st.set_page_config(page_title="Cell Detector", layout="wide")
|
| 24 |
st.title("Cell Detection")
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# Upload first
|
| 27 |
uploaded = st.file_uploader("Upload .tif/.tiff image", type=["tif", "tiff"])
|
| 28 |
|
|
|
|
| 19 |
|
| 20 |
from main import inspect_and_preview, _count_dots_on_preview
|
| 21 |
|
| 22 |
+
# Force configure upload limits using Streamlit's internal config
|
| 23 |
+
try:
|
| 24 |
+
from streamlit import config
|
| 25 |
+
config._set_option("server.maxUploadSize", 1024, "command_line")
|
| 26 |
+
config._set_option("server.maxMessageSize", 1024, "command_line")
|
| 27 |
+
except:
|
| 28 |
+
pass
|
| 29 |
+
|
| 30 |
+
# Also try setting via runtime config
|
| 31 |
+
try:
|
| 32 |
+
import streamlit.runtime.config as runtime_config
|
| 33 |
+
runtime_config.get_config_options()["server.maxUploadSize"] = 1024
|
| 34 |
+
runtime_config.get_config_options()["server.maxMessageSize"] = 1024
|
| 35 |
+
except:
|
| 36 |
+
pass
|
| 37 |
+
|
| 38 |
# Configure Streamlit for large file uploads
|
| 39 |
st.set_page_config(page_title="Cell Detector", layout="wide")
|
| 40 |
st.title("Cell Detection")
|
| 41 |
|
| 42 |
+
# Display current upload limit for debugging
|
| 43 |
+
try:
|
| 44 |
+
from streamlit import config
|
| 45 |
+
current_limit = config.get_option("server.maxUploadSize")
|
| 46 |
+
st.caption(f"🔧 Current upload limit: {current_limit}MB")
|
| 47 |
+
except:
|
| 48 |
+
st.caption("🔧 Upload limit: Using default configuration")
|
| 49 |
+
|
| 50 |
# Upload first
|
| 51 |
uploaded = st.file_uploader("Upload .tif/.tiff image", type=["tif", "tiff"])
|
| 52 |
|