Diffusers documentation

OvisImageTransformer2DModel

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

OvisImageTransformer2DModel

モデルは、以下のコードスニペットで読み込むことができます。

from diffusers import OvisImageTransformer2DModel

transformer = OvisImageTransformer2DModel.from_pretrained("AIDC-AI/Ovis-Image-7B", subfolder="transformer", dtype=torch.bfloat16)

OvisImageTransformer2DModel

class diffusers.OvisImageTransformer2DModel

< >

( patch_size: int = 1in_channels: int = 64out_channels: int | None = 64num_layers: int = 6num_single_layers: int = 27attention_head_dim: int = 128num_attention_heads: int = 24joint_attention_dim: int = 2048axes_dims_rope: tuple = (16, 56, 56) )

パラメータ

  • patch_size (int、デフォルトは1) — 入力データを小さなパッチに変換するためのパッチサイズ。
  • in_channels (int、デフォルトは64) — 入力におけるチャネル数。
  • out_channels (int, 省略可、デフォルトは None) — 出力のチャネル数です。指定しない場合、デフォルトで in_channels になります。
  • num_layers (int、デフォルトは 6) — 使用する dual stream DiT ブロックの層数です。
  • num_single_layers (int, デフォルトは 27) — 使用する単一ストリーム DiT ブロックの層数です。
  • attention_head_dim (int, デフォルトは 128) — 各アテンションヘッドに使用する次元数です。
  • num_attention_heads (int、デフォルトは 24) — 使用するアテンションヘッドの数です。
  • joint_attention_dim (int、デフォルトは 2048) — encoder_hidden_states の埋め込み/チャネル次元として、joint attention に使用する次元数。
  • axes_dims_rope (tuple[int]、デフォルトは (16, 56, 56)) — 回転位置埋め込みに使用する次元です。

Ovis-Image で導入された Transformer モデル。

参照: https://github.com/AIDC-AI/Ovis-Image

forward

< >

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

パラメータ

  • hidden_states (torch.Tensor、形状 (batch_size, image_sequence_length, in_channels)) — 入力となる hidden_states。
  • encoder_hidden_states (torch.Tensor、形状 (batch_size, text_sequence_length, joint_attention_dim)) — 使用する条件埋め込み(プロンプトなどの入力条件から計算される埋め込み)。
  • timestep (torch.LongTensor) — デノイジングステップを示すために使用されます。
  • img_ids — (torch.Tensor): 画像トークンの位置 ID。
  • txt_ids (torch.Tensor) — テキストトークンの位置IDです。
  • joint_attention_kwargs (dict、省略可) — 指定された場合、diffusers.models.attention_processor で定義されている self.processor 配下の AttentionProcessor に渡される kwargs の辞書です。
  • return_dict (bool、任意、デフォルトは True) — プレーンなタプルではなく ~models.transformer_2d.Transformer2DModelOutput を返すかどうか。

OvisImageTransformer2DModelのforwardメソッドです。

Update on GitHub