mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
improve handling of pre-quantized flux
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
+2
-1
@@ -1,12 +1,13 @@
|
||||
# Change Log for SD.Next
|
||||
|
||||
## Update for 2025-08-22
|
||||
## Update for 2025-08-23
|
||||
|
||||
- **UI**
|
||||
- improved image scaling in img2img and control interfaces
|
||||
- **Fixes**
|
||||
- normalize path hanlding when deleting images
|
||||
- fix hidden model tags in networks display
|
||||
- improve handling of pre-quantized flux models
|
||||
|
||||
## Update for 2025-08-20
|
||||
|
||||
|
||||
+11
-6
@@ -1157,13 +1157,18 @@ def unload_model_weights(op='model'):
|
||||
shared.log.debug(f'Unload {op}: {memory_stats()}')
|
||||
|
||||
|
||||
def hf_auth_check(checkpoint_info):
|
||||
def hf_auth_check(checkpoint_info, force:bool=False):
|
||||
login = None
|
||||
try:
|
||||
if (checkpoint_info.path.endswith('.safetensors') and os.path.isfile(checkpoint_info.path)) or (os.path.exists(checkpoint_info.path) and os.path.isdir(checkpoint_info.path) and os.path.isfile(os.path.join(checkpoint_info.path, 'model_index.json'))): # skip check for already downloaded models
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
if not force:
|
||||
try:
|
||||
# skip check for single-file safetensors models
|
||||
if (checkpoint_info.path.endswith('.safetensors') and os.path.isfile(checkpoint_info.path)):
|
||||
return True
|
||||
# skip check for local diffusers folders
|
||||
if (os.path.exists(checkpoint_info.path) and os.path.isdir(checkpoint_info.path) and os.path.isfile(os.path.join(checkpoint_info.path, 'model_index.json'))):
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
login = modelloader.hf_login()
|
||||
repo_id = path_to_repo(checkpoint_info)
|
||||
|
||||
@@ -7,7 +7,7 @@ from pipelines import generic
|
||||
|
||||
def load_flux(checkpoint_info, diffusers_load_config={}):
|
||||
repo_id = sd_models.path_to_repo(checkpoint_info)
|
||||
sd_models.hf_auth_check(checkpoint_info)
|
||||
sd_models.hf_auth_check(checkpoint_info, force=True)
|
||||
|
||||
if 'Fill' in repo_id:
|
||||
cls_name = diffusers.FluxFillPipeline
|
||||
@@ -38,13 +38,9 @@ def load_flux(checkpoint_info, diffusers_load_config={}):
|
||||
transformer = None
|
||||
text_encoder_2 = None
|
||||
|
||||
# handle transformer svdquant if available, t5 is handled inside load_text_encoder
|
||||
prequantized = model_quant.get_quant(checkpoint_info.path)
|
||||
if model_quant.check_nunchaku('Model'):
|
||||
from pipelines.flux.flux_nunchaku import load_flux_nunchaku
|
||||
transformer = load_flux_nunchaku(repo_id)
|
||||
# handle prequantized models
|
||||
elif prequantized == 'nf4':
|
||||
prequantized = model_quant.get_quant(checkpoint_info.path)
|
||||
if prequantized == 'nf4':
|
||||
from pipelines.flux.flux_nf4 import load_flux_nf4
|
||||
transformer, text_encoder_2 = load_flux_nf4(checkpoint_info)
|
||||
elif prequantized == 'qint8' or prequantized == 'qint4':
|
||||
@@ -54,6 +50,11 @@ def load_flux(checkpoint_info, diffusers_load_config={}):
|
||||
from pipelines.flux.flux_bnb import load_flux_bnb
|
||||
transformer = load_flux_bnb(checkpoint_info, diffusers_load_config)
|
||||
|
||||
# handle transformer svdquant if available, t5 is handled inside load_text_encoder
|
||||
if transformer is None and model_quant.check_nunchaku('Model'):
|
||||
from pipelines.flux.flux_nunchaku import load_flux_nunchaku
|
||||
transformer = load_flux_nunchaku(repo_id)
|
||||
|
||||
# finally load transformer and text encoder if not already loaded
|
||||
if transformer is None:
|
||||
transformer = generic.load_transformer(repo_id, cls_name=diffusers.FluxTransformer2DModel, load_config=diffusers_load_config)
|
||||
|
||||
Reference in New Issue
Block a user