Skip to content

Commit d50a96c

Browse files
authored
Merge branch 'main' into fix-hook-removal-with-warped-model
2 parents 71a4706 + 81440fd commit d50a96c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+6244
-196
lines changed

.github/workflows/trufflehog.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ jobs:
1313
fetch-depth: 0
1414
- name: Secret Scanning
1515
uses: trufflesecurity/trufflehog@main
16+
with:
17+
extra_args: --results=verified,unknown
18+

docs/source/en/_toctree.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
title: Kandinsky
9090
- local: using-diffusers/ip_adapter
9191
title: IP-Adapter
92+
- local: using-diffusers/omnigen
93+
title: OmniGen
9294
- local: using-diffusers/pag
9395
title: PAG
9496
- local: using-diffusers/controlnet
@@ -288,10 +290,14 @@
288290
title: LatteTransformer3DModel
289291
- local: api/models/lumina_nextdit2d
290292
title: LuminaNextDiT2DModel
293+
- local: api/models/lumina2_transformer2d
294+
title: Lumina2Transformer2DModel
291295
- local: api/models/ltx_video_transformer3d
292296
title: LTXVideoTransformer3DModel
293297
- local: api/models/mochi_transformer3d
294298
title: MochiTransformer3DModel
299+
- local: api/models/omnigen_transformer
300+
title: OmniGenTransformer2DModel
295301
- local: api/models/pixart_transformer2d
296302
title: PixArtTransformer2DModel
297303
- local: api/models/prior_transformer
@@ -438,6 +444,8 @@
438444
title: LEDITS++
439445
- local: api/pipelines/ltx_video
440446
title: LTXVideo
447+
- local: api/pipelines/lumina2
448+
title: Lumina 2.0
441449
- local: api/pipelines/lumina
442450
title: Lumina-T2X
443451
- local: api/pipelines/marigold
@@ -448,6 +456,8 @@
448456
title: MultiDiffusion
449457
- local: api/pipelines/musicldm
450458
title: MusicLDM
459+
- local: api/pipelines/omnigen
460+
title: OmniGen
451461
- local: api/pipelines/pag
452462
title: PAG
453463
- local: api/pipelines/paint_by_example
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!-- Copyright 2024 The HuggingFace Team. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License. -->
11+
12+
# Lumina2Transformer2DModel
13+
14+
A Diffusion Transformer model for 3D video-like data was introduced in [Lumina Image 2.0](https://huggingface.co/Alpha-VLLM/Lumina-Image-2.0) by Alpha-VLLM.
15+
16+
The model can be loaded with the following code snippet.
17+
18+
```python
19+
from diffusers import Lumina2Transformer2DModel
20+
21+
transformer = Lumina2Transformer2DModel.from_pretrained("Alpha-VLLM/Lumina-Image-2.0", subfolder="transformer", torch_dtype=torch.bfloat16)
22+
```
23+
24+
## Lumina2Transformer2DModel
25+
26+
[[autodoc]] Lumina2Transformer2DModel
27+
28+
## Transformer2DModelOutput
29+
30+
[[autodoc]] models.modeling_outputs.Transformer2DModelOutput
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License.
11+
-->
12+
13+
# OmniGenTransformer2DModel
14+
15+
A Transformer model that accepts multimodal instructions to generate images for [OmniGen](https://github.com/VectorSpaceLab/OmniGen/).
16+
17+
## OmniGenTransformer2DModel
18+
19+
[[autodoc]] OmniGenTransformer2DModel
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!-- Copyright 2024 The HuggingFace Team. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License. -->
14+
15+
# Lumina2
16+
17+
[Lumina Image 2.0: A Unified and Efficient Image Generative Model](https://huggingface.co/Alpha-VLLM/Lumina-Image-2.0) is a 2 billion parameter flow-based diffusion transformer capable of generating diverse images from text descriptions.
18+
19+
The abstract from the paper is:
20+
21+
*We introduce Lumina-Image 2.0, an advanced text-to-image model that surpasses previous state-of-the-art methods across multiple benchmarks, while also shedding light on its potential to evolve into a generalist vision intelligence model. Lumina-Image 2.0 exhibits three key properties: (1) Unification – it adopts a unified architecture that treats text and image tokens as a joint sequence, enabling natural cross-modal interactions and facilitating task expansion. Besides, since high-quality captioners can provide semantically better-aligned text-image training pairs, we introduce a unified captioning system, UniCaptioner, which generates comprehensive and precise captions for the model. This not only accelerates model convergence but also enhances prompt adherence, variable-length prompt handling, and task generalization via prompt templates. (2) Efficiency – to improve the efficiency of the unified architecture, we develop a set of optimization techniques that improve semantic learning and fine-grained texture generation during training while incorporating inference-time acceleration strategies without compromising image quality. (3) Transparency – we open-source all training details, code, and models to ensure full reproducibility, aiming to bridge the gap between well-resourced closed-source research teams and independent developers.*
22+
23+
<Tip>
24+
25+
Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading#reuse-a-pipeline) section to learn how to efficiently load the same components into multiple pipelines.
26+
27+
</Tip>
28+
29+
## Lumina2Text2ImgPipeline
30+
31+
[[autodoc]] Lumina2Text2ImgPipeline
32+
- all
33+
- __call__
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
-->
15+
16+
# OmniGen
17+
18+
[OmniGen: Unified Image Generation](https://arxiv.org/pdf/2409.11340) from BAAI, by Shitao Xiao, Yueze Wang, Junjie Zhou, Huaying Yuan, Xingrun Xing, Ruiran Yan, Chaofan Li, Shuting Wang, Tiejun Huang, Zheng Liu.
19+
20+
The abstract from the paper is:
21+
22+
*The emergence of Large Language Models (LLMs) has unified language
23+
generation tasks and revolutionized human-machine interaction.
24+
However, in the realm of image generation, a unified model capable of handling various tasks
25+
within a single framework remains largely unexplored. In
26+
this work, we introduce OmniGen, a new diffusion model
27+
for unified image generation. OmniGen is characterized
28+
by the following features: 1) Unification: OmniGen not
29+
only demonstrates text-to-image generation capabilities but
30+
also inherently supports various downstream tasks, such
31+
as image editing, subject-driven generation, and visual conditional generation. 2) Simplicity: The architecture of
32+
OmniGen is highly simplified, eliminating the need for additional plugins. Moreover, compared to existing diffusion
33+
models, it is more user-friendly and can complete complex
34+
tasks end-to-end through instructions without the need for
35+
extra intermediate steps, greatly simplifying the image generation workflow. 3) Knowledge Transfer: Benefit from
36+
learning in a unified format, OmniGen effectively transfers
37+
knowledge across different tasks, manages unseen tasks and
38+
domains, and exhibits novel capabilities. We also explore
39+
the model’s reasoning capabilities and potential applications of the chain-of-thought mechanism.
40+
This work represents the first attempt at a general-purpose image generation model,
41+
and we will release our resources at https:
42+
//github.com/VectorSpaceLab/OmniGen to foster future advancements.*
43+
44+
<Tip>
45+
46+
Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers.md) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading.md#reuse-a-pipeline) section to learn how to efficiently load the same components into multiple pipelines.
47+
48+
</Tip>
49+
50+
This pipeline was contributed by [staoxiao](https://github.com/staoxiao). The original codebase can be found [here](https://github.com/VectorSpaceLab/OmniGen). The original weights can be found under [hf.co/shitao](https://huggingface.co/Shitao/OmniGen-v1).
51+
52+
53+
## Inference
54+
55+
First, load the pipeline:
56+
57+
```python
58+
import torch
59+
from diffusers import OmniGenPipeline
60+
pipe = OmniGenPipeline.from_pretrained(
61+
"Shitao/OmniGen-v1-diffusers",
62+
torch_dtype=torch.bfloat16
63+
)
64+
pipe.to("cuda")
65+
```
66+
67+
For text-to-image, pass a text prompt. By default, OmniGen generates a 1024x1024 image.
68+
You can try setting the `height` and `width` parameters to generate images with different size.
69+
70+
```py
71+
prompt = "Realistic photo. A young woman sits on a sofa, holding a book and facing the camera. She wears delicate silver hoop earrings adorned with tiny, sparkling diamonds that catch the light, with her long chestnut hair cascading over her shoulders. Her eyes are focused and gentle, framed by long, dark lashes. She is dressed in a cozy cream sweater, which complements her warm, inviting smile. Behind her, there is a table with a cup of water in a sleek, minimalist blue mug. The background is a serene indoor setting with soft natural light filtering through a window, adorned with tasteful art and flowers, creating a cozy and peaceful ambiance. 4K, HD."
72+
image = pipe(
73+
prompt=prompt,
74+
height=1024,
75+
width=1024,
76+
guidance_scale=3,
77+
generator=torch.Generator(device="cpu").manual_seed(111),
78+
).images[0]
79+
image
80+
```
81+
82+
OmniGen supports multimodal inputs.
83+
When the input includes an image, you need to add a placeholder `<img><|image_1|></img>` in the text prompt to represent the image.
84+
It is recommended to enable `use_input_image_size_as_output` to keep the edited image the same size as the original image.
85+
86+
```py
87+
prompt="<img><|image_1|></img> Remove the woman's earrings. Replace the mug with a clear glass filled with sparkling iced cola."
88+
input_images=[load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/t2i_woman_with_book.png")]
89+
image = pipe(
90+
prompt=prompt,
91+
input_images=input_images,
92+
guidance_scale=2,
93+
img_guidance_scale=1.6,
94+
use_input_image_size_as_output=True,
95+
generator=torch.Generator(device="cpu").manual_seed(222)).images[0]
96+
image
97+
```
98+
99+
100+
## OmniGenPipeline
101+
102+
[[autodoc]] OmniGenPipeline
103+
- all
104+
- __call__
105+
106+

0 commit comments

Comments
 (0)