Spaces:
Running
on
Zero
Running
on
Zero
fix seg
Browse files
app.py
CHANGED
|
@@ -79,9 +79,6 @@ def process_image(image_path):
|
|
| 79 |
mask = image[..., -1] > 0
|
| 80 |
image = recenter_foreground(image, mask, border_ratio=0.1)
|
| 81 |
image = cv2.resize(image, (518, 518), interpolation=cv2.INTER_AREA)
|
| 82 |
-
image = image.astype(np.float32) / 255.0
|
| 83 |
-
image = image[..., :3] * image[..., 3:4] + (1 - image[..., 3:4]) # white background
|
| 84 |
-
image = (image * 255).astype(np.uint8)
|
| 85 |
return image
|
| 86 |
|
| 87 |
# process generation
|
|
@@ -97,6 +94,7 @@ def process_3d(input_image, num_steps=50, cfg_scale=7, grid_res=384, seed=42, si
|
|
| 97 |
|
| 98 |
# input image (assume processed to RGBA uint8)
|
| 99 |
image = input_image.astype(np.float32) / 255.0
|
|
|
|
| 100 |
image_tensor = torch.from_numpy(image).permute(2, 0, 1).contiguous().unsqueeze(0).float().cuda()
|
| 101 |
|
| 102 |
data = {"cond_images": image_tensor}
|
|
|
|
| 79 |
mask = image[..., -1] > 0
|
| 80 |
image = recenter_foreground(image, mask, border_ratio=0.1)
|
| 81 |
image = cv2.resize(image, (518, 518), interpolation=cv2.INTER_AREA)
|
|
|
|
|
|
|
|
|
|
| 82 |
return image
|
| 83 |
|
| 84 |
# process generation
|
|
|
|
| 94 |
|
| 95 |
# input image (assume processed to RGBA uint8)
|
| 96 |
image = input_image.astype(np.float32) / 255.0
|
| 97 |
+
image = image[..., :3] * image[..., 3:4] + (1 - image[..., 3:4]) # white background
|
| 98 |
image_tensor = torch.from_numpy(image).permute(2, 0, 1).contiguous().unsqueeze(0).float().cuda()
|
| 99 |
|
| 100 |
data = {"cond_images": image_tensor}
|