Cursor Agent commited on
Commit
16e0d73
·
1 Parent(s): 64dd0b7

Enhance ball rings with neon glow effect (additive blending)

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -800,10 +800,10 @@ FX_GLOW_COLOR = np.array([1.0, 0.1, 0.6], dtype=np.float32)
800
  FX_EPS = 1e-6
801
  GHOST_TRAIL_COLOR = np.array([1.0, 0.0, 1.0], dtype=np.float32)
802
  GHOST_TRAIL_ALPHA = 0.55
803
- BALL_RING_ALPHA = 0.85
804
- BALL_RING_THICKNESS_PX = 4
805
- BALL_RING_FEATHER_SIGMA = 0.75
806
- BALL_RING_INTENSITY_GAMMA = 0.65
807
 
808
 
809
  def _maybe_upscale_for_display(image: Image.Image) -> Image.Image:
@@ -1288,9 +1288,12 @@ def _build_ball_ring_mask(state: AppState, frame_idx: int) -> np.ndarray | None:
1288
  max_val = float(ring_mask.max())
1289
  if max_val > FX_EPS:
1290
  ring_mask = ring_mask / max_val
 
 
1291
  gamma_val = getattr(state, "fx_ring_gamma", BALL_RING_INTENSITY_GAMMA)
1292
  if abs(gamma_val - 1.0) > 1e-6:
1293
  ring_mask = np.power(np.clip(ring_mask, 0.0, 1.0), gamma_val)
 
1294
  return np.clip(ring_mask, 0.0, 1.0)
1295
 
1296
 
@@ -2844,7 +2847,7 @@ with gr.Blocks(title="SAM2 Video (Transformers) - Interactive Segmentation", the
2844
  with gr.Column(scale=1):
2845
  ball_ring_chk = gr.Checkbox(
2846
  label="Ball rings (future)",
2847
- value=True,
2848
  info="Replace the ghost trail fill with magenta rings at future ball positions.",
2849
  )
2850
  with gr.Column(scale=1):
@@ -2958,7 +2961,7 @@ with gr.Blocks(title="SAM2 Video (Transformers) - Interactive Segmentation", the
2958
  minimum=0.0,
2959
  maximum=5.0,
2960
  step=0.1,
2961
- value=1.5,
2962
  )
2963
  with gr.Column(scale=1):
2964
  ring_gamma = gr.Slider(
@@ -2966,7 +2969,8 @@ with gr.Blocks(title="SAM2 Video (Transformers) - Interactive Segmentation", the
2966
  minimum=0.1,
2967
  maximum=2.0,
2968
  step=0.05,
2969
- value=0.65, # Default gamma
 
2970
  )
2971
 
2972
  with gr.Row():
 
800
  FX_EPS = 1e-6
801
  GHOST_TRAIL_COLOR = np.array([1.0, 0.0, 1.0], dtype=np.float32)
802
  GHOST_TRAIL_ALPHA = 0.55
803
+ BALL_RING_ALPHA = 2.0 # Increased brightness
804
+ BALL_RING_THICKNESS_PX = 2.0 # Thinner rings
805
+ BALL_RING_FEATHER_SIGMA = 1.0 # Less blurred
806
+ BALL_RING_INTENSITY_GAMMA = 0.5 # Higher contrast (for < 1.0 gamma on mask values)
807
 
808
 
809
  def _maybe_upscale_for_display(image: Image.Image) -> Image.Image:
 
1288
  max_val = float(ring_mask.max())
1289
  if max_val > FX_EPS:
1290
  ring_mask = ring_mask / max_val
1291
+
1292
+ # Apply gamma correction (contrast)
1293
  gamma_val = getattr(state, "fx_ring_gamma", BALL_RING_INTENSITY_GAMMA)
1294
  if abs(gamma_val - 1.0) > 1e-6:
1295
  ring_mask = np.power(np.clip(ring_mask, 0.0, 1.0), gamma_val)
1296
+
1297
  return np.clip(ring_mask, 0.0, 1.0)
1298
 
1299
 
 
2847
  with gr.Column(scale=1):
2848
  ball_ring_chk = gr.Checkbox(
2849
  label="Ball rings (future)",
2850
+ value=False,
2851
  info="Replace the ghost trail fill with magenta rings at future ball positions.",
2852
  )
2853
  with gr.Column(scale=1):
 
2961
  minimum=0.0,
2962
  maximum=5.0,
2963
  step=0.1,
2964
+ value=1.0, # Updated default
2965
  )
2966
  with gr.Column(scale=1):
2967
  ring_gamma = gr.Slider(
 
2969
  minimum=0.1,
2970
  maximum=2.0,
2971
  step=0.05,
2972
+ value=0.5, # Updated default
2973
+ info="Lower values = higher contrast/sharper falloff"
2974
  )
2975
 
2976
  with gr.Row():