Spaces:
Sleeping
Sleeping
Michael Rey
commited on
Commit
·
3ff5d42
1
Parent(s):
4efcfc7
fixed issuesg
Browse files- .streamlit/config.toml +2 -2
- src/streamlit_app.py +8 -9
.streamlit/config.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
headless = true
|
| 3 |
port = 7860
|
| 4 |
enableCORS = false
|
| 5 |
-
enableXsrfProtection = false
|
| 6 |
|
| 7 |
[global]
|
| 8 |
-
disableUsageStats = true
|
|
|
|
|
|
| 2 |
headless = true
|
| 3 |
port = 7860
|
| 4 |
enableCORS = false
|
|
|
|
| 5 |
|
| 6 |
[global]
|
| 7 |
+
disableUsageStats = true
|
| 8 |
+
disableWatchdogWarning = true
|
src/streamlit_app.py
CHANGED
|
@@ -1,27 +1,26 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
os.environ["STREAMLIT_HOME"] = "/tmp"
|
| 6 |
-
os.environ["XDG_CONFIG_HOME"] = "/tmp"
|
| 7 |
-
os.environ["XDG_CACHE_HOME"] = "/tmp"
|
| 8 |
-
|
| 9 |
-
# Force use of internal config (avoids /.streamlit access)
|
| 10 |
os.environ["STREAMLIT_CONFIG_FILE"] = os.path.abspath(
|
| 11 |
-
os.path.join(os.path.dirname(__file__), "
|
| 12 |
)
|
| 13 |
|
| 14 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
| 16 |
|
| 17 |
import streamlit as st
|
| 18 |
import torch
|
| 19 |
import torchvision.transforms as transforms
|
| 20 |
from PIL import Image
|
| 21 |
-
|
| 22 |
from resnet_model import MonkeyResNet
|
| 23 |
from data_loader import get_data_loaders
|
| 24 |
|
|
|
|
| 25 |
# Ensure the parent directory is in the system path for module imports
|
| 26 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
| 27 |
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
|
| 4 |
+
# 1. Tell Streamlit to read config from our root folder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
os.environ["STREAMLIT_CONFIG_FILE"] = os.path.abspath(
|
| 6 |
+
os.path.join(os.path.dirname(__file__), "../.streamlit/config.toml")
|
| 7 |
)
|
| 8 |
|
| 9 |
+
# 2. Redirect all Streamlit writes to /tmp
|
| 10 |
+
for var in ["STREAMLIT_HOME", "XDG_CONFIG_HOME", "XDG_CACHE_HOME"]:
|
| 11 |
+
os.environ[var] = "/tmp"
|
| 12 |
+
|
| 13 |
+
# 3. Ensure imports work by adding root to path
|
| 14 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
| 15 |
|
| 16 |
import streamlit as st
|
| 17 |
import torch
|
| 18 |
import torchvision.transforms as transforms
|
| 19 |
from PIL import Image
|
|
|
|
| 20 |
from resnet_model import MonkeyResNet
|
| 21 |
from data_loader import get_data_loaders
|
| 22 |
|
| 23 |
+
|
| 24 |
# Ensure the parent directory is in the system path for module imports
|
| 25 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
| 26 |
|