V 1.0.0 - Auto concept check 5

This commit is contained in:
DESKTOP-CNFQ7PM\Primere
2024-10-18 22:31:51 +02:00
parent f9348e9d64
commit e255fa9227
4 changed files with 1523 additions and 1162 deletions
+238 -13
View File
@@ -23,6 +23,7 @@ import comfy.sd
import comfy.model_detection
import comfy.utils
from ..utils import comfy_dir
from ..utils import here
import comfy_extras.nodes_model_advanced as nodes_model_advanced
import comfy_extras.nodes_upscale_model as nodes_upscale_model
from comfy import model_management
@@ -175,6 +176,7 @@ class PrimereModelConceptSelector:
"STRING", "STRING", "STRING", "STRING",
"STRING", "INT", "INT", "INT",
"STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "FLOAT", "STRING", "STRING",
"FLUX_HYPER_LORA", "STRING", "INT", "INT", "INT",
"STRING", "STRING", "STRING",
"STRING", "STRING", "STRING", "STRING"
)
@@ -185,6 +187,7 @@ class PrimereModelConceptSelector:
"CASCADE_STAGE_A", "CASCADE_STAGE_B", "CASCADE_STAGE_C", "CASCADE_CLIP",
"HYPER-SD_SELECTOR", "HYPER-SD_MODEL_STEP", "STRENGTH_HYPERSD_LORA_MODEL", "STRENGTH_HYPERSD_LORA_CLIP",
"FLUX_SELECTOR", "FLUX_DIFFUSION_MODEL", "FLUX_WEIGHT_TYPE", "FLUX_GGUF_MODEL", "FLUX_CLIP_T5XXL", "FLUX_CLIP_L", "FLUX_CLIP_GUIDANCE", "FLUX_VAE", "FLUX_SAMPLER",
"USE_FLUX_HYPER_LORA", "FLUX_HYPER_LORA_TYPE", "FLUX_HYPER_LORA_STEP", "STRENGTH_FLUXHYPER_LORA_MODEL", "STRENGTH_FLUXHYPER_LORA_CLIP",
"HUNYUAN_CLIP_T5XXL", "HUNYUAN_CLIP_L", "HUNYUAN_VAE",
"SD3_CLIP_G", "SD3_CLIP_L", "SD3_CLIP_T5XXL", "SD3_UNET_VAE"
)
@@ -250,6 +253,11 @@ class PrimereModelConceptSelector:
"flux_clip_guidance": ('FLOAT', {"default": 3.5, "min": 0.0, "max": 100.0, "step": 0.1}),
"flux_vae": (["None"] + VAELIST,),
"flux_sampler": (["custom_advanced", "ksampler"], {"default": "ksampler"}),
"use_flux_hyper_lora": ("BOOLEAN", {"default": False, "label_on": "Use hyper Lora", "label_off": "Ignore Lora"}),
"flux_hyper_lora_type": (["FLUX.1-dev", "FLUX.1-dev-fp16"], {"default": "FLUX.1-dev-fp16"}),
"flux_hyper_lora_step": ([8, 16], {"default": 8}),
"strength_fluxhyper_lora_model": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}),
"strength_fluxhyper_lora_clip": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}),
"hunyuan_clip_t5xxl": (["None"] + CLIPLIST,),
"hunyuan_clip_l": (["None"] + CLIPLIST,),
@@ -272,16 +280,16 @@ class PrimereModelConceptSelector:
hunyuan_clip_t5xxl, hunyuan_clip_l, hunyuan_vae,
sd3_clip_g, sd3_clip_l, sd3_clip_t5xxl, sd3_unet_vae,
model_version = None,
default_sampler_name='euler', default_scheduler_name='normal', default_cfg_scale=7, default_steps=12,
flux_sampler = 'ksampler',
default_sampler_name = 'euler', default_scheduler_name = 'normal', default_cfg_scale = 7, default_steps = 12,
model_concept = 'Auto',
clip_selection=True,
clip_selection = True,
strength_lcm_lora_model = 1, strength_lcm_lora_clip = 1,
lightning_selector = "LORA", lightning_model_step = 8, lightning_sampler = False,
strength_lightning_lora_model = 1, strength_lightning_lora_clip = 1,
hypersd_selector = "LORA", hypersd_model_step = 8, hypersd_sampler = False,
strength_hypersd_lora_model = 1, strength_hypersd_lora_clip = 1,
flux_selector = "DIFFUSION", flux_clip_guidance = 3.5,
flux_sampler = 'ksampler', flux_selector = "DIFFUSION", flux_clip_guidance = 3.5,
use_flux_hyper_lora = False, flux_hyper_lora_type = 'FLUX.1-dev-fp16', flux_hyper_lora_step = 8, strength_fluxhyper_lora_model = 1, strength_fluxhyper_lora_clip = 1,
**kwargs
):
@@ -365,6 +373,11 @@ class PrimereModelConceptSelector:
flux_clip_guidance = None
flux_vae = None
flux_sampler = None
use_flux_hyper_lora = None
flux_hyper_lora_type = None
flux_hyper_lora_step = None
strength_fluxhyper_lora_model = None
strength_fluxhyper_lora_clip = None
if model_concept != 'Hunyuan':
hunyuan_clip_t5xxl = None
@@ -377,6 +390,9 @@ class PrimereModelConceptSelector:
sd3_clip_t5xxl = None
sd3_unet_vae = None
if model_concept == 'Flux' and use_flux_hyper_lora == True:
steps = flux_hyper_lora_step
return (sampler_name, scheduler_name, steps, round(cfg_scale, 2),
model_concept, clip_selection,
strength_lcm_lora_model, strength_lcm_lora_clip,
@@ -384,6 +400,7 @@ class PrimereModelConceptSelector:
cascade_stage_a, cascade_stage_b, cascade_stage_c, cascade_clip,
hypersd_selector, hypersd_model_step, strength_hypersd_lora_model, strength_hypersd_lora_clip,
flux_selector, flux_diffusion, flux_weight_dtype, flux_gguf, flux_clip_t5xxl, flux_clip_l, flux_clip_guidance, flux_vae, flux_sampler,
use_flux_hyper_lora, flux_hyper_lora_type, flux_hyper_lora_step, strength_fluxhyper_lora_model, strength_fluxhyper_lora_clip,
hunyuan_clip_t5xxl, hunyuan_clip_l, hunyuan_vae,
sd3_clip_g, sd3_clip_l, sd3_clip_t5xxl, sd3_unet_vae,
)
@@ -423,6 +440,7 @@ class PrimereCKPTLoader:
cascade_stage_a = None, cascade_stage_b = None, cascade_stage_c = None, cascade_clip = None,
loaded_model = None, loaded_clip = None, loaded_vae = None,
flux_selector = 'DIFFUSION', flux_diffusion = None, flux_weight_dtype = None, flux_gguf = None, flux_clip_t5xxl = None, flux_clip_l = None, flux_clip_guidance = None, flux_vae = None,
use_flux_hyper_lora = False, flux_hyper_lora_type = 'FLUX.1-dev-fp16', flux_hyper_lora_step = 8, strength_fluxhyper_lora_model = 1, strength_fluxhyper_lora_clip = 1,
hunyuan_clip_t5xxl = None, hunyuan_clip_l = None, hunyuan_vae = None,
sd3_clip_g = None, sd3_clip_l = None, sd3_clip_t5xxl = None, sd3_unet_vae = None
):
@@ -490,6 +508,17 @@ class PrimereCKPTLoader:
flux_clip_guidance = concept_data['flux_clip_guidance']
if 'flux_vae' in concept_data:
flux_vae = concept_data['flux_vae']
if 'use_flux_hyper_lora' in concept_data:
use_flux_hyper_lora = concept_data['use_flux_hyper_lora']
if 'flux_hyper_lora_type' in concept_data:
flux_hyper_lora_type = concept_data['flux_hyper_lora_type']
if 'flux_hyper_lora_step' in concept_data:
flux_hyper_lora_step = concept_data['flux_hyper_lora_step']
if 'strength_fluxhyper_lora_model' in concept_data:
strength_fluxhyper_lora_model = concept_data['strength_fluxhyper_lora_model']
if 'strength_fluxhyper_lora_clip' in concept_data:
strength_fluxhyper_lora_clip = concept_data['strength_fluxhyper_lora_clip']
# if 'flux_sampler' in concept_data:
# flux_sampler = concept_data['flux_sampler']
if 'sd3_clip_g' in concept_data:
@@ -587,13 +616,13 @@ class PrimereCKPTLoader:
MODEL_DIFFUSION = nodes.UNETLoader.load_unet(self, flux_diffusion, flux_weight_dtype)[0]
DUAL_CLIP = nodes.DualCLIPLoader.load_clip(self, flux_clip_t5xxl, flux_clip_l, 'flux')[0]
FLUX_VAE = nodes.VAELoader.load_vae(self, flux_vae)[0]
return (MODEL_DIFFUSION,) + (DUAL_CLIP,) + (FLUX_VAE,) + (MODEL_VERSION,)
# return (MODEL_DIFFUSION,) + (DUAL_CLIP,) + (FLUX_VAE,) + (MODEL_VERSION,)
case 'GGUF':
MODEL_GGUF = gguf_nodes.UnetLoaderGGUF.load_unet(self, flux_gguf)[0]
CLIP_GGUF = gguf_nodes.DualCLIPLoaderGGUF.load_clip(self, flux_clip_t5xxl, flux_clip_l, 'flux')[0]
MODEL_DIFFUSION = gguf_nodes.UnetLoaderGGUF.load_unet(self, flux_gguf)[0]
DUAL_CLIP = gguf_nodes.DualCLIPLoaderGGUF.load_clip(self, flux_clip_t5xxl, flux_clip_l, 'flux')[0]
FLUX_VAE = nodes.VAELoader.load_vae(self, flux_vae)[0]
return (MODEL_GGUF,) + (CLIP_GGUF,) + (FLUX_VAE,) + (MODEL_VERSION,)
# return (MODEL_GGUF,) + (CLIP_GGUF,) + (FLUX_VAE,) + (MODEL_VERSION,)
case 'SAFETENSOR':
fullpathFile = folder_paths.get_full_path('checkpoints', ckpt_name)
@@ -632,7 +661,75 @@ class PrimereCKPTLoader:
DUAL_CLIP = nodes.DualCLIPLoader.load_clip(self, flux_clip_t5xxl, flux_clip_l, 'flux')[0]
FLUX_VAE = nodes.VAELoader.load_vae(self, flux_vae)[0]
return (MODEL_DIFFUSION,) + (DUAL_CLIP,) + (FLUX_VAE,) + (MODEL_VERSION,)
if use_flux_hyper_lora == 'True-later':
print('Kell flux lora....')
FLUX_DEV_LORA8 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-FLUX.1-dev-8steps-lora.safetensors?download=true'
FLUX_DEV_FP16_LORA8 = 'https://huggingface.co/nakodanei/Hyper-FLUX.1-dev-8steps-lora-fp16/resolve/main/Hyper-FLUX.1-dev-8steps-lora-fp16.safetensors?download=true'
FLUX_DEV_LORA16 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-FLUX.1-dev-16steps-lora.safetensors?download=true'
DOWNLOADED_FLUX_DEV_LORA8 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-FLUX.1-dev-8steps-lora-fp16.safetensors')
DOWNLOADED_FLUX_DEV_FP16_LORA8 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-FLUX.1-dev-8steps-lora.safetensors')
DOWNLOADED_FLUX_DEV_LORA16 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-FLUX.1-dev-16steps-lora.safetensors')
if os.path.exists(DOWNLOADED_FLUX_DEV_LORA8) == False:
print('Downloading HYPER DEV 8STEP Lora....')
reqsdlcm = requests.get(FLUX_DEV_LORA8, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_FLUX_DEV_LORA8, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload HYPER DEV 8STEP Lora')
if os.path.exists(DOWNLOADED_FLUX_DEV_FP16_LORA8) == False:
print('Downloading HYPER DEV 8STEP FP16 Lora....')
reqsdlcm = requests.get(FLUX_DEV_FP16_LORA8, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_FLUX_DEV_FP16_LORA8, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload HYPER DEV 8STEP FP16 Lora')
if os.path.exists(DOWNLOADED_FLUX_DEV_LORA16) == False:
print('Downloading HYPER DEV 16STEP LORA....')
reqsdlcm = requests.get(FLUX_DEV_LORA16, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_FLUX_DEV_LORA16, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload HYPER DEV 16STEP Lora')
print('fluxlorapath test...')
downloaded_filelist_filtered = utility.getDownloadedFiles()
print(downloaded_filelist_filtered)
allHyperFluxLoras = list(filter(lambda a: 'hyper-flux'.casefold() in a.casefold(), downloaded_filelist_filtered))
print(allHyperFluxLoras)
finalLoras = list(filter(lambda a: str(flux_hyper_lora_step) + 'step'.casefold() in a.casefold(), allHyperFluxLoras))
print(finalLoras)
if flux_hyper_lora_type == 'FLUX.1-dev-fp16':
finalLoras = list(filter(lambda a: 'steps-lora-fp16'.casefold() in a.casefold(), finalLoras))
print(finalLoras)
LORA_FILE = finalLoras[0]
print(LORA_FILE)
FULL_LORA_PATH = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', LORA_FILE)
print(FULL_LORA_PATH)
if FULL_LORA_PATH is not None and os.path.exists(FULL_LORA_PATH) == True:
print('Lora path ok')
if strength_fluxhyper_lora_model != 0 or strength_fluxhyper_lora_clip != 0:
lora = None
if self.loaded_lora is not None:
if self.loaded_lora[0] == FULL_LORA_PATH:
lora = self.loaded_lora[1]
else:
temp = self.loaded_lora
self.loaded_lora = None
del temp
if lora is None:
lora = comfy.utils.load_torch_file(FULL_LORA_PATH, safe_load = False)
self.loaded_lora = (FULL_LORA_PATH, lora)
MODEL_DIFFUSION, DUAL_CLIP = comfy.sd.load_lora_for_models(MODEL_DIFFUSION, DUAL_CLIP, lora, strength_fluxhyper_lora_model, strength_fluxhyper_lora_clip)
print('Flux lora loaded...')
return (MODEL_DIFFUSION,) + (DUAL_CLIP,) + (FLUX_VAE,) + (MODEL_VERSION,)
case 'Hyper':
if hypersd_selector == 'UNET':
@@ -643,7 +740,6 @@ class PrimereCKPTLoader:
unet_name = ModelConceptChanges['unet_name']
hyperModeValid = ModelConceptChanges['hyperModeValid']
OUTPUT_MODEL = utility.LightningConceptModel(self, model_concept, hyperModeValid, hypersd_selector, hypersd_model_step, None, None, lora_name, unet_name)[0]
# (self, model_concept, lightningModeValid, lightning_selector, lightning_model_step, OUTPUT_MODEL, OUTPUT_CLIP, lora_name, unet_name, lora_model_strength = 1, lora_clip_strength = 0):
return (OUTPUT_MODEL[0],) + (OUTPUT_MODEL[1],) + (OUTPUT_MODEL[2],) + (MODEL_VERSION,)
path = Path(ckpt_name)
@@ -743,6 +839,131 @@ class PrimereCKPTLoader:
case 'Hyper' | 'Lightning':
if model_concept == 'Hyper' and MODEL_VERSION == 'Hyper':
MODEL_VERSION = 'SDXL'
print('Hyper Ligntning loras check....')
if lightning_selector == 'LORA':
Lightning_SDXL_2 = 'https://huggingface.co/ByteDance/SDXL-Lightning/resolve/main/sdxl_lightning_2step_lora.safetensors?download=true'
DOWNLOADED_Lightning_SDXL_2 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'sdxl_lightning_2step_lora.safetensors')
Lightning_SDXL_4 = 'https://huggingface.co/ByteDance/SDXL-Lightning/resolve/main/sdxl_lightning_4step_lora.safetensors?download=true'
DOWNLOADED_Lightning_SDXL_4 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'sdxl_lightning_4step_lora.safetensors')
Lightning_SDXL_8 = 'https://huggingface.co/ByteDance/SDXL-Lightning/resolve/main/sdxl_lightning_8step_lora.safetensors?download=true'
DOWNLOADED_Lightning_SDXL_8 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'sdxl_lightning_8step_lora.safetensors')
if os.path.exists(DOWNLOADED_Lightning_SDXL_2) == False:
print('Downloading SDXL Lightning LORA S2....')
reqsdlcm = requests.get(Lightning_SDXL_2, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Lightning_SDXL_2, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SDXL Lightning LORA S2')
if os.path.exists(DOWNLOADED_Lightning_SDXL_4) == False:
print('Downloading SDXL Lightning LORA S4....')
reqsdlcm = requests.get(Lightning_SDXL_4, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Lightning_SDXL_4, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SDXL Lightning LORA S4')
if os.path.exists(DOWNLOADED_Lightning_SDXL_8) == False:
print('Downloading SDXL Lightning LORA S8....')
reqsdlcm = requests.get(Lightning_SDXL_8, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Lightning_SDXL_8, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SDXL Lightning LORA S8')
if hypersd_selector == 'LORA':
Hyper_SD_1 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SD15-1step-lora.safetensors?download=true'
DOWNLOADED_Hyper_SD_1 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-SD15-1step-lora.safetensors')
Hyper_SD_2 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SD15-2steps-lora.safetensors?download=true'
DOWNLOADED_Hyper_SD_2 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-SD15-2steps-lora.safetensors')
Hyper_SD_4 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SD15-4steps-lora.safetensors?download=true'
DOWNLOADED_Hyper_SD_4 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-SD15-4steps-lora.safetensors')
Hyper_SD_8 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SD15-8steps-lora.safetensors?download=true'
DOWNLOADED_Hyper_SD_8 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-SD15-8steps-lora.safetensors')
Hyper_SDXL_1 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SDXL-1step-lora.safetensors?download=true'
DOWNLOADED_Hyper_SDXL_1 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-SDXL-1step-lora.safetensors')
Hyper_SDXL_2 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SDXL-2steps-lora.safetensors?download=true'
DOWNLOADED_Hyper_SDXL_2 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-SDXL-2steps-lora.safetensors')
Hyper_SDXL_4 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SDXL-4steps-lora.safetensors?download=true'
DOWNLOADED_Hyper_SDXL_4 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-SDXL-4steps-lora.safetensors')
Hyper_SDXL_8 = 'https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SDXL-8steps-lora.safetensors?download=true'
DOWNLOADED_Hyper_SDXL_8 = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', 'Hyper-SDXL-8steps-lora.safetensors')
if os.path.exists(DOWNLOADED_Hyper_SD_1) == False:
print('Downloading SD Hyper LORA S1....')
reqsdlcm = requests.get(Hyper_SD_1, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Hyper_SD_1, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SD Hyper LORA S1')
if os.path.exists(DOWNLOADED_Hyper_SD_2) == False:
print('Downloading SD Hyper LORA S2....')
reqsdlcm = requests.get(Hyper_SD_2, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Hyper_SD_2, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SD Hyper LORA S2')
if os.path.exists(DOWNLOADED_Hyper_SD_4) == False:
print('Downloading SD Hyper LORA S4....')
reqsdlcm = requests.get(Hyper_SD_4, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Hyper_SD_4, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SD Hyper LORA S4')
if os.path.exists(DOWNLOADED_Hyper_SD_8) == False:
print('Downloading SD Hyper LORA S8....')
reqsdlcm = requests.get(Hyper_SD_8, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Hyper_SD_8, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SD Hyper LORA S8')
if os.path.exists(DOWNLOADED_Hyper_SDXL_1) == False:
print('Downloading SDXL Hyper LORA S1....')
reqsdlcm = requests.get(Hyper_SDXL_1, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Hyper_SDXL_1, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SDXL Hyper LORA S1')
if os.path.exists(DOWNLOADED_Hyper_SDXL_2) == False:
print('Downloading SDXL Hyper LORA S2....')
reqsdlcm = requests.get(Hyper_SDXL_2, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Hyper_SDXL_2, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SDXL Hyper LORA S2')
if os.path.exists(DOWNLOADED_Hyper_SDXL_4) == False:
print('Downloading SDXL Hyper LORA S4....')
reqsdlcm = requests.get(Hyper_SDXL_4, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Hyper_SDXL_4, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SDXL Hyper LORA S4')
if os.path.exists(DOWNLOADED_Hyper_SDXL_8) == False:
print('Downloading SDXL Hyper LORA S8....')
reqsdlcm = requests.get(Hyper_SDXL_8, allow_redirects=True)
if reqsdlcm.status_code == 200 and reqsdlcm.ok == True:
open(DOWNLOADED_Hyper_SDXL_8, 'wb').write(reqsdlcm.content)
else:
print('ERROR: Cannot dowload SDXL Hyper LORA S8')
print('5')
print('Hyper or Lightning')
print(MODEL_VERSION)
@@ -750,7 +971,7 @@ class PrimereCKPTLoader:
print('6')
print(ModelConceptChanges)
ckpt_name = ModelConceptChanges['ckpt_name']
lora_name = ModelConceptChanges['lora_name']
lora_name = os.path.join(PRIMERE_ROOT, 'Nodes', 'Downloads', ModelConceptChanges['lora_name'])
unet_name = ModelConceptChanges['unet_name']
lightningModeValid = ModelConceptChanges['lightningModeValid']
hyperModeValid = ModelConceptChanges['hyperModeValid']
@@ -796,9 +1017,8 @@ class PrimereCKPTLoader:
if LORA_PATH is not None and os.path.exists(LORA_PATH) == True:
print('Lora path ok')
if strength_lcm_lora_model > 0 or strength_lcm_lora_clip > 0:
if strength_lcm_lora_model != 0 or strength_lcm_lora_clip != 0:
lora = None
if self.loaded_lora is not None:
if self.loaded_lora[0] == LORA_PATH:
lora = self.loaded_lora[1]
@@ -2179,6 +2399,11 @@ class PrimereConceptDataTuple:
"flux_clip_guidance": ("FLOAT", {"default": 3.5, "forceInput": True}),
"flux_vae": ("STRING", {"forceInput": True}),
"flux_sampler": ("STRING", {"forceInput": True}),
"use_flux_hyper_lora": ("FLUX_HYPER_LORA", {"forceInput": True}),
"flux_hyper_lora_type": ("STRING", {"forceInput": True}),
"flux_hyper_lora_step": ("INT", {"forceInput": True}),
"strength_fluxhyper_lora_model": ("INT", {"forceInput": True}),
"strength_fluxhyper_lora_clip": ("INT", {"forceInput": True}),
"hunyuan_clip_t5xxl": ("STRING", {"forceInput": True}),
"hunyuan_clip_l": ("STRING", {"forceInput": True}),
+2 -2
View File
@@ -548,7 +548,7 @@ class PrimereKSampler:
"align_your_steps": ("BOOLEAN", {"default": False, "label_on": "Use AlignYourSteps", "label_off": "Ignore AlignYourSteps"}),
},
"optional": {
"model_concept": ("STRING", {"default": "Normal", "forceInput": True}),
"model_concept": ("STRING", {"default": "Auto", "forceInput": True}),
"workflow_tuple": ("TUPLE", {"default": None}),
},
"hidden": {
@@ -562,7 +562,7 @@ class PrimereKSampler:
if kwargs['variation_extender'] > 0 or kwargs['device'] != 'DEFAULT' or kwargs['variation_batch_step'] > 0 or kwargs['variation_level'] == True:
return float("NaN")
def pk_sampler(self, model, seed, steps, cfg, sampler_name, scheduler_name, positive, negative, latent_image, extra_pnginfo, prompt, model_concept = "Normal", workflow_tuple = None, denoise=1.0, variation_extender = 0, variation_batch_step = 0, variation_level = False, model_sampling = 2.5, device = 'DEFAULT', align_your_steps = False):
def pk_sampler(self, model, seed, steps, cfg, sampler_name, scheduler_name, positive, negative, latent_image, extra_pnginfo, prompt, model_concept = "Auto", workflow_tuple = None, denoise=1.0, variation_extender = 0, variation_batch_step = 0, variation_level = False, model_sampling = 2.5, device = 'DEFAULT', align_your_steps = False):
if workflow_tuple is not None and len(workflow_tuple) > 0 and 'exif_status' in workflow_tuple and workflow_tuple['exif_status'] == 'SUCCEED':
if 'sampler_settings' in workflow_tuple and len(workflow_tuple['sampler_settings']) > 0 and 'setup_states' in workflow_tuple and 'sampler_setup' in workflow_tuple['setup_states']:
if workflow_tuple['setup_states']['sampler_setup'] == True:
File diff suppressed because it is too large Load Diff
+46 -5
View File
@@ -749,6 +749,8 @@ def ModelConceptNames(ckpt_name, model_concept, lightning_selector, lightning_mo
lightningModeValid = False
hyperModeValid = False
LoraList = getDownloadedFiles()
if model_concept == 'Lightning':
if lightning_selector == 'SAFETENSOR':
allCheckpoints = folder_paths.get_filename_list("checkpoints")
@@ -760,7 +762,7 @@ def ModelConceptNames(ckpt_name, model_concept, lightning_selector, lightning_mo
ckpt_name = finalLightning[0]
if lightning_selector == 'LORA':
LoraList = folder_paths.get_filename_list("loras")
# LoraList = folder_paths.get_filename_list("loras")
if len(LoraList) > 0:
allLoraLightning = list(filter(lambda a: 'sdxl_lightning_'.casefold() in a.casefold(), LoraList))
if len(allLoraLightning) > 0:
@@ -781,7 +783,7 @@ def ModelConceptNames(ckpt_name, model_concept, lightning_selector, lightning_mo
if model_concept == 'Hyper':
if hypersd_selector == 'LORA':
LoraList = folder_paths.get_filename_list("loras")
# LoraList = folder_paths.get_filename_list("loras")
if len(LoraList) > 0:
if model_version == 'SDXL':
allLoraHyper = list(filter(lambda a: 'Hyper-SDXL-'.casefold() in a.casefold(), LoraList))
@@ -810,7 +812,23 @@ def ModelConceptNames(ckpt_name, model_concept, lightning_selector, lightning_mo
def LightningConceptModel(self, model_concept, lightningModeValid, lightning_selector, lightning_model_step, OUTPUT_MODEL, OUTPUT_CLIP, lora_name, unet_name, lora_model_strength = 1, lora_clip_strength = 0):
CLIP_MODEL = OUTPUT_CLIP
if model_concept == 'Lightning' and lightningModeValid == True and lightning_selector == 'LORA' and lora_name is not None:
OUTPUT_MODEL, CLIP_MODEL = nodes.LoraLoader.load_lora(self, OUTPUT_MODEL, OUTPUT_CLIP, lora_name, lora_model_strength, lora_clip_strength)
# OUTPUT_MODEL, CLIP_MODEL = nodes.LoraLoader.load_lora(self, OUTPUT_MODEL, OUTPUT_CLIP, lora_name, lora_model_strength, lora_clip_strength)
if lora_model_strength != 0 or lora_clip_strength != 0:
lora = None
if self.loaded_lora is not None:
if self.loaded_lora[0] == lora_name:
lora = self.loaded_lora[1]
else:
temp = self.loaded_lora
self.loaded_lora = None
del temp
if lora is None:
lora = comfy.utils.load_torch_file(lora_name, safe_load=True)
self.loaded_lora = (lora_name, lora)
print(lora_name)
OUTPUT_MODEL, CLIP_MODEL = comfy.sd.load_lora_for_models(OUTPUT_MODEL, OUTPUT_CLIP, lora, lora_model_strength, lora_clip_strength)
if model_concept == 'Lightning' and lightningModeValid == True and lightning_selector == 'UNET' and unet_name is not None:
OUTPUT_MODEL = nodes.UNETLoader.load_unet(self, unet_name)[0]
@@ -819,7 +837,23 @@ def LightningConceptModel(self, model_concept, lightningModeValid, lightning_sel
OUTPUT_MODEL = nodes_model_advanced.ModelSamplingDiscrete.patch(self, OUTPUT_MODEL, "x0", False)[0]
if model_concept == 'Hyper' and lightningModeValid == True and lightning_selector == 'LORA' and lora_name is not None:
OUTPUT_MODEL, CLIP_MODEL = nodes.LoraLoader.load_lora(self, OUTPUT_MODEL, OUTPUT_CLIP, lora_name, lora_model_strength, lora_clip_strength)
# OUTPUT_MODEL, CLIP_MODEL = nodes.LoraLoader.load_lora(self, OUTPUT_MODEL, OUTPUT_CLIP, lora_name, lora_model_strength, lora_clip_strength)
if lora_model_strength != 0 or lora_clip_strength != 0:
lora = None
if self.loaded_lora is not None:
if self.loaded_lora[0] == lora_name:
lora = self.loaded_lora[1]
else:
temp = self.loaded_lora
self.loaded_lora = None
del temp
if lora is None:
lora = comfy.utils.load_torch_file(lora_name, safe_load=True)
self.loaded_lora = (lora_name, lora)
print(lora_name)
OUTPUT_MODEL, CLIP_MODEL = comfy.sd.load_lora_for_models(OUTPUT_MODEL, OUTPUT_CLIP, lora, lora_model_strength, lora_clip_strength)
if model_concept == 'Hyper' and lightningModeValid == True and lightning_selector == 'UNET' and unet_name is not None:
unet_path = folder_paths.get_full_path("unet", unet_name)
@@ -1141,4 +1175,11 @@ def Pic2Story(repo_id, img, prompts, special_tokens_skip = True, clean_same_resu
story_out = ' '.join(dict.fromkeys(story_out.split()))
return story_out.rstrip(', ').replace(' and ', ' ').replace(' an ', ' ').replace(' is ', ' ').replace(' are ', ' ')
else:
return story_out
return story_out
def getDownloadedFiles():
DOWNLOAD_DIR = os.path.join(here, 'Nodes', 'Downloads')
folder_paths.add_model_folder_path("primere_downloads", DOWNLOAD_DIR)
downloaded_filelist = folder_paths.get_filename_list("primere_downloads")
downloaded_filelist_filtered = folder_paths.filter_files_extensions(downloaded_filelist, ['.ckpt', '.safetensors'])
return downloaded_filelist_filtered