Diffusers documentation

ChromaTransformer2DModel

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

ChromaTransformer2DModel

Chroma의 수정된 flux Transformer 모델

ChromaTransformer2DModel

class diffusers.ChromaTransformer2DModel

< >

( patch_size: int = 1in_channels: int = 64out_channels: int | None = Nonenum_layers: int = 19num_single_layers: int = 38attention_head_dim: int = 128num_attention_heads: int = 24joint_attention_dim: int = 4096axes_dims_rope: tuple = (16, 56, 56)approximator_num_channels: int = 64approximator_hidden_dim: int = 5120approximator_layers: int = 5 )

매개변수

  • patch_size (int, 기본값 1) — 입력 데이터를 작은 패치로 변환하기 위한 패치 크기.
  • in_channels (int, 기본값 64) — 입력의 채널 수입니다.
  • out_channels (int, 선택 사항, 기본값 None) — 출력의 채널 수입니다. 지정하지 않으면 기본값으로 in_channels가 사용됩니다.
  • num_layers (int, 기본값 19) — 사용할 dual stream DiT 블록의 레이어 수입니다.
  • num_single_layers (int, 기본값 38) — 사용할 단일 스트림 DiT 블록의 레이어 수입니다.
  • attention_head_dim (int, 기본값 128) — 각 attention head에 사용할 차원의 수입니다.
  • num_attention_heads (int, 기본값 24) — 사용할 attention head의 수입니다.
  • joint_attention_dim (int, 기본값 4096) — encoder_hidden_states의 임베딩/채널 차원)에 사용할 joint attention의 차원 수입니다.
  • axes_dims_rope (tuple[int], 기본값 (16, 56, 56)) — 회전 위치 임베딩에 사용할 차원입니다.

Flux에서 소개된 Transformer 모델을 Chroma에 맞게 수정한 것입니다.

참고: https://huggingface.co/lodestones/Chroma1-HD

forward

< >

( hidden_states: Tensorencoder_hidden_states: Tensor = Nonetimestep: LongTensor = Noneimg_ids: Tensor = Nonetxt_ids: Tensor = Noneattention_mask: Tensor = Nonejoint_attention_kwargs: dict[str, typing.Any] | None = Nonecontrolnet_block_samples = Nonecontrolnet_single_block_samples = Nonereturn_dict: bool = Truecontrolnet_blocks_repeat: bool = False )

매개변수

  • hidden_states (torch.Tensor, shape (batch_size, image_sequence_length, in_channels)) — 입력 hidden_states.
  • encoder_hidden_states (torch.Tensor, shape (batch_size, text_sequence_length, joint_attention_dim)) — 사용할 조건 임베딩(프롬프트와 같은 입력 조건에서 계산된 임베딩).
  • timestep ( torch.LongTensor) — 디노이징 단계를 나타내는 데 사용됩니다.
  • img_ids (torch.Tensor) — 회전 위치 임베딩을 계산하는 데 사용되는 이미지 위치 id입니다.
  • txt_ids (torch.Tensor) — 회전 위치 임베딩을 계산하는 데 사용되는 텍스트 위치 id입니다.
  • attention_mask (torch.Tensor, 선택 사항) — Attention 과정에서 encoder_hidden_states에 적용되는 마스크입니다.
  • controlnet_block_samples (list of torch.Tensor, 선택 사항) — 지정된 경우 transformer 블록의 잔차에 추가되는 텐서 목록입니다.
  • controlnet_single_block_samples (list of torch.Tensor, 선택 사항) — 지정된 경우 단일 transformer 블록의 잔차에 추가되는 텐서 목록입니다.
  • controlnet_blocks_repeat (bool, 선택 사항, 기본값 False) — transformer 블록 전체에 걸쳐 controlnet 블록 샘플을 반복할지 여부입니다.
  • joint_attention_kwargs (dict, 선택 사항) — 지정된 경우 diffusers.models.attention_processor의 self.processor에서 정의된 AttentionProcessor로 전달되는 kwargs 사전입니다.
  • return_dict (bool, 선택 사항, 기본값 True) — 단순 tuple 대신 ~models.transformer_2d.Transformer2DModelOutput를 반환할지 여부.

FluxTransformer2DModel의 forward 메서드입니다.

Update on GitHub