Spaces:
Running
on
Zero
Running
on
Zero
Restore premultiplied alpha preprocessing (matches training data)
Browse files
app.py
CHANGED
|
@@ -375,10 +375,9 @@ def preprocess_image(input: Image.Image) -> Image.Image:
|
|
| 375 |
size = int(size * 1)
|
| 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 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
output = Image.fromarray(output_np[:, :, :3])
|
| 382 |
return output
|
| 383 |
|
| 384 |
|
|
|
|
| 375 |
size = int(size * 1)
|
| 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 |
|
| 383 |
|