opsiclear-admin commited on
Commit
0d76b38
·
verified ·
1 Parent(s): c4c6fa7

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -373,9 +373,8 @@ def preprocess_image(input: Image.Image) -> Image.Image:
373
  output_np = np.array(output).astype(np.float32)
374
  rgb = output_np[:, :, :3]
375
  alpha = output_np[:, :, 3:4] / 255.0
376
- # Use threshold to avoid darkening foreground pixels with slightly transparent alpha
377
- # Pixels with alpha > 0.5 keep their full RGB, pixels below are blacked out
378
- mask = (alpha > 0.5).astype(np.float32)
379
  rgb = rgb * mask
380
  output = Image.fromarray(rgb.astype(np.uint8))
381
  return output
 
373
  output_np = np.array(output).astype(np.float32)
374
  rgb = output_np[:, :, :3]
375
  alpha = output_np[:, :, 3:4] / 255.0
376
+ # Keep full RGB for visible pixels, zero out transparent background
377
+ mask = (alpha > 0.05).astype(np.float32)
 
378
  rgb = rgb * mask
379
  output = Image.fromarray(rgb.astype(np.uint8))
380
  return output