Working Image level Luma Wipe

Still has debug code
- Amended due to missing blend edge color
exit_image
Charles Fettinger 2023-05-12 23:23:08 -07:00
parent 3c54697ba0
commit 938a8aaefc
4 changed files with 25 additions and 11 deletions

View File

@ -864,6 +864,7 @@ def PSLumaWipe2(a_color, b_color, luma, l_color=(255, 255, 0, 255), progress=0.0
out_color_comp = Image.alpha_composite(a_out_color, b_out_color)
# ensure that the composited images have transparency
a_color.putalpha(ImageOps.invert(b_color_alpha))
#a_color.show("a_color b_color_alpha")
final_image = Image.alpha_composite(a_color, out_color_comp)
#end = timer()

View File

@ -1,6 +1,6 @@
import math, time, os
import numpy as np
from PIL import Image, ImageFilter, ImageDraw
from PIL import Image, ImageFilter, ImageDraw, ImageColor
from modules.ui import plaintext_to_html
import modules.shared as shared
from modules.processing import Processed, StableDiffusionProcessing
@ -208,6 +208,7 @@ def create_zoom(
blend_mode,
blend_gradient_size,
blend_invert_do,
blend_color,
inpainting_denoising_strength=1,
inpainting_full_res=0,
inpainting_padding=0,
@ -243,6 +244,7 @@ def create_zoom(
blend_mode,
blend_gradient_size,
blend_invert_do,
blend_color,
inpainting_denoising_strength,
inpainting_full_res,
inpainting_padding,
@ -318,6 +320,7 @@ def create_zoom_single(
blend_mode,
blend_gradient_size,
blend_invert_do,
blend_color,
inpainting_denoising_strength,
inpainting_full_res,
inpainting_padding,
@ -546,6 +549,7 @@ def create_zoom_single(
blend_image,
blend_mode,
blend_gradient_size,
ImageColor.getcolor(blend_color, "RGBA"),
)
print("Video saved in: " + os.path.join(script_path, out_config["video_filename"]))
return (

View File

@ -229,6 +229,7 @@ def on_ui_tabs():
value="Luma Wipe",
type="index",
)
blend_invert_do = gr.Checkbox(False, label="Reverse Blend/Wipe")
with gr.Row():
blend_gradient_size = gr.Slider(
label="Blend Gradient size",
@ -237,13 +238,20 @@ def on_ui_tabs():
value=default_gradient_size,
step=1
)
blend_invert_do = gr.Checkbox(False, label="Reverse Blend/Wipe")
gr.Markdown(
"""# Important Blend Info:
Number of Start and Stop Frame Duplication number of frames used for the blend/wipe effect. At 30 Frames per second, 30 frames is 1 second.
Blend Gradient size determines if blends extend to the border of the images. 61 is typical, higher values may result in frames around steps of your video
"""
)
blend_color = gr.ColorPicker(
label='Blend Edge Color',
default='#ffff00'
)
with gr.Accordion("Blend Info"):
gr.Markdown(
"""# Important Blend Info:
Number of Start and Stop Frame Duplication number of frames used for the blend/wipe effect. At 30 Frames per second, 30 frames is 1 second.
Blend Gradient size determines if blends extend to the border of the images. 61 is typical, higher values may result in frames around steps of your video
Free to use grayscale blend images can be found here: https://github.com/Oncorporation/obs-studio/tree/master/plugins/obs-transitions/data/luma_wipes
Ideas for custom blend images: https://www.pexels.com/search/gradient/
"""
)
with gr.Tab("Outpaint"):
inpainting_mask_blur = gr.Slider(
@ -326,6 +334,7 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler.
blend_mode,
blend_gradient_size,
blend_invert_do,
blend_color,
],
outputs=[output_video, out_image, generation_info, html_info, html_log],
)

View File

@ -3,7 +3,7 @@ import imageio
from .image import draw_gradient_ellipse, alpha_composite_images, blend_images, PSLumaWipe_images2
import math
def write_video(file_path, frames, fps, reversed=True, start_frame_dupe_amount=15, last_frame_dupe_amount=30, num_interpol_frames=2, blend_invert: bool = False, blend_image= None, blend_type:int = 0, blend_gradient_size: int = 63):
def write_video(file_path, frames, fps, reversed=True, start_frame_dupe_amount=15, last_frame_dupe_amount=30, num_interpol_frames=2, blend_invert: bool = False, blend_image= None, blend_type:int = 0, blend_gradient_size: int = 63, blend_color = "#ffff00"):
"""
Writes frames to an mp4 video file
:param file_path: Path to output video, must end with .mp4
@ -34,7 +34,7 @@ def write_video(file_path, frames, fps, reversed=True, start_frame_dupe_amount=1
elif blend_type == 2:
start_frames = alpha_composite_images(frames[0], next_frame, blend_image, math.ceil(start_frame_dupe_amount), blend_invert)
elif blend_type == 3:
start_frames = PSLumaWipe_images2(frames[0], next_frame, blend_image, math.ceil(start_frame_dupe_amount), blend_invert,(255,255,0,225))
start_frames = PSLumaWipe_images2(frames[0], next_frame, blend_image, math.ceil(start_frame_dupe_amount), blend_invert,blend_color)
del frames[:num_frames_replaced]
print(f"Blending end: {math.ceil(last_frame_dupe_amount)} next to last frame:{-1 * (num_frames_replaced)}")
@ -43,7 +43,7 @@ def write_video(file_path, frames, fps, reversed=True, start_frame_dupe_amount=1
elif blend_type == 2:
end_frames = alpha_composite_images(next_to_last_frame, frames[-1], blend_image, math.ceil(last_frame_dupe_amount), blend_invert)
elif blend_type == 3:
end_frames = PSLumaWipe_images2(next_to_last_frame, frames[-1], blend_image, math.ceil(last_frame_dupe_amount), blend_invert, (255,255,0,225))
end_frames = PSLumaWipe_images2(next_to_last_frame, frames[-1], blend_image, math.ceil(last_frame_dupe_amount), blend_invert, blend_color)
frames = frames[:(-1 * num_frames_replaced)]
else:
start_frames = [frames[0]] * start_frame_dupe_amount