-
Notifications
You must be signed in to change notification settings - Fork 166
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
Rework LoRA section, fix incongruent package versions required by different samples #567
Rework LoRA section, fix incongruent package versions required by different samples #567
Conversation
@@ -32,7 +32,7 @@ conda env config vars set LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH | |||
git submodule update --init | |||
# Reactivate Conda environment after installing dependencies and setting env vars | |||
conda activate openvino_sd_cpp | |||
python -m pip install -r requirements.txt | |||
python -m pip install -r ../../requirements.txt | |||
python -m pip install ../../../thirdparty/openvino_tokenizers/[transformers] | |||
``` | |||
2. Download a huggingface SD v1.5 model like: |
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.
optimum-cli export openvino
below is in [dreamlike-anime-1.0](https://huggingface.co/dreamlike-art/dreamlike-anime-1.0)
section even though it they aren't related. Please rework this. I think you can move down as an example of
There are various LoRA models on https://civitai.com/tag/lora
[dreamlike-anime-1.0](https://huggingface.co/dreamlike-art/dreamlike-anime-1.0)
section because it's described 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.
runwayml/stable-diffusion-v1-5
and dreamlike-art/dreamlike-anime-1.0
are Stable Diffusion models exported with optimum-cli
, not the LoRA models. I suppose it is might be useful to show the user which example SD models he can download and export.
Reworked this section and made the messaging more clear
|
||
Refer to [python pipeline blog](https://blog.openvino.ai/blog-posts/enable-lora-weights-with-stable-diffusion-controlnet-pipeline). | ||
The safetensor model is loaded via [safetensors.h](https://github.com/hsnyder/safetensors.h). The layer name and weight are modified with `Eigen` library and inserted into the SD models with `ov::pass::MatcherPass` in the file [common/diffusers/src/lora.cpp](https://github.com/openvinotoolkit/openvino.genai/blob/master/image_generation/common/diffusers/src/lora.cpp). | ||
Low-Rank Adaptation(LoRA) is a novel technique introduced to deal with the problem of fine-tuning Diffusers and Large Language Models (LLMs). In the case of Stable Diffusion fine-tuning, LoRA can be applied to the cross-attention layers for the image representations with the latent described. |
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.
Low-Rank Adaptation(LoRA) is a novel technique introduced to deal with the problem of fine-tuning Diffusers and Large Language Models (LLMs). In the case of Stable Diffusion fine-tuning, LoRA can be applied to the cross-attention layers for the image representations with the latent described. | |
Low-Rank Adaptation(LoRA) is technique introduced to deal with the problem of fine-tuning Diffusers and Large Language Models (LLMs). In the case of Stable Diffusion fine-tuning, LoRA can be applied to the cross-attention layers for the image representations with the latent described. |
it won't be novel after some time. Or maybe it's already not novel :)
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.
Fixed
|
||
SD model [dreamlike-anime-1.0](https://huggingface.co/dreamlike-art/dreamlike-anime-1.0) and LoRA [soulcard model](https://civitai.com/models/67927?modelVersionId=72591) are tested in this pipeline. | ||
|
||
There are various LoRA models on https://civitai.com/tag/lora and on HuggingFace, you can consider to choose your own LoRA model in safetensor format. |
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.
Move that line to the LoRA Weights Format
section. It's a natural question to ask to see examples of the weights with the described format. That would leave Using LoRA Weights
section with just two sentences. And
SD model dreamlike-anime-1.0 and LoRA soulcard model are tested in this pipeline.
isn't informative. I suggest merging them and naming the merged section LoRA Weights
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.
Fixed, sections are merged
image_generation/requirements.txt
Outdated
@@ -0,0 +1,5 @@ | |||
--extra-index-url https://download.pytorch.org/whl/cpu | |||
torch==2.2.2+cpu; sys_platform != 'darwin' | |||
torch==2.2.2; sys_platform == 'darwin' |
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.
Please, add a comment explaining the diff
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.
Fixed
|
||
* Generate image without lora `./build/stable_diffusion -r` | ||
|
||
![](./without_lora.bmp) | ||
|
||
* Generate image with soulcard lora `./build/stable_diffusion -r` | ||
* Generate image with soulcard lora `./build/stable_diffusion -r -l path/to/soulcard.safetensors` | ||
|
||
![](./soulcard_lora.bmp) | ||
|
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.
While you are nearby, please replace is differ
to differ
below.
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.
Fixed for both SD and LCM
samples/requirements.txt
Outdated
@@ -2,3 +2,4 @@ | |||
optimum[openvino]==1.20.0 | |||
einops==0.8.0 # For Qwen | |||
transformers_stream_generator==0.0.5 # For Qwen | |||
-r ../image_generation/requirements.txt |
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.
Reminder to inverse the dependency or introduce a common requirements.txt
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.
Fixed
image_generation/requirements.txt
Outdated
torch==2.2.2+cpu; sys_platform != 'darwin' | ||
torch==2.2.2; sys_platform == 'darwin' # Torch wheel for 2.2.2+cpu does not exist for macOS, using 2.2.2 instead | ||
diffusers==0.27.2 | ||
optimum-intel[openvino]==1.18.0 |
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.
optimum-intel[openvino]==1.18.0 |
samples already have optimum[openvino]==1.20.0
. That's strange that pip didn't detect a conflict
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.
From samples optimum-intel is installed with version >=1.16.0, so there is no conflict.
But I removed duplicated dependencies from image generation
image_generation/requirements.txt
Outdated
@@ -0,0 +1,6 @@ | |||
--extra-index-url https://download.pytorch.org/whl/cpu | |||
torch==2.2.2+cpu; sys_platform != 'darwin' | |||
torch==2.2.2; sys_platform == 'darwin' # Torch wheel for 2.2.2+cpu does not exist for macOS, using 2.2.2 instead |
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 just realized. I'd expect torch to come with optimum. Can torch be removed? Maybe the same is applicable to diffusers
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.
Duplicated dependencies removed keeping only diffusers in requirements
No description provided.