Upload modular_blocks.py with huggingface_hub
Browse files- modular_blocks.py +57 -0
modular_blocks.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from diffusers.modular_pipelines import SequentialPipelineBlocks
|
| 2 |
+
from diffusers.modular_pipelines.modular_pipeline_utils import InsertableDict
|
| 3 |
+
from diffusers.modular_pipelines.wan.decoders import WanDecodeStep
|
| 4 |
+
|
| 5 |
+
from before_denoise import ChronoEditPrepareLatentStep, ChronoEditSetTimestepsStep
|
| 6 |
+
from denoise import ChronoEditDenoiseStep
|
| 7 |
+
from inputs import ChronoEditImageInputStep, ChronoEditInputStep
|
| 8 |
+
from encoders import ChronoEditImageEncoderStep, ChronoEditProcessImageStep, ChronoEditTextEncoderStep
|
| 9 |
+
from decoders import ChronoEditDecodeStep
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class ChronoEditBeforeDenoiseStep(SequentialPipelineBlocks):
|
| 13 |
+
block_classes = [
|
| 14 |
+
ChronoEditInputStep,
|
| 15 |
+
ChronoEditSetTimestepsStep,
|
| 16 |
+
ChronoEditImageInputStep,
|
| 17 |
+
ChronoEditImageEncoderStep,
|
| 18 |
+
ChronoEditProcessImageStep,
|
| 19 |
+
ChronoEditPrepareLatentStep,
|
| 20 |
+
]
|
| 21 |
+
block_names = [
|
| 22 |
+
"input",
|
| 23 |
+
"set_timesteps",
|
| 24 |
+
"image_input_resolution",
|
| 25 |
+
"encode_image",
|
| 26 |
+
"process_image_for_latent_prep",
|
| 27 |
+
"prepare_latent",
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def description(self):
|
| 32 |
+
return (
|
| 33 |
+
"Before denoise step that prepare the inputs for the denoise step.\n"
|
| 34 |
+
+ "This is a sequential pipeline blocks:\n"
|
| 35 |
+
+ " - `ChronoEditSetTimestepsStep` is used to set timesteps\n"
|
| 36 |
+
+ " - `ChronoEditImageInputStep` is used to set the image resolution\n"
|
| 37 |
+
+ " - `ChronoEditImageEncoderStep` is used to derive image embeddings for conditioning\n"
|
| 38 |
+
+ " - `ChronoEditProcessImageStep` is used to process the image for latent preparation\n"
|
| 39 |
+
+ " - `ChronoEditPrepareLatentStep` is used to prepare the latents"
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
EDIT_BLOCKS = InsertableDict(
|
| 44 |
+
[
|
| 45 |
+
("text_encoder", ChronoEditTextEncoderStep),
|
| 46 |
+
("before_denoise", ChronoEditBeforeDenoiseStep),
|
| 47 |
+
("denoise", ChronoEditDenoiseStep),
|
| 48 |
+
("decode", ChronoEditDecodeStep),
|
| 49 |
+
]
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
ALL_BLOCKS = {"img2img": EDIT_BLOCKS}
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
class ChronoEditBlocks(SequentialPipelineBlocks):
|
| 56 |
+
block_classes = list(EDIT_BLOCKS.copy().values())
|
| 57 |
+
block_names = list(EDIT_BLOCKS.copy().keys())
|