-
Notifications
You must be signed in to change notification settings - Fork 110
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
debug dop lora #530
Open
strint
wants to merge
39
commits into
main
Choose a base branch
from
sdxl_dpo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
debug dop lora #530
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
cc16065
reproduce bug
strint c187f9f
use all_dynamic
strint 12ff0bd
align dynamic param with torch
strint d0d056d
add doc of oneflow_compile
strint b96c27e
format
strint 110f104
Merge branch 'align_dynamic' into sdxl_dpo
strint 886b12d
use new dynamic api
strint d78c84f
support text encoder
marigoold 4e56a68
refine code
marigoold 46a6a3f
compatible for prev diffusers version
marigoold ffdf6ed
Update __init__.py
marigoold 9877fb1
refine
marigoold 9aa6af4
Merge branch 'dev_wy_lora_support_textencoder' of github.com:Oneflow-…
marigoold e252c38
update readme
marigoold 7ede9af
refine doc
marigoold ef1eb8c
remove unfuse in fuse func
marigoold cead728
Merge branch 'main' into dev_wy_lora_support_textencoder
marigoold 54903ce
refine
marigoold 55c65b9
rename
marigoold 7892a5b
remove out dated lora.py
marigoold 93388a4
update readme
marigoold cb05e3e
refine
marigoold a964b23
Update lora.py
marigoold 46b54c2
fix bug
marigoold 2cf586e
Merge branch 'dev_wy_lora_support_textencoder' of github.com:Oneflow-…
marigoold 8743725
refine
marigoold cf0452f
Merge branch 'main' into dev_wy_lora_support_textencoder
marigoold 628a608
dual modulelist setattr fix bug, compatible with DualModule input
marigoold c773ac4
remove utils/__init__.py
marigoold 6009d1a
modify examples
marigoold 4a43b0b
update doc, and var name
marigoold 57e8ca1
Merge branch 'dev_wy_lora_support_textencoder' into fix_wy_dualmodule…
marigoold bf57ec6
compatible for PEFT
marigoold 0e7b951
Merge branch 'main' into fix_wy_dualmodulelist_setattr
marigoold daed844
fix merge
strint e2c3991
Merge branch 'main' into fix_wy_dualmodulelist_setattr
strint 71865a2
update to compile pipe
strint e3ad735
Merge branch 'fix_wy_dualmodulelist_setattr' of https://github.com/si…
strint 79a0c2b
Merge branch 'main' into sdxl_dpo
strint 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Need `pip install -U peft transformers` | ||
|
||
from diffusers import DiffusionPipeline | ||
from diffusers.utils import make_image_grid | ||
import torch | ||
|
||
pipe = DiffusionPipeline.from_pretrained( | ||
"/share_nfs/hf_models/sd-turbo", # SD Turbo is a destilled version of Stable Diffusion 2.1 | ||
#"stabilityai/sd-turbo", # SD Turbo is a destilled version of Stable Diffusion 2.1 | ||
# "stabilityai/stable-diffusion-2-1", # for the original stable diffusion 2.1 model | ||
torch_dtype=torch.float16, variant="fp16" | ||
) | ||
pipe.to("cuda") | ||
|
||
from onediffx import compile_pipe | ||
|
||
pipe = compile_pipe(pipe) | ||
|
||
pipe.load_lora_weights("radames/sd-21-DPO-LoRA", adapter_name="dpo-lora-sd21") | ||
pipe.set_adapters(["dpo-lora-sd21"], adapter_weights=[1.0]) # you can play with adapter_weights to increase the effect of the LoRA model | ||
seed = 123123 | ||
prompt = "portrait headshot professional of elon musk" | ||
negative_prompt = "3d render, cartoon, drawing, art, low light" | ||
generator = torch.Generator().manual_seed(seed) | ||
|
||
def run_once(dynamic_guidance_scale): | ||
for i in range(2): | ||
images = pipe( | ||
prompt=prompt, | ||
negative_prompt=negative_prompt, | ||
width=512, | ||
height=512, | ||
num_inference_steps=2, | ||
generator=generator, | ||
guidance_scale=dynamic_guidance_scale, | ||
num_images_per_prompt=4 | ||
).images | ||
make_image_grid(images, 1, 4) | ||
|
||
run_once(1.0) | ||
# Adjust guidance_scale | ||
# Will raise error | ||
run_once(1.5) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no compile time cost now for new guidance_scale now |
||
|
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.
use compile_pipe