Text-to-Image
lora
mi804 commited on
Commit
f737c5e
·
verified ·
1 Parent(s): 2e85c6f

Init commit

Browse files
.gitattributes CHANGED
@@ -33,3 +33,24 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ samples/e1.png filter=lfs diff=lfs merge=lfs -text
37
+ samples/e2.png filter=lfs diff=lfs merge=lfs -text
38
+ samples/e3.png filter=lfs diff=lfs merge=lfs -text
39
+ samples/e4.png filter=lfs diff=lfs merge=lfs -text
40
+ samples/e5.png filter=lfs diff=lfs merge=lfs -text
41
+ samples/e6.png filter=lfs diff=lfs merge=lfs -text
42
+ samples/e7_1.png filter=lfs diff=lfs merge=lfs -text
43
+ samples/e7_2.png filter=lfs diff=lfs merge=lfs -text
44
+ samples/e7_3.png filter=lfs diff=lfs merge=lfs -text
45
+ samples/e7_4.png filter=lfs diff=lfs merge=lfs -text
46
+ samples/ic_target.png filter=lfs diff=lfs merge=lfs -text
47
+ samples/inpaint_i1.jpg filter=lfs diff=lfs merge=lfs -text
48
+ samples/inpaint_i2.png filter=lfs diff=lfs merge=lfs -text
49
+ samples/inpaint_o1.png filter=lfs diff=lfs merge=lfs -text
50
+ samples/inpaint_o2.png filter=lfs diff=lfs merge=lfs -text
51
+ samples/ip_1.png filter=lfs diff=lfs merge=lfs -text
52
+ samples/ip_2.png filter=lfs diff=lfs merge=lfs -text
53
+ samples/ip_3.png filter=lfs diff=lfs merge=lfs -text
54
+ samples/ip_ref.png filter=lfs diff=lfs merge=lfs -text
55
+ samples/regional_attention.jpg filter=lfs diff=lfs merge=lfs -text
56
+ samples/video.mp4 filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,105 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - black-forest-labs/FLUX.1-dev
5
+ tags:
6
+ - lora
7
+ - text-to-image
8
+ ---
9
+ # EliGen: Entity-Level Controlled Image Generation
10
+
11
+ ## Introduction
12
+
13
+ We propose EliGen, a novel approach that leverages fine-grained entity-level information to enable precise and controllable text-to-image generation. EliGen excels in tasks such as entity-level controlled image generation and image inpainting, while its applicability is not limited to these areas. Additionally, it can be seamlessly integrated with existing community models, such as the IP-Adpater and In-Cotext LoRA.
14
+
15
+ * Paper: [EliGen: Entity-Level Controlled Image Generation with Regional Attention](https://arxiv.org/abs/2501.01097)
16
+ * Github: [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio)
17
+ * Model:
18
+ * [ModelScope](https://www.modelscope.cn/models/DiffSynth-Studio/Eligen)
19
+ * [HuggingFace](https://huggingface.co/modelscope/EliGen)
20
+ * Online Demo: [ModelScope EliGen Studio](https://www.modelscope.cn/studios/DiffSynth-Studio/EliGen)
21
+ * Training dataset: [ModelScope Dataset](https://www.modelscope.cn/datasets/DiffSynth-Studio/EliGenTrainSet)
22
+
23
+ ## Methodology
24
+
25
+ ![regional-attention](./samples/regional_attention.jpg)
26
+
27
+ We introduce a regional attention mechanism within the DiT framework to effectively process the conditions of each entity. This mechanism enables the local prompt associated with each entity to semantically influence specific regions through regional attention. To further enhance the layout control capabilities of EliGen, we meticulously contribute an entity-annotated dataset and fine-tune the model using the LoRA framework.
28
+
29
+ 1. **Regional Attention**: Regional attention is shown in above figure, which can be easily applied to other text-to-image models. Its core principle involves transforming the positional information of each entity into an attention mask, ensuring that the mechanism only affects the designated regions.
30
+
31
+ 2. **Dataset with Entity Annotation**: To construct a dedicated entity control dataset, we start by randomly selecting captions from DiffusionDB and generating the corresponding source image using Flux. Next, we employ Qwen2-VL 72B, recognized for its advanced grounding capabilities among MLLMs, to randomly identify entities within the image. These entities are annotated with local prompts and bounding boxes for precise localization, forming the foundation of our dataset for further training.
32
+
33
+ 3. **Training**: We utilize LoRA (Low-Rank Adaptation) and DeepSpeed to fine-tune regional attention mechanisms using a curated dataset, enabling our EliGen model to achieve effective entity-level control.
34
+
35
+ ## Usage
36
+ This model was trained using [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio). We recommend using DiffSynth-Studio for generation.
37
+ ```shell
38
+ git clone https://github.com/modelscope/DiffSynth-Studio.git
39
+ cd DiffSynth-Studio
40
+ pip install -e .
41
+ ```
42
+ 1. **Entity-Level Controlled Image Generation**
43
+ EliGen achieves effective entity-level control results. See [entity_control.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_control.py) for usage.
44
+ 2. **Image Inpainting**
45
+ To apply EliGen to image inpainting task, we propose a inpainting fusion pipeline to preserve the non-painting areas while enabling precise, entity-level modifications over inpaining regions.
46
+ See [entity_inpaint.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_inpaint.py) for usage.
47
+ 3. **Styled Entity Control**
48
+ EliGen can be seamlessly integrated with existing community models. We have provided an example of how to integrate it with the IP-Adpater. See [entity_control_ipadapter.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_control_ipadapter.py) for usage.
49
+ 4. **Entity Transfer**
50
+ We have provided an example of how to integrate EliGen with In-Cotext LoRA, which achieves interesting entity transfer results. See [entity_transfer.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_transfer.py) for usage.
51
+ 5. **Play with EliGen using UI**
52
+ Download the checkpoint of EliGen from [ModelScope](https://www.modelscope.cn/models/DiffSynth-Studio/Eligen) to `models/lora/entity_control` and run the following command to try interactive UI:
53
+ ```bash
54
+ python apps/gradio/entity_level_control.py
55
+ ```
56
+ ## Examples
57
+ ### Entity-Level Controlled Image Generation
58
+
59
+ 1. The effect of generating images with continuously changing entity positions.
60
+
61
+ <div align="center">
62
+ <video width="80%" controls>
63
+ <source src="https://github.com/user-attachments/assets/54a048c8-b663-4262-8c40-43c87c266d4b" type="video/mp4">
64
+ Your browser does not support the video tag.
65
+ </video>
66
+ </div>
67
+
68
+ 1. The image generation effect of complex Entity combinations, demonstrating the strong generalization of EliGen. See [entity_control.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_control.py) `example_1-6` for generation prompts.
69
+
70
+ |Entity Conditions|Generated Image|
71
+ |-|-|
72
+ |![eligen_example_1_mask_0](./samples/e1_m.png)|![eligen_example_1_0](./samples/e1.png)|
73
+ |![eligen_example_2_mask_0](./samples/e2_m.png)|![eligen_example_2_0](./samples/e2.png)|
74
+ |![eligen_example_3_mask_27](./samples/e3_m.png)|![eligen_example_3_27](./samples/e3.png)|
75
+ |![eligen_example_4_mask_21](./samples/e4_m.png)|![eligen_example_4_21](./samples/e4.png)|
76
+ |![eligen_example_5_mask_0](./samples/e5_m.png)|![eligen_example_5_0](./samples/e5.png)|
77
+ |![eligen_example_6_mask_8](./samples/e6_m.png)|![eligen_example_6_8](./samples/e6.png)|
78
+
79
+ 1. Demonstration of the robustness of EliGen. The following examples are generated using the same prompt but different seeds. Refer to [entity_control.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_control.py) `example_7` for the prompts.
80
+
81
+ |Entity Conditions|Generated Image|
82
+ |-|-|
83
+ |![eligen_example_7_mask_5](./samples/e7_m.png)|![eligen_example_7_5](./samples/e7_1.png)|
84
+ |![eligen_example_7_mask_5](./samples/e7_m.png)|![eligen_example_7_6](./samples/e7_2.png)|
85
+ ![eligen_example_7_mask_5](./samples/e7_m.png)|![eligen_example_7_7](./samples/e7_3.png)|
86
+ |![eligen_example_7_mask_5](./samples/e7_m.png)|![eligen_example_7_8](./samples/e7_4.png)|
87
+
88
+ ### Image Inpainting
89
+ Demonstration of the inpainting mode of EliGen, see [entity_inpaint.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_inpaint.py) for generation prompts.
90
+ |Inpainting Input|Inpainting Output|
91
+ |-|-|
92
+ |![inpaint_i1](./samples/inpaint_i1.jpg)|![inpaint_o1](./samples/inpaint_o1.png)|
93
+ |![inpaint_i2](./samples/inpaint_i2.png)|![inpaint_o2](./samples/inpaint_o2.png)|
94
+ ### Styled Entity Control
95
+ Demonstration of the styled entity control results with EliGen and IP-Adapter, see [entity_control_ipadapter.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_control_ipadapter.py) for generation prompts.
96
+ |Style Reference|Entity Control Variance 1|Entity Control Variance 2|Entity Control Variance 3|
97
+ |-|-|-|-|
98
+ |![ip_ref](./samples/ip_ref.png)|![ip_1](./samples/ip_1.png)|![ip_2](./samples/ip_2.png)|![ip_3](./samples/ip_3.png)|
99
+
100
+ ### Entity Transfer
101
+ Demonstration of the entity transfer results with EliGen and In-Context LoRA, see [entity_transfer.py](https://github.com/mi804/DiffSynth-Studio/tree/main/examples/EntityControl/entity_transfer.py) for generation prompts.
102
+
103
+ |Entity to Transfer|Transfer Target Image|Transfer Example 1|Transfer Example 2|
104
+ |-|-|-|-|
105
+ |![ic_logo](./samples/ic_logo.jpg)|![ic_target](./samples/ic_target.png)|![ic_1](./samples/ic_1.jpg)|![ic_2](./samples/ic_2.jpg)|
samples/e1.png ADDED

Git LFS Details

  • SHA256: 2620fd9fa64bc15b436f79ed0c2729c866936a026f1a85f2bb349be17eae8d30
  • Pointer size: 132 Bytes
  • Size of remote file: 1.3 MB
samples/e1_m.png ADDED
samples/e2.png ADDED

Git LFS Details

  • SHA256: 29421c0be0cbc9a63e23982a4ce01ba22a85144e58f6b87b2e8d27ca89d70439
  • Pointer size: 132 Bytes
  • Size of remote file: 1.08 MB
samples/e2_m.png ADDED
samples/e3.png ADDED

Git LFS Details

  • SHA256: ed84a59dfbfe67160bdd892bb5017f6e76c403e3fe052a9eee07b7e6d28b4d4c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.12 MB
samples/e3_m.png ADDED
samples/e4.png ADDED

Git LFS Details

  • SHA256: 240b12e3c8df976b096320d9cf33b515f797a6043c439e84a25ce39b5d5b1847
  • Pointer size: 131 Bytes
  • Size of remote file: 948 kB
samples/e4_m.png ADDED
samples/e5.png ADDED

Git LFS Details

  • SHA256: e29fba5a983b266559612004e22b4d4932bab2cd8388d86cc7c7f93a8f8c717c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.52 MB
samples/e5_m.png ADDED
samples/e6.png ADDED

Git LFS Details

  • SHA256: c5f5b7a0b9536e686aadca067ad248e56b044ec24f8f73ea2a717579cd795a2e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.14 MB
samples/e6_m.png ADDED
samples/e7_1.png ADDED

Git LFS Details

  • SHA256: 0b9b8fbf5c27196f5a796ef811187bdf09c54ceb9f7c488cb530f4df07f63a4c
  • Pointer size: 132 Bytes
  • Size of remote file: 1 MB
samples/e7_2.png ADDED

Git LFS Details

  • SHA256: 846ccca32b106a88346f4ce512175afac001c96f1320e7270e0102c5011e25a6
  • Pointer size: 132 Bytes
  • Size of remote file: 1.05 MB
samples/e7_3.png ADDED

Git LFS Details

  • SHA256: a6d2d30e39dc9ff12c004c28244cf4812fae811f3a2c2812d0f22c8e754ecf58
  • Pointer size: 132 Bytes
  • Size of remote file: 1.06 MB
samples/e7_4.png ADDED

Git LFS Details

  • SHA256: 022f823c282be4ec08f4754d4dc7c3ec699ac9a955e66f6ba58505e74981e417
  • Pointer size: 132 Bytes
  • Size of remote file: 1.01 MB
samples/e7_m.png ADDED
samples/ic_1.jpg ADDED
samples/ic_2.jpg ADDED
samples/ic_logo.jpg ADDED
samples/ic_target.png ADDED

Git LFS Details

  • SHA256: e2f4d5f9172794ca9e8221206d329c677d9c7ae0ef4d9489d1cdfdcb4021370f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.03 MB
samples/inpaint_i1.jpg ADDED

Git LFS Details

  • SHA256: e00e863292f8a5a0ac91d0e5e9f12cbebbe3d2204634be0174b66dba6d71ef9e
  • Pointer size: 131 Bytes
  • Size of remote file: 253 kB
samples/inpaint_i2.png ADDED

Git LFS Details

  • SHA256: 16e3e85556fe42fa401faf860fc189e197b5ef095bb20ca0f1c55f594126da98
  • Pointer size: 132 Bytes
  • Size of remote file: 1.3 MB
samples/inpaint_o1.png ADDED

Git LFS Details

  • SHA256: c35efbe60dc4b2fa4eaf91c1ebf0d41dc3dea3bcc300bb791bec5efc2bd26efb
  • Pointer size: 132 Bytes
  • Size of remote file: 2.36 MB
samples/inpaint_o2.png ADDED

Git LFS Details

  • SHA256: d07ed608b2f6d81fac137056c1776e0cae9f911b1df0864199f84b0ab6137f26
  • Pointer size: 132 Bytes
  • Size of remote file: 1.13 MB
samples/ip_1.png ADDED

Git LFS Details

  • SHA256: 8e853f720d9119d2bf48d4984af494831d23cb623f6bd0b4c8b218e6553d9b20
  • Pointer size: 132 Bytes
  • Size of remote file: 1.01 MB
samples/ip_2.png ADDED

Git LFS Details

  • SHA256: a3428c3af146bd6cabbec875db9828eb68978da3fb262ea6d623d6d92171bb6e
  • Pointer size: 131 Bytes
  • Size of remote file: 983 kB
samples/ip_3.png ADDED

Git LFS Details

  • SHA256: 17365acca35f75384b6a8e3c76e9eef7795ec21d5733da36d7939840fe112dfb
  • Pointer size: 131 Bytes
  • Size of remote file: 961 kB
samples/ip_ref.png ADDED

Git LFS Details

  • SHA256: 5454d28fa063dbbab821d7604b4043a7302977d2cb8bd99938c7c727ec310ba6
  • Pointer size: 132 Bytes
  • Size of remote file: 1.19 MB
samples/regional_attention.jpg ADDED

Git LFS Details

  • SHA256: b598e87fb5f8455d66557bf0bf8822b1f74cb806179bcbaf08a7fe9dd56474b8
  • Pointer size: 131 Bytes
  • Size of remote file: 772 kB
samples/video.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7906b41bcb415c11e6a65774e37332125f0b31fd8a0cb94ff0371e57f3323d64
3
+ size 2952060