Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -450,23 +450,25 @@ def process(
|
|
| 450 |
if t2v:
|
| 451 |
default_height, default_width = 640, 640
|
| 452 |
input_image = np.ones((default_height, default_width, 3), dtype=np.uint8) * 255
|
| 453 |
-
print("
|
| 454 |
else:
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
blended_image_float32 = rgb_uint8.astype(np.float32) * alpha_mask_float32 + \
|
| 467 |
background_uint8.astype(np.float32) * (1.0 - alpha_mask_float32)
|
| 468 |
-
|
| 469 |
-
input_image
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
|
| 471 |
yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True)
|
| 472 |
|
|
|
|
| 450 |
if t2v:
|
| 451 |
default_height, default_width = 640, 640
|
| 452 |
input_image = np.ones((default_height, default_width, 3), dtype=np.uint8) * 255
|
| 453 |
+
print("Using blank white image for text-to-video mode")
|
| 454 |
else:
|
| 455 |
+
if isinstance(input_image, dict) and "composite" in input_image:
|
| 456 |
+
# Handle uploaded image with alpha channel
|
| 457 |
+
composite_rgba_uint8 = input_image["composite"]
|
| 458 |
+
rgb_uint8 = composite_rgba_uint8[:, :, :3]
|
| 459 |
+
mask_uint8 = composite_rgba_uint8[:, :, 3]
|
| 460 |
+
h, w = rgb_uint8.shape[:2]
|
| 461 |
+
background_uint8 = np.full((h, w, 3), 255, dtype=np.uint8)
|
| 462 |
+
alpha_normalized_float32 = mask_uint8.astype(np.float32) / 255.0
|
| 463 |
+
alpha_mask_float32 = np.stack([alpha_normalized_float32]*3, axis=2)
|
| 464 |
+
blended_image_float32 = rgb_uint8.astype(np.float32) * alpha_mask_float32 + \
|
|
|
|
|
|
|
| 465 |
background_uint8.astype(np.float32) * (1.0 - alpha_mask_float32)
|
| 466 |
+
input_image = np.clip(blended_image_float32, 0, 255).astype(np.uint8)
|
| 467 |
+
elif input_image is None:
|
| 468 |
+
raise ValueError("Please provide an input image or enable Text to Video mode")
|
| 469 |
+
else:
|
| 470 |
+
# Handle regular RGB image
|
| 471 |
+
input_image = input_image.astype(np.uint8)
|
| 472 |
|
| 473 |
yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True)
|
| 474 |
|