Rawal Khirodkar commited on
Commit
7b25fbf
·
1 Parent(s): d9c858e

Seg: drop unused opacity slider; bake 0.5 into the static overlay

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -133,7 +133,7 @@ def _label_map_to_overlay(image_bgr: np.ndarray, label_map: np.ndarray, opacity:
133
  # Gradio handler
134
 
135
  @spaces.GPU(duration=120)
136
- def predict(image: Image.Image, size: str, opacity: float):
137
  if image is None:
138
  return None, None, None
139
 
@@ -147,7 +147,7 @@ def predict(image: Image.Image, size: str, opacity: float):
147
  annotations = _label_map_to_annotations(label_map)
148
  annotated = (image_pil, annotations)
149
 
150
- overlay_bgr = _label_map_to_overlay(image_bgr, label_map, float(opacity))
151
  overlay_rgb = cv2.cvtColor(overlay_bgr, cv2.COLOR_BGR2RGB)
152
 
153
  npy_path = tempfile.NamedTemporaryFile(delete=False, suffix=".npy").name
@@ -242,9 +242,8 @@ with gr.Blocks(title="Sapiens2 Seg", theme=gr.themes.Soft(), css=CUSTOM_CSS) as
242
  choices=list(SEG_MODELS.keys()),
243
  value=DEFAULT_SIZE,
244
  label="Model size",
245
- scale=2,
246
  )
247
- opacity = gr.Slider(0.0, 1.0, value=0.5, step=0.05, label="Overlay opacity", scale=2)
248
  run = gr.Button("Run", variant="primary", size="lg", scale=1)
249
 
250
  gr.Examples(examples=EXAMPLES, inputs=inp, examples_per_page=14)
@@ -253,7 +252,7 @@ with gr.Blocks(title="Sapiens2 Seg", theme=gr.themes.Soft(), css=CUSTOM_CSS) as
253
  out_img = gr.Image(label="Color overlay (PNG)", type="pil")
254
  out_npy = gr.File(label="Raw labels (.npy uint8, class indices 0–28)")
255
 
256
- run.click(predict, inputs=[inp, size, opacity], outputs=[out_annot, out_img, out_npy])
257
 
258
 
259
  if __name__ == "__main__":
 
133
  # Gradio handler
134
 
135
  @spaces.GPU(duration=120)
136
+ def predict(image: Image.Image, size: str):
137
  if image is None:
138
  return None, None, None
139
 
 
147
  annotations = _label_map_to_annotations(label_map)
148
  annotated = (image_pil, annotations)
149
 
150
+ overlay_bgr = _label_map_to_overlay(image_bgr, label_map, 0.5)
151
  overlay_rgb = cv2.cvtColor(overlay_bgr, cv2.COLOR_BGR2RGB)
152
 
153
  npy_path = tempfile.NamedTemporaryFile(delete=False, suffix=".npy").name
 
242
  choices=list(SEG_MODELS.keys()),
243
  value=DEFAULT_SIZE,
244
  label="Model size",
245
+ scale=4,
246
  )
 
247
  run = gr.Button("Run", variant="primary", size="lg", scale=1)
248
 
249
  gr.Examples(examples=EXAMPLES, inputs=inp, examples_per_page=14)
 
252
  out_img = gr.Image(label="Color overlay (PNG)", type="pil")
253
  out_npy = gr.File(label="Raw labels (.npy uint8, class indices 0–28)")
254
 
255
+ run.click(predict, inputs=[inp, size], outputs=[out_annot, out_img, out_npy])
256
 
257
 
258
  if __name__ == "__main__":