Team Ai
Modelpublic

diffusers/matrix-game-2-modular

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes14downloads
modular_pipeline.py86 linesDownload Raw Back to root
1# Copyright 2025 The HuggingFace Team. All rights reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7#     http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14 15 16from diffusers.loaders import WanLoraLoaderMixin17from diffusers.utils import logging18from diffusers.modular_pipelines import ModularPipeline19 20 21logger = logging.get_logger(__name__)  # pylint: disable=invalid-name22 23 24class MatrixGameWanModularPipeline(ModularPipeline, WanLoraLoaderMixin):25    """26    A ModularPipeline for MatrixGameWan.27 28    <Tip warning={true}>29 30        This is an experimental feature and is likely to change in the future.31 32    </Tip>33    """34 35    @property36    def default_height(self):37        return self.default_sample_height * self.vae_scale_factor_spatial38 39    @property40    def default_width(self):41        return self.default_sample_width * self.vae_scale_factor_spatial42 43    @property44    def default_num_frames(self):45        return (self.default_sample_num_frames - 1) * self.vae_scale_factor_temporal + 146 47    @property48    def default_sample_height(self):49        return 4450 51    @property52    def default_sample_width(self):53        return 8054 55    @property56    def default_sample_num_frames(self):57        return 2158 59    @property60    def vae_scale_factor_spatial(self):61        vae_scale_factor = 862        if hasattr(self, "vae") and self.vae is not None:63            vae_scale_factor = 2 ** len(self.vae.temperal_downsample)64        return vae_scale_factor65 66    @property67    def vae_scale_factor_temporal(self):68        vae_scale_factor = 469        if hasattr(self, "vae") and self.vae is not None:70            vae_scale_factor = 2 ** sum(self.vae.temperal_downsample)71        return vae_scale_factor72 73    @property74    def num_channels_transformer(self):75        num_channels_transformer = 1676        if hasattr(self, "transformer") and self.transformer is not None:77            num_channels_transformer = self.transformer.config.in_channels78        return num_channels_transformer79 80    @property81    def num_channels_latents(self):82        num_channels_latents = 1683        if hasattr(self, "vae") and self.vae is not None:84            num_channels_latents = self.vae.config.z_dim85        return num_channels_latents86