Diffusers documentation

AnyFlowTransformer3DModel

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

AnyFlowTransformer3DModel

이것이 사용하는 양방향 3D Transformer는 AnyFlowPipeline. v0.35.1 Wan2.1 백본이며, 하나의 구조적 변경 사항이 있습니다. timestep embedder가 AnyFlowDualTimestepTextImageEmbedding, 로 대체되어 모든 forward 호출이 소스 timestep t 과 대상 timestep r. 에 조건부 입력을 받습니다. 이는 Φr←t\Phi_{r\leftarrow t} 에서 도입된 flow map 을 학습하는 데 필요한 임베딩입니다.. 논문, 저자 및 공개된 체크포인트에 대한 자세한 내용은 AnyFlowPipeline 페이지를 참고하세요.

차unk 단위 자기회귀(FAR causal) 생성의 경우, AnyFlowFARTransformer3DModel을 대신 사용하세요.

from diffusers import AnyFlowTransformer3DModel

# Bidirectional AnyFlow checkpoint (T2V):
transformer = AnyFlowTransformer3DModel.from_pretrained(
    "nvidia/AnyFlow-Wan2.1-T2V-1.3B-Diffusers", subfolder="transformer"
)

AnyFlowTransformer3DModel

클래스 diffusers.AnyFlowTransformer3DModel

< >

( patch_size: typing.Tuple[int] = (1, 2, 2)num_attention_heads: int = 40attention_head_dim: int = 128in_channels: int = 16out_channels: int = 16text_dim: int = 4096freq_dim: int = 256ffn_dim: int = 13824num_layers: int = 40cross_attn_norm: bool = Trueeps: float = 1e-06image_dim: typing.Optional[int] = Nonerope_max_seq_len: int = 1024gate_value: float = 0.25deltatime_type: str = 'r' )

매개변수

  • patch_size (Tuple[int], 기본값 (1, 2, 2)) — 비디오 임베딩을 위한 3D 패치 차원 (t_patch, h_patch, w_patch).
  • num_attention_heads (int, 기본값 40) — Attention head의 수입니다.
  • attention_head_dim (int, 기본값 128) — 각 헤드당 채널 수입니다.
  • in_channels (int, 기본값 16) — 입력 latent의 채널 수입니다.
  • out_channels (int, 기본값 16) — 출력 latent의 채널 수입니다.
  • text_dim (int, 기본값 4096) — 텍스트 임베딩(UMT5)의 입력 차원입니다.
  • freq_dim (int, 기본값 256) — 사인 파 시간 임베딩에 사용되는 차원입니다.
  • ffn_dim (int, 기본값 13824) — 피드포워드 네트워크의 중간 차원입니다.
  • num_layers (int, 기본값 40) — Transformer 블록의 수입니다.
  • cross_attn_norm (bool, 기본값 True) — 크로스 어텐션 정규화를 활성화합니다.
  • eps (float, 기본값 1e-6) — 정규화 레이어에 사용되는 Epsilon 값입니다.
  • image_dim (Optional[int], 선택 사항, 기본값 None) — I2V 조건화에 사용되는 이미지 임베딩 차원 (원본 Wan2.1-I2V 모델의 경우 1280).
  • rope_max_seq_len (int, 기본값 1024) — 회전 위치 주파수를 사전 계산하는 데 사용되는 최대 시퀀스 길이입니다.
  • gate_value (float, defaults to 0.25) — Mixing gate between source-timestep and delta-timestep embeddings (the AnyFlow paper’s{@html "ggg"} parameter, fixed at 0.25 in stage-1 distillation).
  • deltatime_type (str, 기본값 ‘r’) — "r"(delta가 대상 timestep임) 또는 "t-r"(delta가 절대 간격임).

AnyFlow 플로우 맵 샘플링을 위한 양방향 3D Transformer.

아키텍처는 v0.35.1 Wan2.1 3D DiT 백본을 기반으로 하며, 하나의 구조적 변경 사항이 있습니다. timestep embedder가 AnyFlowDualTimestepTextImageEmbedding 으로 대체되어 모든 forward 호출이 소스 timestep t 과 대상 timestep r. 에 조건부로 동작합니다. 이는Φr←t\Phi_{r\leftarrow t} 에서 도입된 flow map 을 학습하는 데 필요한 임베딩입니다..

차unk 단위 자기회귀(FAR causal) 생성을 사용하려면 AnyFlowFARTransformer3DModel을 대신 사용하세요. 해당 변형은 동일한 백본 위에 FAR causal 블록 마스크와 압축 프레임 패치 임베딩을 추가합니다.

forward

< >

( hidden_states: Tensortimestep: Tensorr_timestep: Tensorencoder_hidden_states: Tensorencoder_hidden_states_image: typing.Optional[torch.Tensor] = Noneattention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = Nonereturn_dict: bool = True )

매개변수

  • hidden_states (torch.Tensor, shape (batch_size, num_frames, num_channels, height, width)) — 입력 비디오 latents.
  • timestep (torch.Tensor) — 소스(노이즈가 더 많은) flow-map timestep t.
  • r_timestep (torch.Tensor) — 목표(더 깨끗한) flow-map timestep r. flow-map 단계의 도착 지점을 정의합니다.
  • encoder_hidden_states (torch.Tensor, shape (batch_size, sequence_len, embed_dims)) — 텍스트 조건 임베딩입니다.
  • encoder_hidden_states_image (torch.Tensor, optional) — 이미지 조건 임베딩입니다. 제공된 경우 텍스트 토큰 앞에 연결됩니다.
  • attention_kwargs (dict, 선택 사항) — diffusers.models.attention_processor의 self.processor 아래에서 정의된 AttentionProcessor로 전달되는 Kwargs입니다.
  • return_dict (bool, 선택 사항, 기본값 True) — 일반 튜플 대신 [~models.transformer_2d.Transformer2DModelOutput]를 반환할지 여부.

양방향 flow-map forward pass. hidden_states는 (B, F, C, H, W)로 배치됩니다(프레임별 latents). 입력은 표준 patch_embedding(kernel = stride = patch_size)로 patchify되고, 생성된 평탄화 토큰 시퀀스에 대해 전역 양방향 self-attention으로 denoise됩니다.

Update on GitHub