Spaces:
Configuration error
Configuration error
Revert to premultiplied alpha on black (original preprocessing)
Browse files
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 |
-
|
| 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 |
|