From c98aa7e587b7608fb2c5ff2297508b47d118edae Mon Sep 17 00:00:00 2001 From: JPABotermans <45882689+JPABotermans@users.noreply.github.com> Date: Thu, 26 Sep 2024 01:04:37 +0200 Subject: [PATCH] Changed from imagio to cv2 --- scripts/sampling/simple_video_sample.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/sampling/simple_video_sample.py b/scripts/sampling/simple_video_sample.py index cb01abc3..a61ff0a1 100644 --- a/scripts/sampling/simple_video_sample.py +++ b/scripts/sampling/simple_video_sample.py @@ -168,10 +168,7 @@ def sample( if h % 64 != 0 or w % 64 != 0: width, height = map(lambda x: x - x % 64, (w, h)) - if image.mode == "RGBA": - input_image = input_image.resize((width, height)) - else: - input_image = image.resize((width, height)) + input_image = input_image.resize((width, height)) print( f"WARNING: Your image is of size {h}x{w} which is not divisible by 64. We are resizing to {height}x{width}!" ) @@ -273,8 +270,20 @@ def denoiser(input, sigma, c): .numpy() .astype(np.uint8) ) + frames = [frame for frame in vid] video_path = os.path.join(output_folder, f"{base_count:06d}.mp4") - imageio.mimwrite(video_path, vid) + fourcc = cv2.VideoWriter_fourcc(*'mp4v') # Specify the codec for MP4 + + # Step 3: Create a VideoWriter object + video_writer = cv2.VideoWriter(video_path, fourcc, fps_id, (width, height)) + + # Step 4: Write frames to the video + for frame in frames: + video_writer.write(frame) # Write each frame to the video + + # Step 5: Release the VideoWriter + video_writer.release() + def get_unique_embedder_keys_from_conditioner(conditioner):