Repository navigation
One obsession text encoder #14857
Replies: 3 comments 2 replies
|
The component names in that checkpoint ( I checked what's actually in diffusers 0.40.0 ( from diffusers import QwenImageTransformer2DModel
transformer = QwenImageTransformer2DModel.from_single_file("Ob_animaV4.safetensors") # works
from diffusers import AutoencoderKLQwenImage
AutoencoderKLQwenImage.from_single_file("qwen_image_vae.safetensors")
# ValueError: FromOriginalModelMixin is currently only compatible with StableCascadeUNet,
# UNet2DConditionModel, AutoencoderKL, ... (QwenImageTransformer2DModel is in the list, this VAE isn't)The workaround I actually got working is building the VAE from its published config and loading the safetensors weights into it directly, bypassing from diffusers import AutoencoderKLQwenImage
from safetensors.torch import load_file
cfg = AutoencoderKLQwenImage.load_config("Qwen/Qwen-Image", subfolder="vae")
vae = AutoencoderKLQwenImage.from_config(cfg)
result = vae.load_state_dict(load_file("qwen_image_vae.safetensors"))
print(result) # <All keys matched successfully>That loaded with zero missing and zero unexpected keys, strict load, no manual key renaming needed. If your
pipe = QwenImagePipeline(transformer=transformer, vae=vae, text_encoder=..., tokenizer=..., scheduler=...)The part I'd flag before you go further: |
|
Anima is a Cosmos Predict2 finetune, so CosmosTransformer3DModel is right. That error isn't about missing weights, it's import torch
from transformers import AutoModelForTextEncoding
from diffusers import AutoPipelineForText2Video
text_encoder = AutoModelForTextEncoding.from_pretrained(
"nvidia/Cosmos-Predict2-2B-Text2World"
subfolder="text_encoder"
torch_dtype=torch.bfloat16
)
pipe = AutoPipelineForText2Video.from_single_file(
"one-obsession.safetensors"
text_encoder=text_encoder
torch_dtype=torch.bfloat16
)If it complains about vae next, same trick: load it from that same nvidia repo and pass — |
|
One Obsession is an Anima finetune, and Anima is not Qwen-Image. Diffusers supports it as a modular pipeline ( There is no
import torch
from safetensors.torch import load_file
from transformers import AutoConfig, Qwen3Model
from diffusers import ModularPipeline, CosmosTransformer3DModel, AnimaTextConditioner
BASE = "circlestone-labs/Anima-Base-v1.0-Diffusers"
ckpt = "oneObsessionAnima_v40.safetensors"
te_ckpt = "oneObsessionAnima_v40_txt.safetensors"
dtype = torch.bfloat16
transformer = CosmosTransformer3DModel.from_single_file(
ckpt, config=BASE, subfolder="transformer", torch_dtype=dtype
)
sd = load_file(ckpt)
adapter = {k.removeprefix("net.llm_adapter."): v for k, v in sd.items() if k.startswith("net.llm_adapter.")}
text_conditioner = AnimaTextConditioner.from_config(
AnimaTextConditioner.load_config(BASE, subfolder="text_conditioner")
)
text_conditioner.load_state_dict(adapter, strict=True)
te_sd = {k.removeprefix("model."): v for k, v in load_file(te_ckpt).items()}
text_encoder = Qwen3Model(AutoConfig.from_pretrained(BASE, subfolder="text_encoder"))
text_encoder.load_state_dict(te_sd, strict=True)
pipe = ModularPipeline.from_pretrained(BASE)
pipe.load_components(names=["tokenizer", "t5_tokenizer", "vae", "scheduler"], dtype=dtype)
pipe.update_components(
transformer=transformer,
text_conditioner=text_conditioner.to(dtype),
text_encoder=text_encoder.to(dtype),
)
pipe.to("cuda")
image = pipe(
prompt="masterpiece, best quality, 1girl, solo, city lights",
negative_prompt="worst quality, low quality, blurry, jpeg artifacts",
).images[0]I ran this on diffusers 0.41.0 with the original ComfyUI style Anima files. Those use the same layout as the Civitai ones:
Two notes:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
https://civitai.com/models/2695493/one-obsessionanima
how can we load this model using diffuser it has textencoder and vae but
do we have to use CosmosTransformer3DModel ,
but i dont understand they have text encoder as well as vae and diffuser dont seems to have singlefile support ?
All reactions