diff --git a/backend/diffusion_engine/chroma.py b/backend/diffusion_engine/chroma.py index a10256d7..276b7297 100644 --- a/backend/diffusion_engine/chroma.py +++ b/backend/diffusion_engine/chroma.py @@ -11,6 +11,8 @@ from backend.modules.k_prediction import PredictionFlux from backend import memory_management class Chroma(ForgeDiffusionEngine): + matched_guesses = [model_list.Chroma] + def __init__(self, estimated_config, huggingface_components): super().__init__(estimated_config, huggingface_components) self.is_inpaint = False diff --git a/backend/loader.py b/backend/loader.py index a090adab..8d5756be 100644 --- a/backend/loader.py +++ b/backend/loader.py @@ -482,18 +482,7 @@ def split_state_dict(sd, additional_state_dicts: list = None): return state_dict, guess -# To be removed once PR merged on huggingface_guess -chroma_is_in_huggingface_guess = hasattr(huggingface_guess.model_list, "Chroma") -if not chroma_is_in_huggingface_guess: - class GuessChroma: - huggingface_repo = 'Chroma' - unet_extra_config = { - 'guidance_out_dim': 3072, - 'guidance_hidden_dim': 5120, - 'guidance_n_layers': 5 - } - unet_remove_config = ['guidance_embed'] @torch.inference_mode() def forge_loader(sd, additional_state_dicts=None): try: @@ -501,17 +490,6 @@ def forge_loader(sd, additional_state_dicts=None): except: raise ValueError('Failed to recognize model type!') - if not chroma_is_in_huggingface_guess \ - and estimated_config.huggingface_repo == "black-forest-labs/FLUX.1-schnell" \ - and "transformer" in state_dicts \ - and "distilled_guidance_layer.layers.0.in_layer.bias" in state_dicts["transformer"]: - estimated_config.huggingface_repo = GuessChroma.huggingface_repo - for x in GuessChroma.unet_extra_config: - estimated_config.unet_config[x] = GuessChroma.unet_extra_config[x] - for x in GuessChroma.unet_remove_config: - del estimated_config.unet_config[x] - state_dicts['text_encoder'] = state_dicts['text_encoder_2'] - del state_dicts['text_encoder_2'] repo_name = estimated_config.huggingface_repo local_path = os.path.join(dir_path, 'huggingface', repo_name) @@ -566,8 +544,6 @@ def forge_loader(sd, additional_state_dicts=None): else: huggingface_components['scheduler'].config.prediction_type = prediction_types.get(estimated_config.model_type.name, huggingface_components['scheduler'].config.prediction_type) - if not chroma_is_in_huggingface_guess and estimated_config.huggingface_repo == "Chroma": - return Chroma(estimated_config=estimated_config, huggingface_components=huggingface_components) for M in possible_models: if any(isinstance(estimated_config, x) for x in M.matched_guesses): return M(estimated_config=estimated_config, huggingface_components=huggingface_components) diff --git a/backend/patcher/lora.py b/backend/patcher/lora.py index 1d215c92..89cdabe7 100644 --- a/backend/patcher/lora.py +++ b/backend/patcher/lora.py @@ -1,13 +1,12 @@ import torch -import packages_3rdparty.webui_lora_collection.lora as lora_utils_webui -import packages_3rdparty.comfyui_lora_collection.lora as lora_utils_comfyui +import comfy.lora as lora_utils_comfyui from backend import memory_management, utils extra_weight_calculators = {} -lora_collection_priority = [lora_utils_webui, lora_utils_comfyui] +lora_collection_priority = [lora_utils_comfyui] def get_function(function_name: str): diff --git a/modules/launch_utils.py b/modules/launch_utils.py index 5e6e74d1..dd2ff481 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -384,14 +384,14 @@ def prepare_environment(): # stable_diffusion_repo = os.environ.get('STABLE_DIFFUSION_REPO', "https://github.com/Stability-AI/stablediffusion.git") # stable_diffusion_xl_repo = os.environ.get('STABLE_DIFFUSION_XL_REPO', "https://github.com/Stability-AI/generative-models.git") # k_diffusion_repo = os.environ.get('K_DIFFUSION_REPO', 'https://github.com/crowsonkb/k-diffusion.git') - huggingface_guess_repo = os.environ.get('HUGGINGFACE_GUESS_REPO', 'https://github.com/lllyasviel/huggingface_guess.git') + # huggingface_guess_repo = os.environ.get('HUGGINGFACE_GUESS_REPO', 'https://github.com/lllyasviel/huggingface_guess.git') blip_repo = os.environ.get('BLIP_REPO', 'https://github.com/salesforce/BLIP.git') assets_commit_hash = os.environ.get('ASSETS_COMMIT_HASH', "6f7db241d2f8ba7457bac5ca9753331f0c266917") # stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf") # stable_diffusion_xl_commit_hash = os.environ.get('STABLE_DIFFUSION_XL_COMMIT_HASH', "45c443b316737a4ab6e40413d7794a7f5657c19f") # k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "ab527a9a6d347f364e3d185ba6d714e22d80cb3c") - huggingface_guess_commit_hash = os.environ.get('HUGGINGFACE_GUESS_HASH', "84826248b49bb7ca754c73293299c4d4e23a548d") + # huggingface_guess_commit_hash = os.environ.get('HUGGINGFACE_GUESS_HASH', "84826248b49bb7ca754c73293299c4d4e23a548d") blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "48211a1594f1321b00f14c9f7a5b4813144b2fb9") try: @@ -451,7 +451,7 @@ def prepare_environment(): # git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash) # git_clone(stable_diffusion_xl_repo, repo_dir('generative-models'), "Stable Diffusion XL", stable_diffusion_xl_commit_hash) # git_clone(k_diffusion_repo, repo_dir('k-diffusion'), "K-diffusion", k_diffusion_commit_hash) - git_clone(huggingface_guess_repo, repo_dir('huggingface_guess'), "huggingface_guess", huggingface_guess_commit_hash) + # git_clone(huggingface_guess_repo, repo_dir('huggingface_guess'), "huggingface_guess", huggingface_guess_commit_hash) git_clone(blip_repo, repo_dir('BLIP'), "BLIP", blip_commit_hash) startup_timer.record("clone repositores") diff --git a/modules/paths.py b/modules/paths.py index e9fb1d3e..877f7469 100644 --- a/modules/paths.py +++ b/modules/paths.py @@ -9,9 +9,9 @@ sd_path = os.path.dirname(__file__) path_dirs = [ (os.path.join(sd_path, '../repositories/BLIP'), 'models/blip.py', 'BLIP', []), - (os.path.join(sd_path, '../packages_3rdparty'), 'gguf/quants.py', 'packages_3rdparty', []), + # (os.path.join(sd_path, '../packages_3rdparty'), 'gguf/quants.py', 'packages_3rdparty', []), # (os.path.join(sd_path, '../repositories/k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion', ["atstart"]), - (os.path.join(sd_path, '../repositories/huggingface_guess'), 'huggingface_guess/detection.py', 'huggingface_guess', []), + # (os.path.join(sd_path, '../repositories/huggingface_guess'), 'huggingface_guess/detection.py', 'huggingface_guess', []), ] paths = {} diff --git a/modules_forge/initialization.py b/modules_forge/initialization.py index 63bef3c9..9082c931 100644 --- a/modules_forge/initialization.py +++ b/modules_forge/initialization.py @@ -33,7 +33,7 @@ def initialize_forge(): INITIALIZED = True - sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'packages_3rdparty')) + sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'modules_forge', 'packages')) bad_list = ['--lowvram', '--medvram', '--medvram-sdxl']