-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Feature] Support OFT #1160
Merged
Merged
[Feature] Support OFT #1160
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
c7e201d
Support OFT
okotaku 703bc43
add test
okotaku c0288cd
Update README
okotaku 485ed40
fix code quality
okotaku 497505e
fix test
okotaku 0317485
Skip 1 test
okotaku c9b1118
fix eps rule and add more test
okotaku 6536c32
feat: added examples to new OFT method
lukaskuhn-lku 54623f5
fix: removed wrong arguments from model example
lukaskuhn-lku de09791
fix: changed name of inference file
lukaskuhn-lku 8a37126
fix: changed prompt variable
lukaskuhn-lku 38009b3
fix docs
okotaku 1ef5c79
Merge pull request #1 from lukaskuhn-lku/oft
okotaku 3daa236
fix: dreambooth inference revision based on feedback
bf07076
fix: review from BenjaminBossan
edf2fa6
Merge pull request #2 from lukaskuhn-lku/oft
okotaku da0073d
apply safe merge
okotaku dfd3600
del partially
okotaku 6d247ad
refactor oft
okotaku 3d0f6a6
refactor oft
okotaku 58b5383
del unused line
okotaku a21a8a3
del unused line
okotaku 6284f07
fix skip in windows
okotaku 93b1282
skip test
okotaku 0647abe
Add comments about bias added place
okotaku 9a7738f
rename orig_weights to new_weights
okotaku a2c2143
use inverse instead of linalg.inv
okotaku b1a5ddf
Merge pull request #3 from okotaku/pr/okotaku/1160
okotaku e0161e9
delete alpha and scaling
okotaku 377a4ef
Merge branch 'main' into oft
okotaku 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 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 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,89 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "acd7b15e", | ||
"metadata": {}, | ||
"source": [ | ||
"# Dreambooth with OFT\n", | ||
"This Notebook assumes that you already ran the train_dreambooth.py script to create your own adapter." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "acab479f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from diffusers import DiffusionPipeline\n", | ||
"from diffusers.utils import check_min_version, get_logger\n", | ||
"from peft import PeftModel\n", | ||
"\n", | ||
"# Will error if the minimal version of diffusers is not installed. Remove at your own risks.\n", | ||
"check_min_version(\"0.10.0.dev0\")\n", | ||
"\n", | ||
"logger = get_logger(__name__)\n", | ||
"\n", | ||
"BASE_MODEL_NAME = \"stabilityai/stable-diffusion-2-1-base\"\n", | ||
"ADAPTER_MODEL_PATH = \"INSERT MODEL PATH HERE\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pipe = DiffusionPipeline.from_pretrained(\n", | ||
" BASE_MODEL_NAME,\n", | ||
")\n", | ||
"pipe.to('cuda')\n", | ||
"pipe.unet = PeftModel.from_pretrained(pipe.unet, ADAPTER_MODEL_PATH + \"/unet\", adapter_name=\"default\")\n", | ||
"pipe.text_encoder = PeftModel.from_pretrained(pipe.text_encoder, ADAPTER_MODEL_PATH + \"/text_encoder\", adapter_name=\"default\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"prompt = \"A photo of a sks dog\"\n", | ||
"image = pipe(\n", | ||
" prompt,\n", | ||
" num_inference_steps=50,\n", | ||
" height=512,\n", | ||
" width=512,\n", | ||
").images[0]\n", | ||
"image" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.11" | ||
}, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.
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.
The notebook assumes that the user ran the training script first to create an adapter, right? Let's mention that. Otherwise, we could maybe copy https://huggingface.co/takuoko/oft_test to our PEFT HF repo and link that one.
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.
I mentioned it now in PR#2. Don't know how to integrate the oft_test adapter into the PEFT HF repo so I would need some guidance to help with that.
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.
I think it's okay now as is, this way users who just open the notebook know what they should do first.