Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix video writing issue #326 #327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
14 changes: 12 additions & 2 deletions scripts/sampling/simple_video_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
from omegaconf import OmegaConf
from PIL import Image
from rembg import remove
from torchvision.transforms import ToTensor

from scripts.util.detection.nsfw_and_watermark_dectection import DeepFloydDataFiltering
from sgm.inference.helpers import embed_watermark
from sgm.util import default, instantiate_from_config
from torchvision.transforms import ToTensor


def sample(
Expand Down Expand Up @@ -271,7 +272,16 @@ def denoiser(input, sigma, c):
.astype(np.uint8)
)
video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
imageio.mimwrite(video_path, vid)
frame0 = vid[0, :, :, :].squeeze()
out = cv2.VideoWriter(
video_path,
cv2.VideoWriter_fourcc(*"MP4V"),
20.0,
(frame0.shape[1], frame0.shape[0]),
)
for frame in vid:
out.write(frame[:, :, ::-1])
out.release()


def get_unique_embedder_keys_from_conditioner(conditioner):
Expand Down