mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-04-30 19:21:21 +00:00
remove annoying control model version filter
thanks god
This commit is contained in:
@@ -28,47 +28,6 @@ class HiResFixOption(Enum):
|
||||
return self in (HiResFixOption.BOTH, HiResFixOption.HIGH_RES_ONLY)
|
||||
|
||||
|
||||
class StableDiffusionVersion(Enum):
|
||||
"""The version family of stable diffusion model."""
|
||||
|
||||
UNKNOWN = 0
|
||||
SD1x = 1
|
||||
SD2x = 2
|
||||
SDXL = 3
|
||||
|
||||
@staticmethod
|
||||
def detect_from_model_name(model_name: str) -> "StableDiffusionVersion":
|
||||
"""Based on the model name provided, guess what stable diffusion version it is.
|
||||
This might not be accurate without actually inspect the file content.
|
||||
"""
|
||||
if any(f"sd{v}" in model_name.lower() for v in ("14", "15", "16")):
|
||||
return StableDiffusionVersion.SD1x
|
||||
|
||||
if "sd21" in model_name or "2.1" in model_name:
|
||||
return StableDiffusionVersion.SD2x
|
||||
|
||||
if "xl" in model_name.lower():
|
||||
return StableDiffusionVersion.SDXL
|
||||
|
||||
return StableDiffusionVersion.UNKNOWN
|
||||
|
||||
def encoder_block_num(self) -> int:
|
||||
if self in (StableDiffusionVersion.SD1x, StableDiffusionVersion.SD2x, StableDiffusionVersion.UNKNOWN):
|
||||
return 12
|
||||
else:
|
||||
return 9 # SDXL
|
||||
|
||||
def controlnet_layer_num(self) -> int:
|
||||
return self.encoder_block_num() + 1
|
||||
|
||||
def is_compatible_with(self, other: "StableDiffusionVersion") -> bool:
|
||||
""" Incompatible only when one of version is SDXL and other is not. """
|
||||
return (
|
||||
any(v == StableDiffusionVersion.UNKNOWN for v in [self, other]) or
|
||||
sum(v == StableDiffusionVersion.SDXL for v in [self, other]) != 1
|
||||
)
|
||||
|
||||
|
||||
class InputMode(Enum):
|
||||
# Single image to a single ControlNet unit.
|
||||
SIMPLE = "simple"
|
||||
|
||||
@@ -3,7 +3,6 @@ import stat
|
||||
from collections import OrderedDict
|
||||
|
||||
from modules import shared, sd_models
|
||||
from lib_controlnet.enums import StableDiffusionVersion
|
||||
from modules_forge.shared import controlnet_dir, supported_preprocessors
|
||||
|
||||
from typing import Dict, Tuple, List
|
||||
@@ -108,13 +107,7 @@ def get_filtered_controlnet_names(tag):
|
||||
model_filename_filters = []
|
||||
for p in filtered_preprocessors.values():
|
||||
model_filename_filters += p.model_filename_filters
|
||||
return [
|
||||
x for x in controlnet_names
|
||||
if x == 'None' or (
|
||||
any(f.lower() in x.lower() for f in model_filename_filters) and
|
||||
get_sd_version().is_compatible_with(StableDiffusionVersion.detect_from_model_name(x))
|
||||
)
|
||||
]
|
||||
return [x for x in controlnet_names if x == 'None' or any(f.lower() in x.lower() for f in model_filename_filters)]
|
||||
|
||||
|
||||
def update_controlnet_filenames():
|
||||
@@ -138,22 +131,8 @@ def update_controlnet_filenames():
|
||||
return
|
||||
|
||||
|
||||
def get_sd_version() -> StableDiffusionVersion:
|
||||
if not shared.sd_model:
|
||||
return StableDiffusionVersion.UNKNOWN
|
||||
if shared.sd_model.is_sdxl:
|
||||
return StableDiffusionVersion.SDXL
|
||||
elif shared.sd_model.is_sd2:
|
||||
return StableDiffusionVersion.SD2x
|
||||
elif shared.sd_model.is_sd1:
|
||||
return StableDiffusionVersion.SD1x
|
||||
else:
|
||||
return StableDiffusionVersion.UNKNOWN
|
||||
|
||||
|
||||
def select_control_type(
|
||||
control_type: str,
|
||||
sd_version: StableDiffusionVersion = StableDiffusionVersion.UNKNOWN,
|
||||
) -> Tuple[List[str], List[str], str, str]:
|
||||
global controlnet_names
|
||||
|
||||
|
||||
Reference in New Issue
Block a user