kaveh commited on
Commit
f537675
·
1 Parent(s): 7068f5c

roll back remaining batch result option

Browse files
Files changed (1) hide show
  1. S2FApp/ui/result_display.py +6 -31
S2FApp/ui/result_display.py CHANGED
@@ -26,7 +26,6 @@ from ui.measure_tool import (
26
  _HISTOGRAM_ACCENT = "#0d9488"
27
  _RESULT_FIG_HEIGHT = 320
28
  _HISTOGRAM_HEIGHT = 180
29
- _BATCH_PREVIEW_LIMIT = 3
30
 
31
 
32
  def _result_banner(badge: str, badge_class: str, title: str) -> str:
@@ -79,49 +78,25 @@ def render_batch_results(batch_results, colormap_name="Jet", display_mode="Defau
79
  csv_rows.append([os.path.splitext(key)[0]] + row[1:])
80
  st.markdown(_result_banner("INPUT", "input", "Bright-field images"), unsafe_allow_html=True)
81
  n_cols = min(5, len(batch_results))
82
- preview_count = min(_BATCH_PREVIEW_LIMIT, len(batch_results))
83
- preview_results = batch_results[:preview_count]
84
- remaining_results = batch_results[preview_count:]
85
- bf_cols = st.columns(min(n_cols, preview_count))
86
- for i, r in enumerate(preview_results):
87
  img = r["img"]
88
  if img.ndim == 2:
89
  img_rgb = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
90
  else:
91
  img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
92
- with bf_cols[i % min(n_cols, preview_count)]:
93
  st.image(img_rgb, caption=r["key_img"], use_container_width=True)
94
  is_rescale_b = is_display_range_remapped(display_mode, clip_min, clip_max)
95
  st.markdown(_result_banner("OUTPUT", "output", "Predicted force maps"), unsafe_allow_html=True)
96
- hm_cols = st.columns(min(n_cols, preview_count))
97
- for i, r in enumerate(preview_results):
98
  hm_rgb = heatmap_to_rgb_with_contour(
99
  r["_display_heatmap"], colormap_name,
100
  r.get("_cell_mask") if auto_cell_boundary else None,
101
  )
102
- with hm_cols[i % min(n_cols, preview_count)]:
103
  st.image(hm_rgb, caption=r["key_img"], use_container_width=True)
104
- if remaining_results:
105
- with st.expander(f"Show remaining batch previews ({len(remaining_results)})", expanded=False):
106
- st.markdown(_result_banner("INPUT", "input", "Remaining bright-field images"), unsafe_allow_html=True)
107
- rem_bf_cols = st.columns(min(5, len(remaining_results)))
108
- for i, r in enumerate(remaining_results):
109
- img = r["img"]
110
- if img.ndim == 2:
111
- img_rgb = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
112
- else:
113
- img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
114
- with rem_bf_cols[i % min(5, len(remaining_results))]:
115
- st.image(img_rgb, caption=r["key_img"], use_container_width=True)
116
- st.markdown(_result_banner("OUTPUT", "output", "Remaining predicted force maps"), unsafe_allow_html=True)
117
- rem_hm_cols = st.columns(min(5, len(remaining_results)))
118
- for i, r in enumerate(remaining_results):
119
- hm_rgb = heatmap_to_rgb_with_contour(
120
- r["_display_heatmap"], colormap_name,
121
- r.get("_cell_mask") if auto_cell_boundary else None,
122
- )
123
- with rem_hm_cols[i % min(5, len(remaining_results))]:
124
- st.image(hm_rgb, caption=r["key_img"], use_container_width=True)
125
  render_horizontal_colorbar(colormap_name, clip_min, clip_max, is_rescale_b)
126
  # Table
127
  st.dataframe(
 
26
  _HISTOGRAM_ACCENT = "#0d9488"
27
  _RESULT_FIG_HEIGHT = 320
28
  _HISTOGRAM_HEIGHT = 180
 
29
 
30
 
31
  def _result_banner(badge: str, badge_class: str, title: str) -> str:
 
78
  csv_rows.append([os.path.splitext(key)[0]] + row[1:])
79
  st.markdown(_result_banner("INPUT", "input", "Bright-field images"), unsafe_allow_html=True)
80
  n_cols = min(5, len(batch_results))
81
+ bf_cols = st.columns(n_cols)
82
+ for i, r in enumerate(batch_results):
 
 
 
83
  img = r["img"]
84
  if img.ndim == 2:
85
  img_rgb = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
86
  else:
87
  img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
88
+ with bf_cols[i % n_cols]:
89
  st.image(img_rgb, caption=r["key_img"], use_container_width=True)
90
  is_rescale_b = is_display_range_remapped(display_mode, clip_min, clip_max)
91
  st.markdown(_result_banner("OUTPUT", "output", "Predicted force maps"), unsafe_allow_html=True)
92
+ hm_cols = st.columns(n_cols)
93
+ for i, r in enumerate(batch_results):
94
  hm_rgb = heatmap_to_rgb_with_contour(
95
  r["_display_heatmap"], colormap_name,
96
  r.get("_cell_mask") if auto_cell_boundary else None,
97
  )
98
+ with hm_cols[i % n_cols]:
99
  st.image(hm_rgb, caption=r["key_img"], use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  render_horizontal_colorbar(colormap_name, clip_min, clip_max, is_rescale_b)
101
  # Table
102
  st.dataframe(