-
Notifications
You must be signed in to change notification settings - Fork 6.7k
unCLIP image variation #1781
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
patrickvonplaten
merged 4 commits into
huggingface:main
from
williamberman:unclip_image_variation
Dec 28, 2022
Merged
unCLIP image variation #1781
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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,40 @@ | ||
| import argparse | ||
|
|
||
| from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline | ||
| from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser() | ||
|
|
||
| parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") | ||
|
|
||
| parser.add_argument( | ||
| "--txt2img_unclip", | ||
| default="kakaobrain/karlo-v1-alpha", | ||
| type=str, | ||
| required=False, | ||
| help="The pretrained txt2img unclip.", | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| txt2img = UnCLIPPipeline.from_pretrained(args.txt2img_unclip) | ||
|
|
||
| feature_extractor = CLIPImageProcessor() | ||
| image_encoder = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-large-patch14") | ||
|
|
||
| img2img = UnCLIPImageVariationPipeline( | ||
| decoder=txt2img.decoder, | ||
| text_encoder=txt2img.text_encoder, | ||
| tokenizer=txt2img.tokenizer, | ||
| text_proj=txt2img.text_proj, | ||
| feature_extractor=feature_extractor, | ||
| image_encoder=image_encoder, | ||
| super_res_first=txt2img.super_res_first, | ||
| super_res_last=txt2img.super_res_last, | ||
| decoder_scheduler=txt2img.decoder_scheduler, | ||
| super_res_scheduler=txt2img.super_res_scheduler, | ||
| ) | ||
|
|
||
| img2img.save_pretrained(args.dump_path) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very informative, but I'm not sure we store this kind of scripts in the repo. The ones in the folder are usually about converting weights from other checkpoints. What do you think @patil-suraj?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to remove and just put in the PR description! lmk @patil-suraj
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, think no need to have this script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better than not having a script at all. Think it's totally fine to leave it here as is. The main purpose of the scripts is really so that the user can convert the checkpoints themselves - I'm fine with the way it is. Better would be to directly convert from the original checkpoint, but for me this is ok as well and def better than not having anything.