opsiclear-admin commited on
Commit
40e9737
·
verified ·
1 Parent(s): fc11409

Revert to premultiplied alpha on black (original preprocessing)

Browse files
Files changed (1) hide show
  1. app.py +1 -2
app.py CHANGED
@@ -376,8 +376,7 @@ def preprocess_image(input: Image.Image) -> Image.Image:
376
  bbox = center[0] - size // 2, center[1] - size // 2, center[0] + size // 2, center[1] + size // 2
377
  output = output.crop(bbox) # type: ignore
378
  output = np.array(output).astype(np.float32) / 255
379
- alpha = output[:, :, 3:4]
380
- output = output[:, :, :3] * alpha + (1 - alpha) # composite on white
381
  output = Image.fromarray((output * 255).astype(np.uint8))
382
  return output
383
 
 
376
  bbox = center[0] - size // 2, center[1] - size // 2, center[0] + size // 2, center[1] + size // 2
377
  output = output.crop(bbox) # type: ignore
378
  output = np.array(output).astype(np.float32) / 255
379
+ output = output[:, :, :3] * output[:, :, 3:4]
 
380
  output = Image.fromarray((output * 255).astype(np.uint8))
381
  return output
382