resize
Browse files
app.py
CHANGED
|
@@ -16,11 +16,17 @@ def create_mask(input):
|
|
| 16 |
|
| 17 |
input.save(input_path)
|
| 18 |
bg_removed = remove(input)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
-
img2_grayscale =
|
| 24 |
img2_a = np.array(img2_grayscale)
|
| 25 |
|
| 26 |
mask = np.array(img2_grayscale)
|
|
|
|
| 16 |
|
| 17 |
input.save(input_path)
|
| 18 |
bg_removed = remove(input)
|
| 19 |
+
|
| 20 |
+
width, height = bg_removed.size
|
| 21 |
+
max_dim = max(width, height)
|
| 22 |
+
square_img = Image.new('RGB', (max_dim, max_dim), (255, 255, 255))
|
| 23 |
+
paste_pos = ((max_dim - width) // 2, (max_dim - height) // 2)
|
| 24 |
+
square_img.paste(bg_removed, paste_pos)
|
| 25 |
|
| 26 |
+
square_img = square_img.resize((512, 512))
|
| 27 |
+
square_img.save(bg_removed_path)
|
| 28 |
|
| 29 |
+
img2_grayscale = square_img.convert('L')
|
| 30 |
img2_a = np.array(img2_grayscale)
|
| 31 |
|
| 32 |
mask = np.array(img2_grayscale)
|