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

[SVD] fix a bug when passing image as tensor #6999

Merged
merged 2 commits into from
Feb 18, 2024
Merged

[SVD] fix a bug when passing image as tensor #6999

merged 2 commits into from
Feb 18, 2024

Conversation

yiyixuxu
Copy link
Collaborator

@yiyixuxu yiyixuxu commented Feb 16, 2024

fix #6574

when user passes image input as a tensor with range [0,1] (not normalized), we still have to pass it through the CLIP Image Processor before encode it with image encoder

this script now works as expected

import torch
from diffusers import StableVideoDiffusionPipeline
from diffusers.utils import load_image, export_to_video

pipe = StableVideoDiffusionPipeline.from_pretrained(
    "stabilityai/stable-video-diffusion-img2vid-xt", torch_dtype=torch.float16, variant="fp16"
)
pipe.enable_model_cpu_offload()

# Load the conditioning image
image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/svd/rocket.png")
image = image.resize((1024, 576))
image = pipe.image_processor.pil_to_numpy(image)  # to np
image = pipe.image_processor.numpy_to_pt(image)  # to pt


generator = torch.manual_seed(42)
frames = pipe(image, decode_chunk_size=8, generator=generator).frames[0]
export_to_video(frames, "out.mp4", fps=7)
yiyi_test_6_out.mp4

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@DN6 DN6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍🏽

@yiyixuxu yiyixuxu merged commit 8974c50 into main Feb 18, 2024
15 checks passed
@yiyixuxu yiyixuxu deleted the fix-svd-img branch February 18, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FutureWarning: expected range[0,1] tensor in SVD pipeline
3 participants