mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 09:38:23 +02:00
fix lora on model change
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -143,7 +143,9 @@ def quant_flux_bnb(checkpoint_info, transformer, text_encoder_2):
|
||||
"""
|
||||
|
||||
|
||||
def load_quants(kwargs, repo_id, cache_dir):
|
||||
def load_quants(kwargs, repo_id, cache_dir, allow_quant):
|
||||
if not allow_quant:
|
||||
return kwargs
|
||||
quant_args = {}
|
||||
quant_args = model_quant.create_bnb_config(quant_args)
|
||||
if quant_args:
|
||||
@@ -359,10 +361,10 @@ def load_flux(checkpoint_info, diffusers_load_config): # triggered by opts.sd_ch
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
allow_quant = 'gguf' not in (sd_unet.loaded_unet or '')
|
||||
allow_quant = 'gguf' not in (sd_unet.loaded_unet or '') and (quant is None or quant == 'none')
|
||||
fn = checkpoint_info.path
|
||||
if (fn is None) or (not os.path.exists(fn) or os.path.isdir(fn)):
|
||||
kwargs = load_quants(kwargs, repo_id, cache_dir=shared.opts.diffusers_dir)
|
||||
kwargs = load_quants(kwargs, repo_id, cache_dir=shared.opts.diffusers_dir, allow_quant=allow_quant)
|
||||
kwargs = model_quant.create_bnb_config(kwargs, allow_quant)
|
||||
kwargs = model_quant.create_ao_config(kwargs, allow_quant)
|
||||
if fn.endswith('.safetensors') and os.path.isfile(fn):
|
||||
|
||||
@@ -1622,6 +1622,11 @@ def unload_model_weights(op='model'):
|
||||
model_data.sd_model = None
|
||||
devices.torch_gc(force=True)
|
||||
shared.log.debug(f'Unload weights {op}: {memory_stats()}')
|
||||
if not shared.opts.lora_legacy:
|
||||
from modules.lora import networks
|
||||
networks.loaded_networks.clear()
|
||||
networks.previously_loaded_networks.clear()
|
||||
networks.lora_cache.clear()
|
||||
elif op == 'refiner':
|
||||
if model_data.sd_refiner:
|
||||
if not shared.native:
|
||||
|
||||
@@ -61,7 +61,7 @@ def create_sampler(name, model):
|
||||
model.prior_pipe.scheduler = copy.deepcopy(model.default_scheduler)
|
||||
model.prior_pipe.scheduler.config.clip_sample = False
|
||||
config = {k: v for k, v in model.scheduler.config.items() if not k.startswith('_')}
|
||||
shared.log.debug(f'Sampler: default class={current}: {config}')
|
||||
shared.log.debug(f'Sampler: "default" class={current}: {config}')
|
||||
if "flow" in model.scheduler.__class__.__name__.lower():
|
||||
shared.state.prediction_type = "flow_prediction"
|
||||
elif hasattr(model.scheduler, "config") and hasattr(model.scheduler.config, "prediction_type"):
|
||||
|
||||
Reference in New Issue
Block a user