Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion scripts/sampling/simple_video_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ def sample(
with Image.open(input_img_path) as image:
if image.mode == "RGBA":
input_image = image.convert("RGB")
else:
input_image = image.copy()
w, h = image.size

if h % 64 != 0 or w % 64 != 0:
Expand Down Expand Up @@ -270,8 +272,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, (w,h))

# Step 4: Write frames to the video
for frame in frames:
video_writer.write(frame[..., ::-1]) # Write each frame to the video and convert to BGR

# Step 5: Release the VideoWriter
video_writer.release()



def get_unique_embedder_keys_from_conditioner(conditioner):
Expand Down