Update app.py
Browse files
app.py
CHANGED
@@ -112,13 +112,11 @@ def process(image, bg):
|
|
112 |
pred_pil = transforms.ToPILImage()(pred)
|
113 |
mask = pred_pil.resize(image_size)
|
114 |
|
115 |
-
if
|
116 |
color_rgb = tuple(int(bg[i:i+2], 16) for i in (1, 3, 5))
|
117 |
background = Image.new("RGBA", image_size, color_rgb + (255,))
|
118 |
-
elif isinstance(bg, Image.Image):
|
119 |
-
background = bg.convert("RGBA").resize(image_size)
|
120 |
else:
|
121 |
-
background =
|
122 |
|
123 |
# Composite the image onto the background using the mask
|
124 |
image = Image.composite(image, background, mask)
|
|
|
112 |
pred_pil = transforms.ToPILImage()(pred)
|
113 |
mask = pred_pil.resize(image_size)
|
114 |
|
115 |
+
if bg.startswith("#"):
|
116 |
color_rgb = tuple(int(bg[i:i+2], 16) for i in (1, 3, 5))
|
117 |
background = Image.new("RGBA", image_size, color_rgb + (255,))
|
|
|
|
|
118 |
else:
|
119 |
+
background = bg.convert("RGBA").resize(image_size)
|
120 |
|
121 |
# Composite the image onto the background using the mask
|
122 |
image = Image.composite(image, background, mask)
|