-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Add GLIGEN implementation #4441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7749b7c
Add GLIGEN implementation
nikhil-masterful 2c63533
GLIGEN: Fix code quality check failures
nikhil-masterful 3a71fa3
GLIGEN: Fix Import block un-sorted or un-formatted failures
nikhil-masterful a7d798f
GLIGEN: Fix check_repository_consistency failures
nikhil-masterful db78984
GLIGEN: Add 'PositionNet' to versatile_diffusion/modeling_text_unet.py
nikhil-masterful ee273a3
GLIGEN: check_repository_consistency: fix 'copy does not match' error
nikhil-masterful 1dcb79b
GLIGEN: Fix review comments (1)
nikhil-masterful bf67c27
GLIGEN: Fix E721 Do not compare types, use `isinstance()` failures
nikhil-masterful 80540c2
Merge branch 'main' into nikhil/gligen
nikhil-masterful c029794
GLIGEN : Ensure _encode_prompt() copy matches to StableDiffusionPipeline
nikhil-masterful c9332ac
GLIGEN: Fix ruff E721 failure in unidiffuser/test_unidiffuser.py
nikhil-masterful 1705e15
GLIGEN: doc_builder: restyle pipeline_stable_diffusion_gligen.py
nikhil-masterful cab9e58
GIGLEN: reset files unrelated to gligen
nikhil-masterful 1aedd75
GLIGEN: Fix documentation comments (1)
nikhil-masterful 4317754
GLIGEN: Fix review comments (2)
nikhil-masterful b40829f
GLIGEN: Added FastTest
nikhil-masterful f87d640
GLIGEN: Fix review comments (3)
nikhil-masterful File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!--Copyright 2023 The GLIGEN Authors and The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
--> | ||
|
||
# GLIGEN (Grounded Language-to-Image Generation) | ||
|
||
The GLIGEN model was created by researchers and engineers from [University of Wisconsin-Madison, Columbia University, and Microsoft](https://github.com/gligen/GLIGEN). The [`StableDiffusionGLIGENPipeline`] can generate photorealistic images conditioned on grounding inputs. Along with text and bounding boxes, if input images are given, this pipeline can insert objects described by text at the region defined by bounding boxes. Otherwise, it'll generate an image described by the caption/prompt and insert objects described by text at the region defined by bounding boxes. It's trained on COCO2014D and COCO2014CD datasets, and the model uses a frozen CLIP ViT-L/14 text encoder to condition itself on grounding inputs. | ||
|
||
The abstract from the [paper](https://huggingface.co/papers/2301.07093) is: | ||
|
||
*Large-scale text-to-image diffusion models have made amazing advances. However, the status quo is to use text input alone, which can impede controllability. In this work, we propose GLIGEN, Grounded-Language-to-Image Generation, a novel approach that builds upon and extends the functionality of existing pre-trained text-to-image diffusion models by enabling them to also be conditioned on grounding inputs. To preserve the vast concept knowledge of the pre-trained model, we freeze all of its weights and inject the grounding information into new trainable layers via a gated mechanism. Our model achieves open-world grounded text2img generation with caption and bounding box condition inputs, and the grounding ability generalizes well to novel spatial configurations and concepts. GLIGEN’s zeroshot performance on COCO and LVIS outperforms existing supervised layout-to-image baselines by a large margin.* | ||
|
||
<Tip> | ||
|
||
Make sure to check out the Stable Diffusion [Tips](https://huggingface.co/docs/diffusers/en/api/pipelines/stable_diffusion/overview#tips) section to learn how to explore the tradeoff between scheduler speed and quality and how to reuse pipeline components efficiently! | ||
|
||
If you want to use one of the official checkpoints for a task, explore the [gligen](https://huggingface.co/gligen) Hub organizations! | ||
|
||
</Tip> | ||
|
||
sayakpaul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This pipeline was contributed by [Nikhil Gajendrakumar](https://github.com/nikhil-masterful). | ||
|
||
## StableDiffusionGLIGENPipeline | ||
|
||
[[autodoc]] StableDiffusionGLIGENPipeline | ||
- all | ||
- __call__ | ||
- enable_vae_slicing | ||
- disable_vae_slicing | ||
- enable_vae_tiling | ||
- disable_vae_tiling | ||
- enable_model_cpu_offload | ||
- prepare_latents | ||
- enable_fuser | ||
sayakpaul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## StableDiffusionPipelineOutput | ||
|
||
[[autodoc]] pipelines.stable_diffusion.StableDiffusionPipelineOutput |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.