mindspore-lab / mindone

one for all, Optimal generator with No Exception
Apache License 2.0
328 stars 62 forks source link

feat(diffusers/lora): support lora loading & training #498

Closed geniuspatrick closed 1 month ago

geniuspatrick commented 1 month ago

What does this PR do?

We support LoRA!

Now you can load the lora fine-tuning weights for trial. For example, the awesome Hyper-SD from ByteDance can generate an image on a laptop CPU in 1 minute! Paste the following code in your python console to generate a cute cat.

from mindone.diffusers import DiffusionPipeline, DDIMScheduler
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe.load_lora_weights("ByteDance/Hyper-SD", weight_name="Hyper-SD15-2steps-lora.safetensors")
pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
prompt = "a photo of a cat"
image = pipe(prompt=prompt, num_inference_steps=2, guidance_scale=0)[0][0]
image.save("cat.jpg")

Try it out!

Fixes # (issue)

Adds # (feature)

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.

@xxx