Error solved for hex colors
Browse files
app.py
CHANGED
|
@@ -82,11 +82,11 @@ def process(image, bg):
|
|
| 82 |
pred_pil = transforms.ToPILImage()(pred)
|
| 83 |
mask = pred_pil.resize(image_size)
|
| 84 |
|
| 85 |
-
if
|
| 86 |
-
background = Image.open(bg).convert("RGBA").resize(image_size)
|
| 87 |
-
else: # If bg is a color hex code
|
| 88 |
color_rgb = tuple(int(bg[i : i + 2], 16) for i in (1, 3, 5))
|
| 89 |
background = Image.new("RGBA", image_size, color_rgb + (255,))
|
|
|
|
|
|
|
| 90 |
|
| 91 |
# Composite the image onto the background using the mask
|
| 92 |
image = Image.composite(image, background, mask)
|
|
|
|
| 82 |
pred_pil = transforms.ToPILImage()(pred)
|
| 83 |
mask = pred_pil.resize(image_size)
|
| 84 |
|
| 85 |
+
if bg.startswith("#"):
|
|
|
|
|
|
|
| 86 |
color_rgb = tuple(int(bg[i : i + 2], 16) for i in (1, 3, 5))
|
| 87 |
background = Image.new("RGBA", image_size, color_rgb + (255,))
|
| 88 |
+
else:
|
| 89 |
+
background = Image.open(bg).convert("RGBA").resize(image_size)
|
| 90 |
|
| 91 |
# Composite the image onto the background using the mask
|
| 92 |
image = Image.composite(image, background, mask)
|