Skip to content

WanImageToVideoPipeline update to work with offloading #11162

@vladmandic

Description

@vladmandic

Describe the bug

Currently WAN I2V fails with offloaded model since image_processor returns image tensors on cpu while image_encoder gets moved to gpu by accelerate hook according to execution_device.

This simple patch fixes it by setting device explicitly
in pipelines/wan/pipeline_wan_i2v.py:

    def encode_image(
        self,
        image: PipelineImageInput,
        device: Optional[torch.device] = None,
    ):
        device = device or self._execution_device
        image = self.image_processor(images=image, return_tensors="pt").to(device)
        image_embeds = self.image_encoder(**image, output_hidden_states=True)
        return image_embeds.hidden_states[-2]

Reproduction

N/A

Logs

System Info

diffusers==main

Who can help?

@DN6 @a-r-r-o-w @hlky

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions