Snake4y5h commited on
Commit
918ffce
·
verified ·
1 Parent(s): 9f3f261

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -34,7 +34,8 @@ from transformers import pipeline
34
  # setting parts biggest region
35
  # SAM defaults ~40 (13% of frame even covered)
36
  # 64 pts / IoU .5 / stab .75 117 24% <- one blob held a quarter of the art
37
- # 96 pts / IoU .35 / stab .5 284 10% <- the giants break apart
 
38
  #
39
  # `stability_score_thresh` is the one that lets the finer, "less stable" masks
40
  # through, and the DENSE GRID is what actually splits a big region: more sample
@@ -158,9 +159,9 @@ def _run(pixels: np.ndarray, points_per_crop: int, pred_iou_thresh: float, stabi
158
  def segment(
159
  image: Image.Image,
160
  points_per_crop: int = 96,
161
- min_area_frac: float = 0.0002,
162
- pred_iou_thresh: float = 0.35,
163
- stability_score_thresh: float = 0.5,
164
  gap_reach: int = 32,
165
  ):
166
  """
@@ -218,10 +219,10 @@ with gr.Blocks(title="Segment Everything API") as demo:
218
  image_in = gr.Image(label="Image", type="pil")
219
  points = gr.Slider(8, 128, value=96, step=8, label="Points per crop (detail)")
220
  min_area = gr.Slider(
221
- 0.0, 0.01, value=0.0002, step=0.0001, label="Min segment area (fraction)"
222
  )
223
- iou = gr.Slider(0.2, 0.99, value=0.35, step=0.01, label="Predicted IoU threshold")
224
- stability = gr.Slider(0.2, 0.99, value=0.5, step=0.01, label="Stability threshold")
225
  gap = gr.Slider(0, 64, value=32, step=1, label="Gap close reach (px)")
226
  run = gr.Button("Segment", variant="primary")
227
  with gr.Column():
 
34
  # setting parts biggest region
35
  # SAM defaults ~40 (13% of frame even covered)
36
  # 64 pts / IoU .5 / stab .75 117 24% <- one blob held a quarter of the art
37
+ # 96 pts / IoU .35 / stab .5 284 10%
38
+ # 96 pts / IoU .3 / stab .3 443 9% <- current, finest that stays sane
39
  #
40
  # `stability_score_thresh` is the one that lets the finer, "less stable" masks
41
  # through, and the DENSE GRID is what actually splits a big region: more sample
 
159
  def segment(
160
  image: Image.Image,
161
  points_per_crop: int = 96,
162
+ min_area_frac: float = 0.0001,
163
+ pred_iou_thresh: float = 0.3,
164
+ stability_score_thresh: float = 0.3,
165
  gap_reach: int = 32,
166
  ):
167
  """
 
219
  image_in = gr.Image(label="Image", type="pil")
220
  points = gr.Slider(8, 128, value=96, step=8, label="Points per crop (detail)")
221
  min_area = gr.Slider(
222
+ 0.0, 0.01, value=0.0001, step=0.0001, label="Min segment area (fraction)"
223
  )
224
+ iou = gr.Slider(0.2, 0.99, value=0.3, step=0.01, label="Predicted IoU threshold")
225
+ stability = gr.Slider(0.2, 0.99, value=0.3, step=0.01, label="Stability threshold")
226
  gap = gr.Slider(0, 64, value=32, step=1, label="Gap close reach (px)")
227
  run = gr.Button("Segment", variant="primary")
228
  with gr.Column():