Fabrice-TIERCELIN commited on
Commit
e512267
·
verified ·
1 Parent(s): d8ca1d8

No image editor

Browse files
Files changed (1) hide show
  1. app.py +2 -27
app.py CHANGED
@@ -385,31 +385,6 @@ def process(input_image, prompt,
385
  default_height, default_width = 640, 640
386
  input_image = np.ones((default_height, default_width, 3), dtype=np.uint8) * 255
387
  print("No input image provided. Using a blank white image.")
388
- else:
389
- composite_rgba_uint8 = input_image["composite"]
390
-
391
- # rgb_uint8 will be (H, W, 3), dtype uint8
392
- rgb_uint8 = composite_rgba_uint8[:, :, :3]
393
- # mask_uint8 will be (H, W), dtype uint8
394
- mask_uint8 = composite_rgba_uint8[:, :, 3]
395
-
396
- # Create background
397
- h, w = rgb_uint8.shape[:2]
398
- # White background, (H, W, 3), dtype uint8
399
- background_uint8 = np.full((h, w, 3), 255, dtype=np.uint8)
400
-
401
- # Normalize mask to range [0.0, 1.0].
402
- alpha_normalized_float32 = mask_uint8.astype(np.float32) / 255.0
403
-
404
- # Expand alpha to 3 channels to match RGB images for broadcasting.
405
- # alpha_mask_float32 will have shape (H, W, 3)
406
- alpha_mask_float32 = np.stack([alpha_normalized_float32] * 3, axis=2)
407
-
408
- # alpha blending
409
- blended_image_float32 = rgb_uint8.astype(np.float32) * alpha_mask_float32 + \
410
- background_uint8.astype(np.float32) * (1.0 - alpha_mask_float32)
411
-
412
- input_image = np.clip(blended_image_float32, 0, 255).astype(np.uint8)
413
 
414
  yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True)
415
 
@@ -454,7 +429,7 @@ with block:
454
  """)
455
  with gr.Row():
456
  with gr.Column():
457
- input_image = gr.ImageEditor(type="numpy", label="Image", height=320, brush=gr.Brush(colors=["#ffffff"]))
458
  prompt = gr.Textbox(label="Prompt", value='')
459
  t2v = gr.Checkbox(label="do text-to-video", value=False)
460
  example_quick_prompts = gr.Dataset(samples=quick_prompts, label='Quick List', samples_per_page=1000, components=[prompt])
@@ -485,7 +460,7 @@ with block:
485
  mp4_crf = gr.Slider(label="MP4 Compression", minimum=0, maximum=100, value=16, step=1, info="Lower means better quality. 0 is uncompressed. Change to 16 if you get black outputs. ")
486
 
487
  with gr.Accordion("Debug", open=False):
488
- input_image_debug = gr.ImageEditor(type="numpy", label="Image Debug", height=320, brush=gr.Brush(colors=["#ffffff"]))
489
  prompt_debug = gr.Textbox(label="Prompt Debug", value='')
490
  total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (Seconds) Debug", minimum=1, maximum=120, value=5, step=0.1)
491
 
 
385
  default_height, default_width = 640, 640
386
  input_image = np.ones((default_height, default_width, 3), dtype=np.uint8) * 255
387
  print("No input image provided. Using a blank white image.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
 
389
  yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True)
390
 
 
429
  """)
430
  with gr.Row():
431
  with gr.Column():
432
+ input_image = gr.Image(sources='upload', type="numpy", label="Image", height=320)
433
  prompt = gr.Textbox(label="Prompt", value='')
434
  t2v = gr.Checkbox(label="do text-to-video", value=False)
435
  example_quick_prompts = gr.Dataset(samples=quick_prompts, label='Quick List', samples_per_page=1000, components=[prompt])
 
460
  mp4_crf = gr.Slider(label="MP4 Compression", minimum=0, maximum=100, value=16, step=1, info="Lower means better quality. 0 is uncompressed. Change to 16 if you get black outputs. ")
461
 
462
  with gr.Accordion("Debug", open=False):
463
+ input_image_debug = gr.Image(type="numpy", label="Image Debug", height=320)
464
  prompt_debug = gr.Textbox(label="Prompt Debug", value='')
465
  total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (Seconds) Debug", minimum=1, maximum=120, value=5, step=0.1)
466