Views
No views yet
WanCameraControlTransformer3DModel class (included in this repo) that extends diffusers' WanTransformer3DModel with a camera control adapter.1import torch
2from huggingface_hub import hf_hub_download, snapshot_download
3
4REPO = "the-sweater-cat/Wan2.1-Fun-V1.1-1.3B-Control-Camera-Diffusers"
5
6# Download the custom model class and import it
7import importlib.util, sys
8spec = importlib.util.spec_from_file_location(
9 "modeling_wan_camera",
10 hf_hub_download(REPO, "modeling_wan_camera.py"))
11mod = importlib.util.module_from_spec(spec)
12spec.loader.exec_module(mod)
13
14# Load transformer with camera adapter
15transformer = mod.WanCameraControlTransformer3DModel.from_pretrained(
16 REPO, subfolder="transformer", torch_dtype=torch.bfloat16)
17
18# Load other pipeline components
19from diffusers import AutoencoderKLWan
20from transformers import CLIPVisionModel, UMT5EncoderModel, AutoTokenizer
21
22vae = AutoencoderKLWan.from_pretrained(REPO, subfolder="vae", torch_dtype=torch.bfloat16)
23text_encoder = UMT5EncoderModel.from_pretrained(REPO, subfolder="text_encoder", torch_dtype=torch.bfloat16)
24image_encoder = CLIPVisionModel.from_pretrained(REPO, subfolder="image_encoder", torch_dtype=torch.bfloat16)
25tokenizer = AutoTokenizer.from_pretrained(REPO, subfolder="tokenizer")1import sys, torch
2sys.path.insert(0, "Wan2.1-Fun-V1.1-1.3B-Control-Camera-Diffusers")
3from modeling_wan_camera import WanCameraControlTransformer3DModel
4
5transformer = WanCameraControlTransformer3DModel.from_pretrained(
6 "Wan2.1-Fun-V1.1-1.3B-Control-Camera-Diffusers/transformer",
7 torch_dtype=torch.bfloat16)PixelUnshuffle(8) -- spatial downscale from pixel to latent resolutionConv2d(1536, 1536, k=2, s=2) -- matches patch embedding strideResidualBlock(1536) -- conv3x3 + ReLU + conv3x3 + skip1output = transformer(
2 hidden_states=latents, # [B, 32, F, H, W] noise + image latents
3 timestep=timestep, # [B] diffusion timestep
4 encoder_hidden_states=text_emb, # [B, 512, 4096] text embeddings
5 encoder_hidden_states_image=clip_emb, # [B, 257, 1280] CLIP image tokens
6 control_camera_video=camera_emb, # [B, 24, F, H*8, W*8] Plucker rays at pixel res
7 return_dict=False,
8)[0]process_pose_file() or ray_condition() utilities from camera extrinsic matrices.| File / Directory | Description | Size |
|---|---|---|
modeling_wan_camera.py | Custom model class (also in transformer/) | 6 KB |
transformer/ | Converted transformer weights + config | 3.0 GB |
text_encoder/ | UMT5-XXL text encoder | 21 GB |
image_encoder/ | CLIP ViT-H image encoder | 1.2 GB |
vae/ | Wan2.1 VAE | 485 MB |
tokenizer/ | UMT5 tokenizer | 21 MB |
scheduler/ | UniPCMultistepScheduler config | 1 KB |
image_processor/ | CLIPImageProcessor config | 1 KB |
model_index.json | Pipeline component index | 1 KB |