Comments (6)
the previous version scripts\main.py Add these lines:
**def assign_lora_names_to_compvis_modules(sd_model): lora_layer_mapping = {}
for name, module in shared.sd_model.cond_stage_model.wrapped.named_modules(): lora_name = name.replace(".", "_") lora_layer_mapping[lora_name] = module module.lora_layer_name = lora_name for name, module in shared.sd_model.model.named_modules(): lora_name = name.replace(".", "_") lora_layer_mapping[lora_name] = module module.lora_layer_name = lora_name sd_model.lora_layer_mapping = lora_layer_mapping**
def load_lora(name, filename): print('locon load lora method') lora = LoraModule(name) lora.mtime = os.path.getmtime(filename)
sd = sd_models.read_state_dict(filename) **if not hasattr(shared.sd_model, 'lora_layer_mapping'): assign_lora_names_to_compvis_modules(shared.sd_model)**
It works for me.
Let me clear the code for others:
Add one function before 'def load_lora'
def assign_lora_names_to_compvis_modules(sd_model):
lora_layer_mapping = {}
for name, module in shared.sd_model.cond_stage_model.wrapped.named_modules():
lora_name = name.replace(".", "_")
lora_layer_mapping[lora_name] = module
module.lora_layer_name = lora_name
for name, module in shared.sd_model.model.named_modules():
lora_name = name.replace(".", "_")
lora_layer_mapping[lora_name] = module
module.lora_layer_name = lora_name
sd_model.lora_layer_mapping = lora_layer_mapping
Replace first a few lins o 'def load_lora'
as
def load_lora(name, lora_on_disk):
print('locon load lora method')
lora = LoraModule(name, lora_on_disk)
lora.mtime = os.path.getmtime(lora_on_disk.filename)
sd = sd_models.read_state_dict(lora_on_disk.filename)
if not hasattr(shared.sd_model, 'lora_layer_mapping'):
assign_lora_names_to_compvis_modules(shared.sd_model)
is_sd2 = True // I don't really know what this is for anther function ask for it.
The 'lora_on_disk' part is compatible with latest PR:
https://github.com/KohakuBlueleaf/a1111-sd-webui-locon/pull/39/files
The error reported disppeared.
AttributeError: 'LatentDiffusion' object has no attribute 'lora_layer_mapping'
However one new errror emerged:
Failed to match keys when loading Lora models\Lora.....
Magically, it does not effect final result. All LoRA models works fine to me...
from a1111-sd-webui-locon.
I also get this error, running on windows 10 with gtx 1660 ti.
COMMANDLINE_ARGS= --theme dark --autolaunch --precision full --no-half --no-half-vae --medvram --disable-safe-unpickle --reinstall-torch --xformers --always-batch-cond-uncond
from a1111-sd-webui-locon.
loading Lora Z:\sd\stable-diffusion-webui\models\Lora\locon_angelina_v1_from_v3_64_32.safetensors: AssertionError ?it/s]
Traceback (most recent call last):
File "Z:\sd\stable-diffusion-webui\extensions-builtin\Lora\lora.py", line 222, in load_loras
lora = load_lora(name, lora_on_disk.filename)
File "Z:\sd\stable-diffusion-webui\extensions-builtin\Lora\lora.py", line 192, in load_lora
assert False, f'Bad Lora layer name: {key_diffusers} - must end in lora_up.weight, lora_down.weight or alpha'
AssertionError: Bad Lora layer name: lora_unet_down_blocks_0_downsamplers_0_conv.lora_mid.weight - must end in lora_up.w
I get this random error? whats going on?
from a1111-sd-webui-locon.
The extension seems to be broken in a few ways with upstream A1111 changes, though I haven't gotten any of them except the following one.
Another breaking change in dev is AUTOMATIC1111/stable-diffusion-webui@39ec4f0, which I've made a RP for: #39
from a1111-sd-webui-locon.
the previous version
scripts\main.py
Add these lines:
**def assign_lora_names_to_compvis_modules(sd_model):
lora_layer_mapping = {}
for name, module in shared.sd_model.cond_stage_model.wrapped.named_modules():
lora_name = name.replace(".", "_")
lora_layer_mapping[lora_name] = module
module.lora_layer_name = lora_name
for name, module in shared.sd_model.model.named_modules():
lora_name = name.replace(".", "_")
lora_layer_mapping[lora_name] = module
module.lora_layer_name = lora_name
sd_model.lora_layer_mapping = lora_layer_mapping**
def load_lora(name, filename):
print('locon load lora method')
lora = LoraModule(name)
lora.mtime = os.path.getmtime(filename)
sd = sd_models.read_state_dict(filename)
**if not hasattr(shared.sd_model, 'lora_layer_mapping'):
assign_lora_names_to_compvis_modules(shared.sd_model)**
from a1111-sd-webui-locon.
I'm getting this error too, anyone figure out how to fix it
from a1111-sd-webui-locon.
Related Issues (20)
- getting RuntimeError: shape '[1280]' is invalid for input of size 0 while applying locon model HOT 1
- extension doesn't load if data directory changed HOT 1
- Quite trivial issue, might change walrus operator to the traditional one HOT 1
- Installed via Automatic1111 install from URL but getting error on LOCON HOT 1
- locon load lora method HOT 1
- It wasn't clear HOT 1
- 第657行 (mid:=module.mid_model) 不兼容python 3.7
- Lycoris not supported for inpainting and outpainting HOT 1
- Error HOT 2
- Request to fix the import path for build-in lora
- [CRITICAL]All LoRAs not working anymore HOT 37
- AttributeError: 'str' object has no attribute 'filename' HOT 3
- Error when load Lora
- Someone please push the FIX to the main branch!!! HOT 7
- locon is not working with google colab… HOT 7
- Trying to Use Locon as Lora - Attribute Error String HOT 1
- Keeping the 'lora' conception in simple is preferable for future development.
- Locon doesn't work...? HOT 1
- Fail to work with A1111 V1.4.0
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 a1111-sd-webui-locon.