OmniGenTransformer2DModel¶
A Transformer model that accepts multimodal instructions to generate images for OmniGen.
The abstract from the paper is:
The emergence of Large Language Models (LLMs) has unified language generation tasks and revolutionized human-machine interaction. However, in the realm of image generation, a unified model capable of handling various tasks within a single framework remains largely unexplored. In this work, we introduce OmniGen, a new diffusion model for unified image generation. OmniGen is characterized by the following features: 1) Unification: OmniGen not only demonstrates text-to-image generation capabilities but also inherently supports various downstream tasks, such as image editing, subject-driven generation, and visual conditional generation. 2) Simplicity: The architecture of OmniGen is highly simplified, eliminating the need for additional plugins. Moreover, compared to existing diffusion models, it is more user-friendly and can complete complex tasks end-to-end through instructions without the need for extra intermediate steps, greatly simplifying the image generation workflow. 3) Knowledge Transfer: Benefit from learning in a unified format, OmniGen effectively transfers knowledge across different tasks, manages unseen tasks and domains, and exhibits novel capabilities. We also explore the model’s reasoning capabilities and potential applications of the chain-of-thought mechanism. This work represents the first attempt at a general-purpose image generation model, and we will release our resources at https://github.com/VectorSpaceLab/OmniGen to foster future advancements.
import mindspore
from mindone.diffusers import OmniGenTransformer2DModel
transformer = OmniGenTransformer2DModel.from_pretrained("Shitao/OmniGen-v1-diffusers", subfolder="transformer", mindspore_dtype=mindspore.bfloat16)
mindone.diffusers.OmniGenTransformer2DModel
¶
Bases: ModelMixin
, ConfigMixin
The Transformer model introduced in OmniGen (https://arxiv.org/pdf/2409.11340).
PARAMETER | DESCRIPTION |
---|---|
in_channels |
The number of channels in the input.
TYPE:
|
patch_size |
The size of the spatial patches to use in the patch embedding layer.
TYPE:
|
hidden_size |
The dimensionality of the hidden layers in the model.
TYPE:
|
rms_norm_eps |
Eps for RMSNorm layer.
TYPE:
|
num_attention_heads |
The number of heads to use for multi-head attention.
TYPE:
|
num_key_value_heads |
The number of heads to use for keys and values in multi-head attention.
TYPE:
|
intermediate_size |
Dimension of the hidden layer in FeedForward layers.
TYPE:
|
num_layers |
The number of layers of transformer blocks to use.
TYPE:
|
pad_token_id |
The id of the padding token.
TYPE:
|
vocab_size |
The size of the vocabulary of the embedding vocabulary.
TYPE:
|
rope_base |
The default theta value to use when creating RoPE.
TYPE:
|
rope_scaling |
The scaling factors for the RoPE. Must contain
TYPE:
|
pos_embed_max_size |
The maximum size of the positional embeddings.
TYPE:
|
time_step_dim |
Output dimension of timestep embeddings.
TYPE:
|
flip_sin_to_cos |
Whether to flip the sin and cos in the positional embeddings when preparing timestep embeddings.
TYPE:
|
downscale_freq_shift |
The frequency shift to use when downscaling the timestep embeddings.
TYPE:
|
timestep_activation_fn |
The activation function to use for the timestep embeddings.
TYPE:
|
Source code in mindone/diffusers/models/transformers/transformer_omnigen.py
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 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
|