Comments (8)
query = attn.to_q(hidden_states, scale=scale)
The latest diffusers adopts LoRACompatibleLinear
module rather than nn.Linear
.
The forward method of LoRACompatibleLinear
, however, has an additional kwargs scale
which is not included in LoraInjectedLinear
.
Since LoraInjectedLinear
already has a scale
parameter as an instance variable, simply modifying the definition of the forward method of LoraInjectedLinear
will resolve the issue.
class LoraInjectedLinear(nn.Module):
...
def forward(self, input, scale: float = 1.0): # FIXED: add dummy scale argument
from lora.
You may need to lower the version of the Python package, such as using diffusers==0.11.0 and transformers==4.25.1.
from lora.
Modification for inference
After training, I faced a similar issue for inference.
The patch_pipe
method would fail with the following error.
...
line 784, in monkeypatch_or_replace_lora_extended
_module._modules[name] = _tmp
UnboundLocalError: local variable '_tmp' referenced before assignment
I figured out that the error occurred because the monkeypatch_or_replace_lora_extended
did not handle the LoRACompatibleLinear
module properly.
There would be a better solution, but I fixed the issue by simply adding the LoRACompatibleLinear
module on the search target.
def monkeypatch_or_replace_lora_extended(
model,
loras,
target_replace_module=DEFAULT_TARGET_REPLACE,
r: Union[int, List[int]] = 4,
):
for _module, name, _child_module in _find_modules(
model,
target_replace_module,
search_class=[nn.Linear, LoraInjectedLinear, LoRACompatibleLinear, nn.Conv2d, LoraInjectedConv2d],
):
_tmp = None
if _child_module.__class__ in {nn.Linear, LoraInjectedLinear, LoRACompatibleLinear}:
...
from lora.
@justin-prnd where is the LoRACompatibleLinear defined? I get module not defined error?
Defined at
https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/lora.py#L181
and can be imported as
from diffusers.models.lora import LoRACompatibleLinear
if diffusers >= v0.16.0
from lora.
Build the environment from source.
from lora.
Build the environment from source.
I did run
!pip install git+https://github.com/cloneofsimo/lora.git
Is this not building from source?
from lora.
thanks @justin-prnd
from lora.
@justin-prnd where is the LoRACompatibleLinear defined? I get module not defined error?
from lora.
Related Issues (20)
- example dataset
- Bug: Merging lora to model with lora_add produces garbage output in stable diff webui HOT 2
- what is?
- Do we need to finetune controlnet when we merge sd with different lora?
- Can LoRA be applied to different base models?
- Training a lora_model with inpainting is giving conversion failed: . the model may not be trained by `sd-scripts`. HOT 2
- Citation HOT 2
- The examples in run_inference.ipynb cannot work. RuntimeError: The size of tensor a (320) must match the size of tensor b (2560) at non-singleton dimension 2. HOT 4
- SDXL 0.9 / 1.0 HOT 1
- RuntimeError: One of the differentiated Tensors does not require grad HOT 3
- classifier free guidance during training and inference
- Face seg mask is not in [0, 1]
- cannot find the function monkeypatch_lora() HOT 1
- Inpainting not working on custom dataset but image generation works. HOT 3
- [patch_pipe] UnboundLocalError: local variable '_tmp' referenced before assignment HOT 1
- the `optimizer.zero_grad()` is called after loss backward
- New version of HuggingFace đ¤ diffusers library is incompatible with this codebase.
- How to embed lora in a custom stable diffusion network HOT 1
- č°åēĻå¨éŽéĸīŧ
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lora.