CogView3PlusTransformer2DModel¶
A Diffusion Transformer model for 2D data from CogView3Plus was introduced in CogView3: Finer and Faster Text-to-Image Generation via Relay Diffusion by Tsinghua University & ZhipuAI.
The model can be loaded with the following code snippet.
from mindone.diffusers import CogView3PlusTransformer2DModel
transformer = CogView3PlusTransformer2DModel.from_pretrained("THUDM/CogView3-Plus-3B", subfolder="transformer", mindspore_dtype=mindspore.bfloat16)
mindone.diffusers.models.transformers.transformer_cogview3plus.CogView3PlusTransformer2DModel
¶
Bases: ModelMixin
, ConfigMixin
The Transformer model introduced in CogView3: Finer and Faster Text-to-Image Generation via Relay Diffusion.
PARAMETER | DESCRIPTION |
---|---|
patch_size |
The size of the patches to use in the patch embedding layer.
TYPE:
|
in_channels |
The number of channels in the input.
TYPE:
|
num_layers |
The number of layers of Transformer blocks to use.
TYPE:
|
attention_head_dim |
The number of channels in each head.
TYPE:
|
num_attention_heads |
The number of heads to use for multi-head attention.
TYPE:
|
out_channels |
The number of channels in the output.
TYPE:
|
text_embed_dim |
Input dimension of text embeddings from the text encoder.
TYPE:
|
time_embed_dim |
Output dimension of timestep embeddings.
TYPE:
|
condition_dim |
The embedding dimension of the input SDXL-style resolution conditions (original_size, target_size, crop_coords).
TYPE:
|
pos_embed_max_size |
The maximum resolution of the positional embeddings, from which slices of shape
TYPE:
|
sample_size |
The base resolution of input latents. If height/width is not provided during generation, this value is used
to determine the resolution as
TYPE:
|
Source code in mindone/diffusers/models/transformers/transformer_cogview3plus.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
mindone.diffusers.models.transformers.transformer_cogview3plus.CogView3PlusTransformer2DModel.attn_processors: Dict[str, AttentionProcessor]
property
¶
RETURNS | DESCRIPTION |
---|---|
Dict[str, AttentionProcessor]
|
|
Dict[str, AttentionProcessor]
|
indexed by its weight name. |
mindone.diffusers.models.transformers.transformer_cogview3plus.CogView3PlusTransformer2DModel.construct(hidden_states, encoder_hidden_states, timestep, original_size, target_size, crop_coords, return_dict=False)
¶
The [CogView3PlusTransformer2DModel
] forward method.
PARAMETER | DESCRIPTION |
---|---|
hidden_states |
Input
TYPE:
|
encoder_hidden_states |
Conditional embeddings (embeddings computed from the input conditions such as prompts) of shape
TYPE:
|
timestep |
Used to indicate denoising step.
TYPE:
|
original_size |
CogView3 uses SDXL-like micro-conditioning for original image size as explained in section 2.2 of https://huggingface.co/papers/2307.01952.
TYPE:
|
target_size |
CogView3 uses SDXL-like micro-conditioning for target image size as explained in section 2.2 of https://huggingface.co/papers/2307.01952.
TYPE:
|
crop_coords |
CogView3 uses SDXL-like micro-conditioning for crop coordinates as explained in section 2.2 of https://huggingface.co/papers/2307.01952.
TYPE:
|
return_dict |
Whether or not to return a [
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[Tensor, Transformer2DModelOutput]
|
|
Source code in mindone/diffusers/models/transformers/transformer_cogview3plus.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
mindone.diffusers.models.transformers.transformer_cogview3plus.CogView3PlusTransformer2DModel.set_attn_processor(processor)
¶
Sets the attention processor to use to compute attention.
PARAMETER | DESCRIPTION |
---|---|
processor |
The instantiated processor class or a dictionary of processor classes that will be set as the processor
for all If
TYPE:
|
Source code in mindone/diffusers/models/transformers/transformer_cogview3plus.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
mindone.diffusers.models.modeling_outputs.Transformer2DModelOutput
dataclass
¶
Bases: BaseOutput
The output of [Transformer2DModel
].
PARAMETER | DESCRIPTION |
---|---|
`(batch |
The hidden states output conditioned on the
TYPE:
|
Source code in mindone/diffusers/models/modeling_outputs.py
22 23 24 25 26 27 28 29 30 31 32 33 34 |
|