Run this model with HF Jobs
Run diffusers-internal-dev/chronoedit-modular on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/diffusers-internal-dev/chronoedit-modular. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/diffusers-internal-dev/chronoedit-modular on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use diffusers-internal-dev/chronoedit-modular with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use diffusers-internal-dev/chronoedit-modular with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("diffusers-internal-dev/chronoedit-modular", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse filesFiles changed (11)
- .ruff_cache/.gitignoreAdded+2
- .ruff_cache/0.7.1/3405182261834977827Added
- .ruff_cache/CACHEDIR.TAGAdded+1
- before_denoise.py+7-13
- decoders.py+3-5
- demo.png
- denoise.py+1-1
- encoders.py+2-2
- example.py+6-7
- inputs.py+3-3
- upload_block.pyAdded+11
12# Automatically created by ruff.*1Signature: 8a477f597d28d172789f06886806bc5536 unmodified lines373839404142434445464748495051525318 unmodified lines72737475767778107 unmodified lines18618718818919019119219319419519619719819920020120220310 unmodified lines21421521621721836 unmodified lines@propertydef expected_components(self) -> List[ComponentSpec]:return [ComponentSpec("scheduler", UniPCMultistepScheduler)]@propertydef inputs(self) -> List[InputParam]:return [InputParam("num_inference_steps", default=50),InputParam("timesteps"),InputParam("sigmas")]@propertydef intermediate_outputs(self) -> List[OutputParam]:18 unmodified linesblock_state.timesteps,block_state.sigmas,)self.set_block_state(state, block_state)return components, state107 unmodified lines)mask_lat_size = mask_lat_size.transpose(1, 2)mask_lat_size = mask_lat_size.to(latent_condition.device)return latents, torch.concat([mask_lat_size, latent_condition], dim=1)@torch.no_grad()def __call__(self, components: ModularPipeline, state: PipelineState) -> PipelineState:block_state = self.get_block_state(state)self.check_inputs(block_state.height, block_state.width)block_state.device = components._execution_deviceblock_state.num_channels_latents = components.num_channels_latentsbatch_size = block_state.batch_size * block_state.num_videos_per_promptblock_state.latents, block_state.condition = self.prepare_latents(components,10 unmodified lines)self.set_block_state(state, block_state)return components, state36 unmodified lines373839404142434445464718 unmodified lines66676869707172107 unmodified lines18018118218318418518618718818919019119219319419519619710 unmodified lines20820921021121236 unmodified lines@propertydef expected_components(self) -> List[ComponentSpec]:return [ComponentSpec("scheduler", UniPCMultistepScheduler)]@propertydef inputs(self) -> List[InputParam]:return [InputParam("num_inference_steps", default=50), InputParam("timesteps"), InputParam("sigmas")]@propertydef intermediate_outputs(self) -> List[OutputParam]:18 unmodified linesblock_state.timesteps,block_state.sigmas,)self.set_block_state(state, block_state)return components, state107 unmodified lines)mask_lat_size = mask_lat_size.transpose(1, 2)mask_lat_size = mask_lat_size.to(latent_condition.device)return latents, torch.concat([mask_lat_size, latent_condition], dim=1)@torch.no_grad()def __call__(self, components: ModularPipeline, state: PipelineState) -> PipelineState:block_state = self.get_block_state(state)self.check_inputs(block_state.height, block_state.width)block_state.device = components._execution_deviceblock_state.num_channels_latents = components.num_channels_latentsbatch_size = block_state.batch_size * block_state.num_videos_per_promptblock_state.latents, block_state.condition = self.prepare_latents(components,10 unmodified lines)self.set_block_state(state, block_state)return components, state
13 unmodified lines141516171819202122232425262765 unmodified lines9394959613 unmodified lines# limitations under the License.from diffusers.configuration_utils import FrozenDictfrom diffusers.modular_pipelines import (ModularPipelineBlocks, ComponentSpec, InputParam, OutputParam, PipelineState)from typing import List, Unionfrom diffusers import AutoencoderKLWanfrom diffusers.video_processor import VideoProcessorimport torchimport PILimport numpy as np65 unmodified linesself.set_block_state(state, block_state)return components, state13 unmodified lines14151617181920212223242565 unmodified lines9192939413 unmodified lines# limitations under the License.from diffusers.configuration_utils import FrozenDictfrom diffusers.modular_pipelines import ModularPipelineBlocks, ComponentSpec, InputParam, OutputParam, PipelineStatefrom typing import List, Unionfrom diffusers import AutoencoderKLWanfrom diffusers.video_processor import VideoProcessorimport torchimport PILimport numpy as np65 unmodified linesself.set_block_state(state, block_state)return components, state
189 unmodified lines190191192193194195196189 unmodified lines@torch.no_grad()def __call__(self, components: ModularPipeline, state: PipelineState) -> PipelineState:block_state = self.get_block_state(state)block_state.num_warmup_steps = max(len(block_state.timesteps) - block_state.num_inference_steps * components.scheduler.order, 0)189 unmodified lines190191192193194195196189 unmodified lines@torch.no_grad()def __call__(self, components: ModularPipeline, state: PipelineState) -> PipelineState:block_state = self.get_block_state(state)block_state.num_warmup_steps = max(len(block_state.timesteps) - block_state.num_inference_steps * components.scheduler.order, 0)
87 unmodified lines8889909192939423 unmodified lines11811912012112212312487 unmodified linesdef intermediate_outputs(self) -> List[OutputParam]:return [OutputParam("processed_image", type_hint=PipelineImageInput),OutputParam("image_embeds", type_hint=torch.Tensor)]@property23 unmodified linesblock_state.image_embeds = image_embeds.repeat(batch_size, 1, 1).to(torch.bfloat16)self.set_block_state(state, block_state)return components, state87 unmodified lines8889909192939423 unmodified lines11811912012112212312487 unmodified linesdef intermediate_outputs(self) -> List[OutputParam]:return [OutputParam("processed_image", type_hint=PipelineImageInput),OutputParam("image_embeds", type_hint=torch.Tensor),]@property23 unmodified linesblock_state.image_embeds = image_embeds.repeat(batch_size, 1, 1).to(torch.bfloat16)self.set_block_state(state, block_state)return components, state
1 unmodified line23456789101112131415161718192021222324255 unmodified lines31323334353637381 unmodified lineMimicked from https://huggingface.co/spaces/nvidia/ChronoEdit/blob/main/app.py"""from diffusers.modular_pipelines import ModularPipelineBlocks, WanModularPipelinefrom diffusers.utils import load_imagefrom diffusers import UniPCMultistepSchedulerfrom modular_blocks import ChronoEditBlocksimport torchfrom PIL import Imagerepo_id = "nvidia/ChronoEdit-14B-Diffusers"blocks = ChronoEditBlocks()pipe = WanModularPipeline(blocks, repo_id)pipe.load_components(trust_remote_code=True,device_map="cuda",torch_dtype={"default": torch.bfloat16, "image_encoder": torch.float32},)pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=2.0)pipe.load_lora_weights(repo_id, weight_name="lora/chronoedit_distill_lora.safetensors")pipe.fuse_lora(lora_scale=1.0)image = load_image("https://huggingface.co/spaces/nvidia/ChronoEdit/resolve/main/examples/3.png")5 unmodified linesimage=image,prompt=prompt, # todo: enhance promptnum_inference_steps=8, # todo: implement temporal reasoningnum_frames=5, # https://huggingface.co/spaces/nvidia/ChronoEdit/blob/main/app.py#L152output_type="np",)frames = out.values["videos"][0]Image.fromarray((frames[-1] * 255).clip(0, 255).astype("uint8")).save("demo.png")1 unmodified line2345678910111213141516171819202122235 unmodified lines2930313233343536371 unmodified lineMimicked from https://huggingface.co/spaces/nvidia/ChronoEdit/blob/main/app.py"""from diffusers.modular_pipelines import WanModularPipeline, ModularPipelineBlocksfrom diffusers.utils import load_imagefrom diffusers import UniPCMultistepSchedulerimport torchfrom PIL import Imagerepo_id = "diffusers-internal-dev/chronoedit-modular"blocks = ModularPipelineBlocks.from_pretrained(repo_id, trust_remote_code=True)pipe = WanModularPipeline(blocks, repo_id)pipe.load_components(trust_remote_code=True,device_map="cuda",torch_dtype={"default": torch.bfloat16, "image_encoder": torch.float32},)pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=2.0)pipe.load_lora_weights("nvidia/ChronoEdit-14B-Diffusers", weight_name="lora/chronoedit_distill_lora.safetensors")pipe.fuse_lora(lora_scale=1.0)image = load_image("https://huggingface.co/spaces/nvidia/ChronoEdit/resolve/main/examples/3.png")5 unmodified linesimage=image,prompt=prompt, # todo: enhance promptnum_inference_steps=8, # todo: implement temporal reasoningnum_frames=5, # https://huggingface.co/spaces/nvidia/ChronoEdit/blob/main/app.py#L152output_type="np",generator=torch.manual_seed(0),)frames = out.values["videos"][0]Image.fromarray((frames[-1] * 255).clip(0, 255).astype("uint8")).save("demo.png")
85 unmodified lines868788899091929394959685 unmodified linesblock_state = self.get_block_state(state)image = block_state.imagemod_value = components.vae_scale_factor_spatial * components.transformer.config.patch_size[1]width, height = calculate_dimensions(image, mod_value)block_state.image = image.resize((width, height))block_state.height = heightblock_state.width = widthself.set_block_state(state, block_state)return components, state85 unmodified lines868788899091929394959685 unmodified linesblock_state = self.get_block_state(state)image = block_state.imagemod_value = components.vae_scale_factor_spatial * components.transformer.config.patch_size[1]width, height = calculate_dimensions(image, mod_value)block_state.image = image.resize((width, height))block_state.height = heightblock_state.width = widthself.set_block_state(state, block_state)return components, state
1234567891011from diffusers.modular_pipelines import WanModularPipeline
from modular_blocks import ChronoEditBlocks
repo_id = "nvidia/ChronoEdit-14B-Diffusers"blocks = ChronoEditBlocks()
blocks.push_to_hub("diffusers-internal-dev/chronoedit-modular")
pipe = WanModularPipeline(blocks, repo_id)pipe.push_to_hub("diffusers-internal-dev/chronoedit-modular").ruff_cache/.gitignoreAdded+2
.ruff_cache/0.7.1/3405182261834977827Added
.ruff_cache/CACHEDIR.TAGAdded+1
before_denoise.py+7-13
decoders.py+3-5
demo.png

Large File Pointer Details
- SHA256: c324784d3448ecf10df38c9a097d034c701f3edf6d0917f5adab86ffc2220934
- Pointer size: 131 Bytes
- Size of remote file: 906 kB

Large File Pointer Details
- SHA256: b29c5b280640a727812d58ace45b0ab06cbdd68e2e1cbdef3b3b3d5afd6b8436
- Pointer size: 131 Bytes
- Size of remote file: 897 kB
denoise.py+1-1
encoders.py+2-2
example.py+6-7
inputs.py+3-3
upload_block.pyAdded+11