devjas1 commited on
Commit
82ba161
·
1 Parent(s): 6598986

(DEPLOY): unignore outputs/*.pth on space-deploy; continue ignoring output/logs

Browse files
Files changed (2) hide show
  1. .gitignore +3 -33
  2. dashboard/app.py +0 -171
.gitignore CHANGED
@@ -1,8 +1,6 @@
1
  # Ignore raw data and system clutter
2
 
3
- data
4
  datasets/
5
- depracated_scripts/
6
  __pycache__/
7
  *.pyc
8
  .DS_store
@@ -12,43 +10,15 @@ __pycache__/
12
  *.env
13
  *.yml
14
  *.json
15
- environment.yml
16
- test_env/
17
- _frozen_reference.txt
18
-
19
- _venv_docker_test/
20
-
21
  .streamlit
22
- logs/
23
- docs/scope_maintenance_log.yaml
24
- depracated_script/ftir_cv_diagnostics_run1.json
25
- depracated_script/ftir_cv_diagnostics.json
26
- depracated_script/ftir_model.pth
27
- depracated_script/plot_ftir_sample.py
28
- depracated_script/preprocess_ftir_legacy.py
29
- depracated_script/preprocess_ftir.py
30
- depracated_script/train_ftir_model_cv.py
31
- depracated_script/train_ftir_model.py
32
- depracated_script/train_model.py
33
- depracated_script/cnn_model.py
34
- models/cnn_model.py
35
- outputs\inference\test_prediction.json
36
- outputs\figure2_model.pth
37
- outputs\resnet_model.pth
38
- outputs\saliency
39
- outputs/plots/04_raman_diagnostics.ipynb
40
- outputs/figure2_model.pth
41
- outputs/inference/test_prediction.json
42
  docs/PROJECT_REPORT.md
43
  wea-*.txt
44
  sta-*.txt
45
- scripts/generate_saliency.py
46
- scripts/compare_samples.py
47
  # --- Data (keep folder, ignore files) ---
48
  datasets/**
49
  !datasets/.gitkeep
50
  !datasets/.README.md
51
  # ---------------------------------------
52
- outputs/resnet18vision_model.pth
53
- requirements_0.txt
54
- requirements.txt
 
1
  # Ignore raw data and system clutter
2
 
 
3
  datasets/
 
4
  __pycache__/
5
  *.pyc
6
  .DS_store
 
10
  *.env
11
  *.yml
12
  *.json
 
 
 
 
 
 
13
  .streamlit
14
+ outputs/logs/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  docs/PROJECT_REPORT.md
16
  wea-*.txt
17
  sta-*.txt
18
+
 
19
  # --- Data (keep folder, ignore files) ---
20
  datasets/**
21
  !datasets/.gitkeep
22
  !datasets/.README.md
23
  # ---------------------------------------
24
+
 
 
dashboard/app.py DELETED
@@ -1,171 +0,0 @@
1
- """
2
- Streamlit UI for ml-polymer-recycling — Step 3b: Raman Upload → Parse → Preview
3
- - Adds real file uploader to Raman Inference page
4
- - Accepts .txt Raman spectra (single or batch)
5
- - Parses one- or two-column format
6
- - Displays file name and data table preview per upload
7
- - No inference or resampling yet
8
- """
9
-
10
- import streamlit as st
11
- from pathlib import Path
12
- import pandas as pd
13
- import io
14
-
15
- # --- PAGE CONFIGURATION ---
16
- st.set_page_config(
17
- page_title="ML Polymer Recycling",
18
- page_icon="🧪",
19
- layout="wide"
20
- )
21
-
22
- # --- SESSION STATE INITIALIZATION ---
23
- def init_session_state():
24
- if "status_message" not in st.session_state:
25
- st.session_state.status_message = "Ready."
26
- if "status_type" not in st.session_state:
27
- st.session_state.status_type = "ok"
28
- if "modality" not in st.session_state:
29
- st.session_state.modality = "Raman"
30
-
31
- # --- STATUS BANNER ---
32
- def display_status():
33
- style_map = {
34
- "ok": ("#e8f5e9", "#2e7d32"),
35
- "warn": ("#fff8e1", "#f9a825"),
36
- "err": ("#ffebee", "#c62828")
37
- }
38
- bg_color, text_color = style_map.get(st.session_state.status_type, ("#f0f0f0", "#333"))
39
- st.markdown(f"""
40
- <div style='background-color:{bg_color}; padding:0.75em 1em; border-radius:8px; color:{text_color};'>
41
- <b>Status:</b> {st.session_state.status_message}
42
- </div>
43
- """, unsafe_allow_html=True)
44
-
45
- # --- SIDEBAR NAVIGATION ---
46
- def display_sidebar():
47
- with st.sidebar:
48
- st.header("🧪 ML Polymer Dashboard")
49
-
50
- modality = st.radio("Modality", ["Raman", "Image", "FTIR"])
51
- st.session_state.modality = modality
52
-
53
- if modality == "Raman":
54
- page = st.radio("Raman Pages", ["Dashboard", "Model Management", "Inference"])
55
- elif modality == "Image":
56
- page = st.radio("Image Pages", ["Model Management", "Inference"])
57
- elif modality == "FTIR":
58
- page = st.radio("FTIR Pages", ["Model Management", "Inference"])
59
-
60
- return modality, page
61
-
62
- # --- HEADER BAR ---
63
- def display_header(title: str):
64
- st.title(title)
65
- display_status()
66
- st.markdown("---")
67
-
68
- # --- MODEL DISCOVERY (Raman only for now) ---
69
- def discover_models(outputs_dir="outputs"):
70
- out = []
71
- root = Path(outputs_dir)
72
- if not root.exists():
73
- return []
74
- for p in sorted(root.rglob("*.pth")):
75
- out.append(p)
76
- return out
77
-
78
- # --- RAMAN HELPERS ---
79
- def parse_txt_file(upload) -> pd.DataFrame:
80
- try:
81
- content = upload.read()
82
- upload.seek(0)
83
- buf = io.BytesIO(content)
84
- try:
85
- df = pd.read_csv(buf, sep=None, engine="python", header=None, comment="#")
86
- except Exception:
87
- buf.seek(0)
88
- df = pd.read_csv(buf, delim_whitespace=True, header=None, comment="#")
89
- return df
90
- except Exception as e:
91
- st.error(f"Failed to parse file: {upload.name}. Error: {e}")
92
- return pd.DataFrame()
93
-
94
- # --- RAMAN PAGES ---
95
- def raman_dashboard():
96
- display_header("Raman Dashboard")
97
- st.write("This will house future metrics, model count, and version history.")
98
-
99
- def raman_model_management():
100
- display_header("Raman Model Management")
101
- models = discover_models()
102
- if not models:
103
- st.info("No model weights found in outputs/. Place .pth files there to make them discoverable.")
104
- else:
105
- st.markdown(f"**Discovered {len(models)} model weight file(s):**")
106
- for m in models:
107
- st.code(str(m), language="text")
108
-
109
- def raman_inference():
110
- display_header("Raman Inference")
111
-
112
- uploads = st.file_uploader(
113
- "Upload one or more Raman .txt spectra (single- or two-column)",
114
- type="txt",
115
- accept_multiple_files=True
116
- )
117
-
118
- if uploads:
119
- for file in uploads:
120
- st.markdown(f"**Preview: {file.name}**")
121
- df = parse_txt_file(file)
122
- if not df.empty:
123
- st.dataframe(df.head(10), use_container_width=True)
124
- else:
125
- st.warning("No data parsed or file unreadable.")
126
- st.markdown("---")
127
-
128
- # --- IMAGE + FTIR PLACEHOLDERS ---
129
- def image_model_management():
130
- display_header("Image Model Management")
131
- st.info("Image-based model integration is coming soon.")
132
-
133
- def image_inference():
134
- display_header("Image Inference")
135
- st.info("This page will allow batch image upload and multi-model prediction.")
136
-
137
- def ftir_model_management():
138
- display_header("FTIR Model Management")
139
- st.info("FTIR model support is planned and will be developed after clarification with Dr. K.")
140
-
141
- def ftir_inference():
142
- display_header("FTIR Inference")
143
- st.info("FTIR input and prediction support will be added in a future phase.")
144
-
145
- # --- MAIN ENTRY POINT ---
146
- def main():
147
- init_session_state()
148
- modality, page = display_sidebar()
149
-
150
- if modality == "Raman":
151
- if page == "Dashboard":
152
- raman_dashboard()
153
- elif page == "Model Management":
154
- raman_model_management()
155
- elif page == "Inference":
156
- raman_inference()
157
-
158
- elif modality == "Image":
159
- if page == "Model Management":
160
- image_model_management()
161
- elif page == "Inference":
162
- image_inference()
163
-
164
- elif modality == "FTIR":
165
- if page == "Model Management":
166
- ftir_model_management()
167
- elif page == "Inference":
168
- ftir_inference()
169
-
170
- if __name__ == "__main__":
171
- main()