File size: 1,867 Bytes
d80ed59
44ad3d9
 
 
 
 
d80ed59
44ad3d9
d80ed59
 
 
 
 
44ad3d9
 
 
 
 
 
 
 
 
 
 
 
 
 
d80ed59
 
44ad3d9
 
 
 
d80ed59
 
44ad3d9
d80ed59
 
 
 
44ad3d9
 
 
 
d80ed59
 
 
 
44ad3d9
d80ed59
 
 
44ad3d9
d80ed59
 
44ad3d9
 
 
 
d80ed59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from diffusers.modular_pipelines import ModularPipelineBlocks, PipelineState
from diffusers.modular_pipelines.modular_pipeline_utils import (
    ComponentSpec,
    InputParam,
    OutputParam,
)

from .modeling_prunavae import PrunaAutoencoderKLLTX2Video


class LoadPrunaVAE(ModularPipelineBlocks):
    model_name = "PrunaVAED"

    def __init__(
        self,
        pretrained_model_name_or_path: str = "AINovice2005/pruna-vaed-modular-diffusers",
        subfolder: str | None = None,
        revision: str | None = None,
        variant: str | None = None,
    ):
        super().__init__()

        self.pretrained_model_name_or_path = pretrained_model_name_or_path
        self.subfolder = subfolder
        self.revision = revision
        self.variant = variant

    @property
    def description(self) -> str:
        return (
            "Loads a PrunaAutoencoderKLLTX2Video from the Hugging Face Hub "
            "and exposes it as `components.vae`."
        )

    @property
    def expected_components(self):
        return [
            ComponentSpec(
                "vae",
                PrunaAutoencoderKLLTX2Video,
                pretrained_model_name_or_path=self.pretrained_model_name_or_path,
                subfolder=self.subfolder,
                revision=self.revision,
                variant=self.variant,
            )
        ]

    @property
    def inputs(self):
        return []

    @property
    def intermediate_outputs(self):
        return []

    def __call__(self, components, state):
        # Nothing to compute here -- this block's only role is to make # `components.vae` 
        #(a PrunaAutoencoderKLLTX2Video) available to # every block downstream in the pipeline. 
        #Blocks that actually # need it (e.g. a decode step) read it directly off `components`, # not off `state`.
        return components, state