Diffusers documentation

Anima

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Anima

Anima는 Qwen3 텍스트 인코더, T5-token 텍스트 컨디셔너, AutoencoderKLQwenImage VAE와 함께 CosmosTransformer3DModel을 재사용하는 텍스트-이미지 생성 모델입니다.

import torch
from diffusers import ModularPipeline

pipe = ModularPipeline.from_pretrained("circlestone-labs/Anima-Base-v1.0-Diffusers")
pipe.load_components(dtype=torch.bfloat16)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

image = pipe(prompt="masterpiece, best quality, 1girl, solo, city lights").images[0]

AnimaModularPipeline

클래스 diffusers.AnimaModularPipeline

< >

( blocks: diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = Nonepretrained_model_name_or_path: str | os.PathLike | None = Nonecomponents_manager: diffusers.modular_pipelines.components_manager.ComponentsManager | None = Nonecollection: str | None = Noneworkflow: str | None = Nonemodular_config_dict: dict[str, typing.Any] | None = Noneconfig_dict: dict[str, typing.Any] | None = None**kwargs )

Anima용 ModularPipeline.

AnimaAutoBlocks

클래스 diffusers.AnimaAutoBlocks

< >

( )

Anima를 사용하여 텍스트-이미지 및 이미지-이미지 생성을 위한 Auto Modular 파이프라인.

지원되는 워크플로:

  • text2image: prompt 필수
  • img2img: image, prompt 필수

구성 요소: text_encoder (Qwen3Model) tokenizer (Qwen2Tokenizer) t5_tokenizer (T5Tokenizer) guider (ClassifierFreeGuidance) vae (AutoencoderKLQwenImage) image_processor (VaeImageProcessor) text_conditioner (AnimaTextConditioner) transformer (CosmosTransformer3DModel) scheduler (FlowMatchEulerDiscreteScheduler)

입력: prompt (str): 이미지 생성을 안내할 프롬프트입니다. negative_prompt (str, 선택 사항): 이미지 생성을 안내하지 않을 프롬프트입니다. max_sequence_length (int, 선택 사항, 기본값 512): 프롬프트 인코딩을 위한 최대 시퀀스 길이입니다. image (Image | list, 선택 사항): 디노이징을 위한 참조 이미지입니다. 단일 이미지 또는 이미지 목록일 수 있습니다. height (int, 선택 사항): 생성된 이미지의 픽셀 단위 높이입니다. width (int, 선택 사항): 생성된 이미지의 픽셀 단위 너비입니다. generator (Generator, 선택 사항): 결정론적 생성을 위한 Torch generator입니다. num_images_per_prompt (int, 선택 사항, 기본값 1): 프롬프트당 생성할 이미지의 수입니다. image_latents (Tensor, 선택 사항): 이미지 생성을 안내하는 데 사용되는 image latents입니다. vae_encoder 단계에서 생성할 수 있습니다. num_inference_steps (int): 디노이징 단계의 수입니다. sigmas (list, 선택 사항): 디노이징 프로세스를 위한 사용자 지정 sigmas입니다. strength (float, 선택 사항, 기본값 0.9): img2img/inpainting의 강도입니다. latents (Tensor): 이미지 생성을 위한 사전 생성된 노이즈 latents입니다. *denoiser_input_fields (None,선택 사항): Anima denoiser의 조건부 모델 입력입니다. output_type (str,선택 사항*, 기본값 pil): 출력 형식: ‘pil’, ‘np’, ‘pt’.

출력: images (list): 생성된 이미지.

AnimaTextConditioner

클래스 diffusers.AnimaTextConditioner

< >

( source_dim: int = 1024target_dim: int = 1024model_dim: int = 1024num_layers: int = 6num_attention_heads: int = 16mlp_ratio: float = 4.0target_vocab_size: int = 32128use_self_attention: bool = Trueuse_layer_norm: bool = Falsemin_sequence_length: int = 512 )

Anima가 Qwen3의 숨겨진 상태와 T5의 토큰 ID를 Cosmos 텍스트 임베딩으로 매핑하는 데 사용하는 텍스트 컨디셔너입니다.

Anima는 Cosmos Predict2 DiT를 재사용합니다. 모델에 특화된 유일한 조건화 모듈은 이 LLM 어댑터이며, diffusion 루프 전에 학습된 T5 토큰 임베딩에서 Qwen3 텍스트 인코더의 hidden states로 cross-attention을 수행합니다. target_dim은 conditioner의 출력 차원이며 transformer의 text_embed_dim과 일치해야 합니다.

forward

< >

( source_hidden_states: Tensortarget_input_ids: Tensortarget_attention_mask: typing.Optional[torch.Tensor] = Nonesource_attention_mask: typing.Optional[torch.Tensor] = None ) → torch.Tensor

매개변수

  • source_hidden_states (torch.Tensor, shape (batch_size, source_sequence_length, source_dim)) — 조건부로 사용할 Qwen3 텍스트 인코더의 hidden states입니다.
  • target_input_ids (torch.Tensor, shape (batch_size, target_sequence_length)) — 학습된 query token으로 사용되는 T5 token id입니다.
  • target_attention_mask (torch.Tensor, 선택 사항) — 타겟 T5 토큰 ID에 대한 어텐션 마스크입니다.
  • source_attention_mask (torch.Tensor, 선택 사항) — 소스 Qwen3 hidden states에 대한 attention mask입니다.

반환값

torch.Tensor

Cosmos transformer의 텍스트 조건화 임베딩.

Update on GitHub