kaveh commited on
Commit
30d4f85
·
1 Parent(s): 7af52d1

updated to make UI more compact

Browse files
Files changed (1) hide show
  1. S2FApp/app.py +10 -5
S2FApp/app.py CHANGED
@@ -134,7 +134,7 @@ else:
134
  sample_subfolder_name = "single_cell" if model_type == "single_cell" else "spheroid"
135
  if sample_files:
136
  selected_sample = st.selectbox(
137
- "Select example image",
138
  sample_files,
139
  format_func=lambda x: x,
140
  key=f"sample_{model_type}",
@@ -143,7 +143,6 @@ else:
143
  sample_path = os.path.join(sample_folder, selected_sample)
144
  img = cv2.imread(sample_path, cv2.IMREAD_GRAYSCALE)
145
  # Show example thumbnails (filtered by model type)
146
- st.caption(f"Example images from `samples/{sample_subfolder_name}/`")
147
  n_cols = min(5, len(sample_files))
148
  cols = st.columns(n_cols)
149
  for i, fname in enumerate(sample_files[:8]): # show up to 8
@@ -155,7 +154,15 @@ else:
155
  else:
156
  st.info(f"No example images in samples/{sample_subfolder_name}/. Add images or use Upload.")
157
 
158
- run = st.button("Run prediction", type="primary")
 
 
 
 
 
 
 
 
159
  has_image = img is not None
160
 
161
  # Persist results in session state so they survive re-runs (e.g. when clicking Download)
@@ -171,7 +178,6 @@ has_cached = cached is not None and cached.get("cache_key") == current_key
171
 
172
  if just_ran:
173
  st.session_state["prediction_result"] = None # Clear before new run
174
- st.markdown(f"**Using checkpoint:** `ckp/{ckp_subfolder_name}/{checkpoint}`")
175
  with st.spinner("Loading model and predicting..."):
176
  try:
177
  from predictor import S2FPredictor
@@ -325,5 +331,4 @@ elif run and not has_image:
325
 
326
  # Footer
327
  st.sidebar.divider()
328
- st.sidebar.caption(f"Checkpoint: `ckp/{ckp_subfolder_name}/`")
329
  st.sidebar.caption(f"Examples: `samples/{ckp_subfolder_name}/`")
 
134
  sample_subfolder_name = "single_cell" if model_type == "single_cell" else "spheroid"
135
  if sample_files:
136
  selected_sample = st.selectbox(
137
+ f"Select example image (from `samples/{sample_subfolder_name}/`)",
138
  sample_files,
139
  format_func=lambda x: x,
140
  key=f"sample_{model_type}",
 
143
  sample_path = os.path.join(sample_folder, selected_sample)
144
  img = cv2.imread(sample_path, cv2.IMREAD_GRAYSCALE)
145
  # Show example thumbnails (filtered by model type)
 
146
  n_cols = min(5, len(sample_files))
147
  cols = st.columns(n_cols)
148
  for i, fname in enumerate(sample_files[:8]): # show up to 8
 
154
  else:
155
  st.info(f"No example images in samples/{sample_subfolder_name}/. Add images or use Upload.")
156
 
157
+ col_btn, col_model, col_path = st.columns([1, 1, 3])
158
+ with col_btn:
159
+ run = st.button("Run prediction", type="primary")
160
+ with col_model:
161
+ model_label = "Single cell" if model_type == "single_cell" else "Spheroid"
162
+ st.markdown(f"<span style='display: inline-flex; align-items: center; height: 38px;'>{model_label}</span>", unsafe_allow_html=True)
163
+ with col_path:
164
+ ckp_path = f"ckp/{ckp_subfolder_name}/{checkpoint}" if checkpoint else f"ckp/{ckp_subfolder_name}/"
165
+ st.markdown(f"<span style='display: inline-flex; align-items: center; height: 38px;'>Checkpoint: <code>{ckp_path}</code></span>", unsafe_allow_html=True)
166
  has_image = img is not None
167
 
168
  # Persist results in session state so they survive re-runs (e.g. when clicking Download)
 
178
 
179
  if just_ran:
180
  st.session_state["prediction_result"] = None # Clear before new run
 
181
  with st.spinner("Loading model and predicting..."):
182
  try:
183
  from predictor import S2FPredictor
 
331
 
332
  # Footer
333
  st.sidebar.divider()
 
334
  st.sidebar.caption(f"Examples: `samples/{ckp_subfolder_name}/`")