Spaces:
Runtime error
Runtime error
gokaygokay
commited on
Commit
•
235021a
1
Parent(s):
c3faeca
Update app.py
Browse files
app.py
CHANGED
@@ -185,8 +185,13 @@ def laplacian_blend(img1: np.ndarray, img2: np.ndarray, mask: np.ndarray, depth:
|
|
185 |
return np.clip(imgs[-1], 0, 1)
|
186 |
|
187 |
def get_image(img_input, mask=False, scale=True):
|
|
|
|
|
|
|
188 |
if isinstance(img_input, dict):
|
189 |
-
img = img_input.get('composite')
|
|
|
|
|
190 |
elif isinstance(img_input, np.ndarray):
|
191 |
img = img_input
|
192 |
elif isinstance(img_input, str):
|
@@ -214,7 +219,9 @@ def blend_images(bg_img, obj_img, mask_img, method):
|
|
214 |
|
215 |
# Handle different input types for mask_img
|
216 |
if isinstance(mask_img, dict):
|
217 |
-
mask_img = mask_img.get('composite')
|
|
|
|
|
218 |
elif isinstance(mask_img, str):
|
219 |
mask_img = cv2.imread(mask_img, cv2.IMREAD_GRAYSCALE)
|
220 |
|
@@ -272,7 +279,7 @@ with gr.Blocks(theme='bethecloud/storj_theme') as iface:
|
|
272 |
"layers": [],
|
273 |
"composite": image_path
|
274 |
}
|
275 |
-
|
276 |
gr.Examples(
|
277 |
examples=[
|
278 |
["img1.jpg", "img2.jpg", create_image_editor_input("mask1.jpg"), "Poisson"],
|
|
|
185 |
return np.clip(imgs[-1], 0, 1)
|
186 |
|
187 |
def get_image(img_input, mask=False, scale=True):
|
188 |
+
if img_input is None:
|
189 |
+
raise ValueError("Image input is None")
|
190 |
+
|
191 |
if isinstance(img_input, dict):
|
192 |
+
img = img_input.get('composite')
|
193 |
+
if img is None:
|
194 |
+
img = img_input.get('background')
|
195 |
elif isinstance(img_input, np.ndarray):
|
196 |
img = img_input
|
197 |
elif isinstance(img_input, str):
|
|
|
219 |
|
220 |
# Handle different input types for mask_img
|
221 |
if isinstance(mask_img, dict):
|
222 |
+
mask_img = mask_img.get('composite')
|
223 |
+
if mask_img is None:
|
224 |
+
mask_img = mask_img.get('background')
|
225 |
elif isinstance(mask_img, str):
|
226 |
mask_img = cv2.imread(mask_img, cv2.IMREAD_GRAYSCALE)
|
227 |
|
|
|
279 |
"layers": [],
|
280 |
"composite": image_path
|
281 |
}
|
282 |
+
|
283 |
gr.Examples(
|
284 |
examples=[
|
285 |
["img1.jpg", "img2.jpg", create_image_editor_input("mask1.jpg"), "Poisson"],
|