AINovice2005 commited on
Commit
44ad3d9
·
verified ·
1 Parent(s): bd79d92

Update block.py

Browse files
Files changed (1) hide show
  1. block.py +35 -16
block.py CHANGED
@@ -1,41 +1,60 @@
1
  from diffusers.modular_pipelines import ModularPipelineBlocks, PipelineState
2
- from diffusers.modular_pipelines.modular_pipeline_utils import ComponentSpec, InputParam, OutputParam
 
 
 
 
3
 
4
- try:
5
- from .modeling_prunavae import PrunaAutoencoderKLLTX2Video
6
- except ImportError:
7
- from modeling_prunavae import PrunaAutoencoderKLLTX2Video
8
 
9
 
10
  class LoadPrunaVAE(ModularPipelineBlocks):
11
  model_name = "PrunaVAED"
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  @property
14
  def description(self) -> str:
15
- return "Declares the Pruna LTX-2 VAE as an expected pipeline component."
 
 
 
16
 
17
  @property
18
- def expected_components(self) -> list[ComponentSpec]:
19
  return [
20
  ComponentSpec(
21
  "vae",
22
  PrunaAutoencoderKLLTX2Video,
23
- pretrained_model_name_or_path="AINovice2005/pruna-vaed-modular-diffusers",
 
 
 
24
  )
25
  ]
26
 
27
  @property
28
- def inputs(self) -> list[InputParam]:
29
  return []
30
 
31
  @property
32
- def intermediate_outputs(self) -> list[OutputParam]:
33
  return []
34
 
35
- def __call__(self, components, state: PipelineState):
36
- # Nothing to compute here -- this block's only role is to make
37
- # `components.vae` (a PrunaAutoencoderKLLTX2Video) available to
38
- # every block downstream in the pipeline. Blocks that actually
39
- # need it (e.g. a decode step) read it directly off `components`,
40
- # not off `state`.
41
  return components, state
 
1
  from diffusers.modular_pipelines import ModularPipelineBlocks, PipelineState
2
+ from diffusers.modular_pipelines.modular_pipeline_utils import (
3
+ ComponentSpec,
4
+ InputParam,
5
+ OutputParam,
6
+ )
7
 
8
+ from .modeling_prunavae import PrunaAutoencoderKLLTX2Video
 
 
 
9
 
10
 
11
  class LoadPrunaVAE(ModularPipelineBlocks):
12
  model_name = "PrunaVAED"
13
 
14
+ def __init__(
15
+ self,
16
+ pretrained_model_name_or_path: str = "AINovice2005/pruna-vaed-modular-diffusers",
17
+ subfolder: str | None = None,
18
+ revision: str | None = None,
19
+ variant: str | None = None,
20
+ ):
21
+ super().__init__()
22
+
23
+ self.pretrained_model_name_or_path = pretrained_model_name_or_path
24
+ self.subfolder = subfolder
25
+ self.revision = revision
26
+ self.variant = variant
27
+
28
  @property
29
  def description(self) -> str:
30
+ return (
31
+ "Loads a PrunaAutoencoderKLLTX2Video from the Hugging Face Hub "
32
+ "and exposes it as `components.vae`."
33
+ )
34
 
35
  @property
36
+ def expected_components(self):
37
  return [
38
  ComponentSpec(
39
  "vae",
40
  PrunaAutoencoderKLLTX2Video,
41
+ pretrained_model_name_or_path=self.pretrained_model_name_or_path,
42
+ subfolder=self.subfolder,
43
+ revision=self.revision,
44
+ variant=self.variant,
45
  )
46
  ]
47
 
48
  @property
49
+ def inputs(self):
50
  return []
51
 
52
  @property
53
+ def intermediate_outputs(self):
54
  return []
55
 
56
+ def __call__(self, components, state):
57
+ # Nothing to compute here -- this block's only role is to make # `components.vae`
58
+ #(a PrunaAutoencoderKLLTX2Video) available to # every block downstream in the pipeline.
59
+ #Blocks that actually # need it (e.g. a decode step) read it directly off `components`, # not off `state`.
 
 
60
  return components, state