Spaces:
Runtime error
Runtime error
gokaygokay
commited on
Commit
•
17778d7
1
Parent(s):
d11da87
Update app.py
Browse files
app.py
CHANGED
@@ -199,10 +199,13 @@ def get_image(img_path: str, mask: bool=False, scale: bool=True) -> np.array:
|
|
199 |
_, binary_mask = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)
|
200 |
return np.where(binary_mask == 255, 1, 0)
|
201 |
|
|
|
|
|
|
|
202 |
if scale:
|
203 |
-
return
|
204 |
|
205 |
-
return
|
206 |
|
207 |
def blend_images(bg_img, obj_img, mask_img, method):
|
208 |
bg_img = get_image(bg_img)
|
|
|
199 |
_, binary_mask = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)
|
200 |
return np.where(binary_mask == 255, 1, 0)
|
201 |
|
202 |
+
if img.shape[-1] == 3: # Check if the image has 3 channels
|
203 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
204 |
+
|
205 |
if scale:
|
206 |
+
return img.astype('double') / 255.0
|
207 |
|
208 |
+
return img
|
209 |
|
210 |
def blend_images(bg_img, obj_img, mask_img, method):
|
211 |
bg_img = get_image(bg_img)
|