Spaces:
Sleeping
Sleeping
devjas1
commited on
Commit
·
7a4d9b4
1
Parent(s):
a003091
(CHORE)[config[: Refine configuration for model weights, sample data, and UI state
Browse files- Centralized key configuration for Streamlit session state persistence (`KEEP_KEYS`), ensuring important UI context is retained after resets.
- Set `TARGET_LEN` for standardized spectrum preprocessing length.
- Defined `SAMPLE_DATA_DIR` using pathlib for robust path handling.
- Improved `MODEL_WEIGHTS_DIR` logic: checks for environment variable `WEIGHTS_DIR`, falls back to `model_weights` directory if present, otherwise defaults to `outputs`.
- Added clear label mapping (`LABEL_MAP`) for model output classes: "Stable (Unweathered)" and "Weathered (Degraded)".
- Enhanced maintainability and clarity of global configuration for
config.py
CHANGED
|
@@ -1,43 +1,20 @@
|
|
| 1 |
-
from pathlib import Path
|
| 2 |
-
import os
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
#
|
| 8 |
-
"
|
| 9 |
-
"
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
)
|
| 21 |
-
|
| 22 |
-
# Model configuration
|
| 23 |
-
MODEL_CONFIG = {
|
| 24 |
-
"Figure2CNN (Baseline)": {
|
| 25 |
-
"class": Figure2CNN,
|
| 26 |
-
"path": f"{MODEL_WEIGHTS_DIR}/figure2_model.pth",
|
| 27 |
-
"emoji": "",
|
| 28 |
-
"description": "Baseline CNN with standard filters",
|
| 29 |
-
"accuracy": "94.80%",
|
| 30 |
-
"f1": "94.30%"
|
| 31 |
-
},
|
| 32 |
-
"ResNet1D (Advanced)": {
|
| 33 |
-
"class": ResNet1D,
|
| 34 |
-
"path": f"{MODEL_WEIGHTS_DIR}/resnet_model.pth",
|
| 35 |
-
"emoji": "",
|
| 36 |
-
"description": "Residual CNN with deeper feature learning",
|
| 37 |
-
"accuracy": "96.20%",
|
| 38 |
-
"f1": "95.90%"
|
| 39 |
-
}
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
# ==Label mapping==
|
| 43 |
-
LABEL_MAP = {0: "Stable (Unweathered)", 1: "Weathered (Degraded)"}
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
KEEP_KEYS = {
|
| 5 |
+
# ==global UI context we want to keep after "Reset"==
|
| 6 |
+
"model_select", # sidebar model key
|
| 7 |
+
"input_mode", # radio for Upload|Sample
|
| 8 |
+
"uploader_version", # version counter for file uploader
|
| 9 |
+
"input_registry", # radio controlling Upload vs Sample
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
TARGET_LEN = 500
|
| 13 |
+
SAMPLE_DATA_DIR = Path("sample_data")
|
| 14 |
+
|
| 15 |
+
MODEL_WEIGHTS_DIR = os.getenv("WEIGHTS_DIR") or (
|
| 16 |
+
"model_weights" if os.path.isdir("model_weights") else "outputs"
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
# ==Label mapping==
|
| 20 |
+
LABEL_MAP = {0: "Stable (Unweathered)", 1: "Weathered (Degraded)"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|