Diffusers documentation
Anima
Anima
Anima は、CosmosTransformer3DModel を再利用するテキストから画像を生成するモデルであり、Qwen3 テキストエンコーダー、T5 トークンベースのテキストコンディショナー、および AutoencoderKLQwenImage VAE を使用します。
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
class diffusers.AnimaModularPipeline
< source >( 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
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 ジェネレーター。
num_images_per_prompt (int, 任意, デフォルトは 1):
プロンプトごとに生成する画像の数。
image_latents (Tensor, 任意):
画像生成をガイドするために使用される image latents。vae_encoder ステップから生成できます。
num_inference_steps (int):
デノイジングのステップ数。
sigmas (list, 任意):
デノイジングプロセス用のカスタムシグマ。
strength (float, 任意, デフォルトは 0.9):
img2img / インペインティングの強度。
latents (Tensor):
画像生成用の事前生成されたノイジーな latents。
*denoiser_input_fields (None,任意):
Anima デノイザー用の条件付きモデルの入力。
output_type (str,任意*, デフォルトは pil):
出力形式: ‘pil’、‘np’、‘pt’。
出力:
images (list):
生成された画像。
AnimaTextConditioner
class diffusers.AnimaTextConditioner
< source >( 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 アダプターのみです。このアダプターは、拡散ループの前に、学習された T5 トークン埋め込みから Qwen3 テキストエンコーダーの隠れ状態へクロスアテンションを行います。target_dim は条件付けモジュールの出力次元であり、transformer の text_embed_dim と一致する必要があります。
forward
< source >( 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、形状(batch_size, source_sequence_length, source_dim)) — 条件付けに使用する Qwen3 テキストエンコーダーの隠れ状態。 - target_input_ids (
torch.Tensor、shape(batch_size, target_sequence_length)) — 学習済みクエリトークンとして使用される T5 のトークン ID。 - target_attention_mask (
torch.Tensor, 任意) — ターゲットの T5 トークン ID 用のアテンションマスク。 - source_attention_mask (
torch.Tensor, 任意) — ソースの Qwen3 隠れ状態用のアテンションマスク。
戻り値
torch.Tensor
Cosmos transformer用のテキスト条件付け埋め込み。