2023-06-11 16:51:50 +00:00
|
|
|
import json
|
2023-09-20 19:03:15 +00:00
|
|
|
import re
|
2023-06-11 16:51:50 +00:00
|
|
|
from dataclasses import dataclass
|
|
|
|
from pathlib import Path
|
2023-08-18 15:18:46 +00:00
|
|
|
from typing import Callable, Dict, Literal, Optional, Union
|
2023-08-18 03:01:21 +00:00
|
|
|
|
|
|
|
import safetensors.torch
|
|
|
|
import torch
|
2023-08-18 15:18:46 +00:00
|
|
|
from diffusers import ConfigMixin, ModelMixin
|
2023-06-11 16:51:50 +00:00
|
|
|
from picklescan.scanner import scan_file_path
|
|
|
|
|
2023-09-14 15:18:43 +00:00
|
|
|
from invokeai.backend.model_management.models.ip_adapter import IPAdapterModelFormat
|
2023-09-13 21:14:20 +00:00
|
|
|
|
2023-06-24 16:37:26 +00:00
|
|
|
from .models import (
|
2023-07-28 13:46:44 +00:00
|
|
|
BaseModelType,
|
2023-08-18 15:18:46 +00:00
|
|
|
InvalidModelException,
|
2023-07-28 13:46:44 +00:00
|
|
|
ModelType,
|
|
|
|
ModelVariantType,
|
|
|
|
SchedulerPredictionType,
|
|
|
|
SilenceWarnings,
|
2023-06-24 16:37:26 +00:00
|
|
|
)
|
|
|
|
from .models.base import read_checkpoint_meta
|
2023-08-18 03:01:21 +00:00
|
|
|
from .util import lora_token_vector_length
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
@dataclass
|
2023-06-17 02:54:36 +00:00
|
|
|
class ModelProbeInfo(object):
|
2023-06-11 16:51:50 +00:00
|
|
|
model_type: ModelType
|
|
|
|
base_type: BaseModelType
|
2023-06-12 20:07:04 +00:00
|
|
|
variant_type: ModelVariantType
|
|
|
|
prediction_type: SchedulerPredictionType
|
2023-06-13 15:05:12 +00:00
|
|
|
upcast_attention: bool
|
2023-07-28 13:46:44 +00:00
|
|
|
format: Literal["diffusers", "checkpoint", "lycoris", "olive", "onnx"]
|
2023-06-12 20:07:04 +00:00
|
|
|
image_size: int
|
2023-11-23 03:29:02 +00:00
|
|
|
name: Optional[str] = None
|
|
|
|
description: Optional[str] = None
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class ProbeBase(object):
|
2023-07-28 13:46:44 +00:00
|
|
|
"""forward declaration"""
|
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
pass
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class ModelProbe(object):
|
|
|
|
PROBES = {
|
2023-07-28 13:46:44 +00:00
|
|
|
"diffusers": {},
|
|
|
|
"checkpoint": {},
|
2023-07-28 20:54:03 +00:00
|
|
|
"onnx": {},
|
2023-06-11 16:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CLASS2TYPE = {
|
2023-07-28 13:46:44 +00:00
|
|
|
"StableDiffusionPipeline": ModelType.Main,
|
|
|
|
"StableDiffusionInpaintPipeline": ModelType.Main,
|
|
|
|
"StableDiffusionXLPipeline": ModelType.Main,
|
|
|
|
"StableDiffusionXLImg2ImgPipeline": ModelType.Main,
|
2023-09-02 02:58:14 +00:00
|
|
|
"StableDiffusionXLInpaintPipeline": ModelType.Main,
|
2023-11-22 19:58:27 +00:00
|
|
|
"LatentConsistencyModelPipeline": ModelType.Main,
|
2023-07-28 13:46:44 +00:00
|
|
|
"AutoencoderKL": ModelType.Vae,
|
2023-08-18 02:59:31 +00:00
|
|
|
"AutoencoderTiny": ModelType.Vae,
|
2023-07-28 13:46:44 +00:00
|
|
|
"ControlNetModel": ModelType.ControlNet,
|
2023-09-14 13:54:10 +00:00
|
|
|
"CLIPVisionModelWithProjection": ModelType.CLIPVision,
|
2023-10-05 05:29:16 +00:00
|
|
|
"T2IAdapter": ModelType.T2IAdapter,
|
2023-06-11 16:51:50 +00:00
|
|
|
}
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
@classmethod
|
2023-07-31 20:47:48 +00:00
|
|
|
def register_probe(
|
|
|
|
cls, format: Literal["diffusers", "checkpoint", "onnx"], model_type: ModelType, probe_class: ProbeBase
|
|
|
|
):
|
2023-06-11 16:51:50 +00:00
|
|
|
cls.PROBES[format][model_type] = probe_class
|
|
|
|
|
2023-06-12 20:07:04 +00:00
|
|
|
@classmethod
|
2023-07-28 13:46:44 +00:00
|
|
|
def heuristic_probe(
|
|
|
|
cls,
|
|
|
|
model: Union[Dict, ModelMixin, Path],
|
|
|
|
prediction_type_helper: Callable[[Path], SchedulerPredictionType] = None,
|
|
|
|
) -> ModelProbeInfo:
|
|
|
|
if isinstance(model, Path):
|
|
|
|
return cls.probe(model_path=model, prediction_type_helper=prediction_type_helper)
|
|
|
|
elif isinstance(model, (dict, ModelMixin, ConfigMixin)):
|
2023-06-12 20:07:04 +00:00
|
|
|
return cls.probe(model_path=None, model=model, prediction_type_helper=prediction_type_helper)
|
|
|
|
else:
|
2023-07-18 03:08:39 +00:00
|
|
|
raise InvalidModelException("model parameter {model} is neither a Path, nor a model")
|
2023-06-12 20:07:04 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
@classmethod
|
2023-07-28 13:46:44 +00:00
|
|
|
def probe(
|
|
|
|
cls,
|
|
|
|
model_path: Path,
|
|
|
|
model: Optional[Union[Dict, ModelMixin]] = None,
|
|
|
|
prediction_type_helper: Optional[Callable[[Path], SchedulerPredictionType]] = None,
|
|
|
|
) -> ModelProbeInfo:
|
|
|
|
"""
|
2023-06-11 16:51:50 +00:00
|
|
|
Probe the model at model_path and return sufficient information about it
|
|
|
|
to place it somewhere in the models directory hierarchy. If the model is
|
|
|
|
already loaded into memory, you may provide it as model in order to avoid
|
2023-06-12 20:07:04 +00:00
|
|
|
opening it a second time. The prediction_type_helper callable is a function that receives
|
2023-09-24 16:22:29 +00:00
|
|
|
the path to the model and returns the SchedulerPredictionType.
|
2023-07-28 13:46:44 +00:00
|
|
|
"""
|
2023-06-11 23:51:53 +00:00
|
|
|
if model_path:
|
2023-07-28 13:46:44 +00:00
|
|
|
format_type = "diffusers" if model_path.is_dir() else "checkpoint"
|
2023-06-11 23:51:53 +00:00
|
|
|
else:
|
2023-07-28 13:46:44 +00:00
|
|
|
format_type = "diffusers" if isinstance(model, (ConfigMixin, ModelMixin)) else "checkpoint"
|
2023-06-11 16:51:50 +00:00
|
|
|
model_info = None
|
|
|
|
try:
|
2023-07-28 13:46:44 +00:00
|
|
|
model_type = (
|
|
|
|
cls.get_model_type_from_folder(model_path, model)
|
|
|
|
if format_type == "diffusers"
|
|
|
|
else cls.get_model_type_from_checkpoint(model_path, model)
|
|
|
|
)
|
2023-07-31 20:47:48 +00:00
|
|
|
format_type = "onnx" if model_type == ModelType.ONNX else format_type
|
2023-06-27 16:30:53 +00:00
|
|
|
probe_class = cls.PROBES[format_type].get(model_type)
|
2023-06-11 16:51:50 +00:00
|
|
|
if not probe_class:
|
|
|
|
return None
|
2023-06-12 20:07:04 +00:00
|
|
|
probe = probe_class(model_path, model, prediction_type_helper)
|
2023-06-11 16:51:50 +00:00
|
|
|
base_type = probe.get_base_type()
|
|
|
|
variant_type = probe.get_variant_type()
|
2023-06-12 20:07:04 +00:00
|
|
|
prediction_type = probe.get_scheduler_prediction_type()
|
2023-11-23 03:29:02 +00:00
|
|
|
name = cls.get_model_name(model_path)
|
|
|
|
description = f"{base_type.value} {model_type.value} model {name}"
|
2023-06-27 16:30:53 +00:00
|
|
|
format = probe.get_format()
|
2023-06-17 02:54:36 +00:00
|
|
|
model_info = ModelProbeInfo(
|
2023-07-28 13:46:44 +00:00
|
|
|
model_type=model_type,
|
|
|
|
base_type=base_type,
|
|
|
|
variant_type=variant_type,
|
|
|
|
prediction_type=prediction_type,
|
2023-11-26 22:13:31 +00:00
|
|
|
name=name,
|
|
|
|
description=description,
|
2023-07-28 13:46:44 +00:00
|
|
|
upcast_attention=(
|
|
|
|
base_type == BaseModelType.StableDiffusion2
|
|
|
|
and prediction_type == SchedulerPredictionType.VPrediction
|
|
|
|
),
|
|
|
|
format=format,
|
2023-09-13 21:14:20 +00:00
|
|
|
image_size=(
|
|
|
|
1024
|
|
|
|
if (base_type in {BaseModelType.StableDiffusionXL, BaseModelType.StableDiffusionXLRefiner})
|
|
|
|
else (
|
|
|
|
768
|
|
|
|
if (
|
|
|
|
base_type == BaseModelType.StableDiffusion2
|
|
|
|
and prediction_type == SchedulerPredictionType.VPrediction
|
|
|
|
)
|
|
|
|
else 512
|
|
|
|
)
|
|
|
|
),
|
2023-06-11 16:51:50 +00:00
|
|
|
)
|
2023-06-23 20:35:39 +00:00
|
|
|
except Exception:
|
2023-07-05 19:38:07 +00:00
|
|
|
raise
|
2023-06-11 16:51:50 +00:00
|
|
|
|
|
|
|
return model_info
|
|
|
|
|
2023-11-23 03:29:02 +00:00
|
|
|
@classmethod
|
|
|
|
def get_model_name(cls, model_path: Path) -> str:
|
2023-11-26 22:13:31 +00:00
|
|
|
if model_path.suffix in {".safetensors", ".bin", ".pt", ".ckpt"}:
|
2023-11-23 03:29:02 +00:00
|
|
|
return model_path.stem
|
|
|
|
else:
|
|
|
|
return model_path.name
|
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
@classmethod
|
2023-06-24 16:37:26 +00:00
|
|
|
def get_model_type_from_checkpoint(cls, model_path: Path, checkpoint: dict) -> ModelType:
|
2023-07-28 13:46:44 +00:00
|
|
|
if model_path.suffix not in (".bin", ".pt", ".ckpt", ".safetensors", ".pth"):
|
2023-06-13 05:27:51 +00:00
|
|
|
return None
|
2023-06-24 16:37:26 +00:00
|
|
|
|
|
|
|
if model_path.name == "learned_embeds.bin":
|
2023-06-13 05:27:51 +00:00
|
|
|
return ModelType.TextualInversion
|
2023-06-24 16:37:26 +00:00
|
|
|
|
2023-06-27 16:30:53 +00:00
|
|
|
ckpt = checkpoint if checkpoint else read_checkpoint_meta(model_path, scan=True)
|
|
|
|
ckpt = ckpt.get("state_dict", ckpt)
|
2023-06-24 16:37:26 +00:00
|
|
|
|
2023-06-27 16:30:53 +00:00
|
|
|
for key in ckpt.keys():
|
2023-06-24 16:37:26 +00:00
|
|
|
if any(key.startswith(v) for v in {"cond_stage_model.", "first_stage_model.", "model.diffusion_model."}):
|
|
|
|
return ModelType.Main
|
|
|
|
elif any(key.startswith(v) for v in {"encoder.conv_in", "decoder.conv_in"}):
|
|
|
|
return ModelType.Vae
|
|
|
|
elif any(key.startswith(v) for v in {"lora_te_", "lora_unet_"}):
|
|
|
|
return ModelType.Lora
|
2023-07-05 20:18:53 +00:00
|
|
|
elif any(key.endswith(v) for v in {"to_k_lora.up.weight", "to_q_lora.down.weight"}):
|
|
|
|
return ModelType.Lora
|
2023-06-24 16:37:26 +00:00
|
|
|
elif any(key.startswith(v) for v in {"control_model", "input_blocks"}):
|
|
|
|
return ModelType.ControlNet
|
|
|
|
elif key in {"emb_params", "string_to_param"}:
|
|
|
|
return ModelType.TextualInversion
|
|
|
|
|
|
|
|
else:
|
|
|
|
# diffusers-ti
|
2023-06-27 16:30:53 +00:00
|
|
|
if len(ckpt) < 10 and all(isinstance(v, torch.Tensor) for v in ckpt.values()):
|
2023-06-24 16:37:26 +00:00
|
|
|
return ModelType.TextualInversion
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-07-18 03:08:39 +00:00
|
|
|
raise InvalidModelException(f"Unable to determine model type for {model_path}")
|
2023-06-11 16:51:50 +00:00
|
|
|
|
|
|
|
@classmethod
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_model_type_from_folder(cls, folder_path: Path, model: ModelMixin) -> ModelType:
|
|
|
|
"""
|
2023-06-11 16:51:50 +00:00
|
|
|
Get the model type of a hugging-face style folder.
|
2023-07-28 13:46:44 +00:00
|
|
|
"""
|
2023-06-13 05:27:51 +00:00
|
|
|
class_name = None
|
2023-08-18 03:01:21 +00:00
|
|
|
error_hint = None
|
2023-06-11 23:51:53 +00:00
|
|
|
if model:
|
|
|
|
class_name = model.__class__.__name__
|
|
|
|
else:
|
2023-11-10 22:38:34 +00:00
|
|
|
for suffix in ["bin", "safetensors"]:
|
|
|
|
if (folder_path / f"learned_embeds.{suffix}").exists():
|
|
|
|
return ModelType.TextualInversion
|
|
|
|
if (folder_path / f"pytorch_lora_weights.{suffix}").exists():
|
|
|
|
return ModelType.Lora
|
2023-07-31 20:47:48 +00:00
|
|
|
if (folder_path / "unet/model.onnx").exists():
|
2023-07-28 20:54:03 +00:00
|
|
|
return ModelType.ONNX
|
2023-09-14 15:18:43 +00:00
|
|
|
if (folder_path / "image_encoder.txt").exists():
|
|
|
|
return ModelType.IPAdapter
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
i = folder_path / "model_index.json"
|
|
|
|
c = folder_path / "config.json"
|
2023-06-11 23:51:53 +00:00
|
|
|
config_path = i if i.exists() else c if c.exists() else None
|
|
|
|
|
|
|
|
if config_path:
|
2023-07-28 13:46:44 +00:00
|
|
|
with open(config_path, "r") as file:
|
2023-06-12 20:07:04 +00:00
|
|
|
conf = json.load(file)
|
2023-09-14 13:54:10 +00:00
|
|
|
if "_class_name" in conf:
|
|
|
|
class_name = conf["_class_name"]
|
|
|
|
elif "architectures" in conf:
|
|
|
|
class_name = conf["architectures"][0]
|
|
|
|
else:
|
|
|
|
class_name = None
|
2023-08-18 03:01:21 +00:00
|
|
|
else:
|
|
|
|
error_hint = f"No model_index.json or config.json found in {folder_path}."
|
2023-06-11 23:51:53 +00:00
|
|
|
|
2023-06-13 05:27:51 +00:00
|
|
|
if class_name and (type := cls.CLASS2TYPE.get(class_name)):
|
2023-06-11 23:51:53 +00:00
|
|
|
return type
|
2023-08-18 03:01:21 +00:00
|
|
|
else:
|
|
|
|
error_hint = f"class {class_name} is not one of the supported classes [{', '.join(cls.CLASS2TYPE.keys())}]"
|
2023-06-11 16:51:50 +00:00
|
|
|
|
|
|
|
# give up
|
2023-08-18 03:01:21 +00:00
|
|
|
raise InvalidModelException(
|
|
|
|
f"Unable to determine model type for {folder_path}" + (f"; {error_hint}" if error_hint else "")
|
|
|
|
)
|
2023-06-11 16:51:50 +00:00
|
|
|
|
|
|
|
@classmethod
|
2023-07-28 13:46:44 +00:00
|
|
|
def _scan_and_load_checkpoint(cls, model_path: Path) -> dict:
|
2023-06-11 23:51:53 +00:00
|
|
|
with SilenceWarnings():
|
|
|
|
if model_path.suffix.endswith((".ckpt", ".pt", ".bin")):
|
|
|
|
cls._scan_model(model_path, model_path)
|
2023-11-25 18:38:27 +00:00
|
|
|
return torch.load(model_path, map_location="cpu")
|
2023-06-11 23:51:53 +00:00
|
|
|
else:
|
|
|
|
return safetensors.torch.load_file(model_path)
|
2023-06-11 16:51:50 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _scan_model(cls, model_name, checkpoint):
|
2023-07-28 13:46:44 +00:00
|
|
|
"""
|
|
|
|
Apply picklescanner to the indicated checkpoint and issue a warning
|
|
|
|
and option to exit if an infected file is identified.
|
|
|
|
"""
|
|
|
|
# scan model
|
|
|
|
scan_result = scan_file_path(checkpoint)
|
|
|
|
if scan_result.infected_files != 0:
|
2023-11-10 23:51:21 +00:00
|
|
|
raise Exception("The model {model_name} is potentially infected by malware. Aborting import.")
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-08-17 22:45:25 +00:00
|
|
|
# ##################################################3
|
2023-06-11 16:51:50 +00:00
|
|
|
# Checkpoint probing
|
2023-08-17 22:45:25 +00:00
|
|
|
# ##################################################3
|
2023-06-11 16:51:50 +00:00
|
|
|
class ProbeBase(object):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-11 16:51:50 +00:00
|
|
|
pass
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_variant_type(self) -> ModelVariantType:
|
2023-06-11 16:51:50 +00:00
|
|
|
pass
|
2023-07-28 13:46:44 +00:00
|
|
|
|
|
|
|
def get_scheduler_prediction_type(self) -> SchedulerPredictionType:
|
2023-06-12 20:07:04 +00:00
|
|
|
pass
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_format(self) -> str:
|
2023-06-27 16:30:53 +00:00
|
|
|
pass
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class CheckpointProbeBase(ProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def __init__(
|
|
|
|
self, checkpoint_path: Path, checkpoint: dict, helper: Callable[[Path], SchedulerPredictionType] = None
|
|
|
|
) -> BaseModelType:
|
2023-06-11 16:51:50 +00:00
|
|
|
self.checkpoint = checkpoint or ModelProbe._scan_and_load_checkpoint(checkpoint_path)
|
|
|
|
self.checkpoint_path = checkpoint_path
|
|
|
|
self.helper = helper
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-11 16:51:50 +00:00
|
|
|
pass
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_format(self) -> str:
|
|
|
|
return "checkpoint"
|
2023-06-27 16:30:53 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_variant_type(self) -> ModelVariantType:
|
|
|
|
model_type = ModelProbe.get_model_type_from_checkpoint(self.checkpoint_path, self.checkpoint)
|
2023-06-24 15:45:49 +00:00
|
|
|
if model_type != ModelType.Main:
|
2023-06-12 20:07:04 +00:00
|
|
|
return ModelVariantType.Normal
|
2023-07-28 13:46:44 +00:00
|
|
|
state_dict = self.checkpoint.get("state_dict") or self.checkpoint
|
|
|
|
in_channels = state_dict["model.diffusion_model.input_blocks.0.0.weight"].shape[1]
|
2023-06-11 16:51:50 +00:00
|
|
|
if in_channels == 9:
|
2023-06-12 20:07:04 +00:00
|
|
|
return ModelVariantType.Inpaint
|
2023-06-11 16:51:50 +00:00
|
|
|
elif in_channels == 5:
|
2023-06-12 20:07:04 +00:00
|
|
|
return ModelVariantType.Depth
|
2023-06-13 05:27:51 +00:00
|
|
|
elif in_channels == 4:
|
|
|
|
return ModelVariantType.Normal
|
2023-06-11 16:51:50 +00:00
|
|
|
else:
|
2023-07-28 13:46:44 +00:00
|
|
|
raise InvalidModelException(
|
|
|
|
f"Cannot determine variant type (in_channels={in_channels}) at {self.checkpoint_path}"
|
|
|
|
)
|
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
|
|
|
|
class PipelineCheckpointProbe(CheckpointProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-11 16:51:50 +00:00
|
|
|
checkpoint = self.checkpoint
|
2023-07-28 13:46:44 +00:00
|
|
|
state_dict = self.checkpoint.get("state_dict") or checkpoint
|
2023-06-11 16:51:50 +00:00
|
|
|
key_name = "model.diffusion_model.input_blocks.2.1.transformer_blocks.0.attn2.to_k.weight"
|
|
|
|
if key_name in state_dict and state_dict[key_name].shape[-1] == 768:
|
2023-06-12 20:07:04 +00:00
|
|
|
return BaseModelType.StableDiffusion1
|
|
|
|
if key_name in state_dict and state_dict[key_name].shape[-1] == 1024:
|
|
|
|
return BaseModelType.StableDiffusion2
|
2023-07-28 13:46:44 +00:00
|
|
|
key_name = "model.diffusion_model.input_blocks.4.1.transformer_blocks.0.attn2.to_k.weight"
|
2023-07-09 19:47:06 +00:00
|
|
|
if key_name in state_dict and state_dict[key_name].shape[-1] == 2048:
|
|
|
|
return BaseModelType.StableDiffusionXL
|
2023-07-23 13:31:14 +00:00
|
|
|
elif key_name in state_dict and state_dict[key_name].shape[-1] == 1280:
|
|
|
|
return BaseModelType.StableDiffusionXLRefiner
|
|
|
|
else:
|
|
|
|
raise InvalidModelException("Cannot determine base type")
|
2023-06-12 20:07:04 +00:00
|
|
|
|
2023-09-24 16:22:29 +00:00
|
|
|
def get_scheduler_prediction_type(self) -> Optional[SchedulerPredictionType]:
|
|
|
|
"""Return model prediction type."""
|
|
|
|
# if there is a .yaml associated with this checkpoint, then we do not need
|
|
|
|
# to probe for the prediction type as it will be ignored.
|
|
|
|
if self.checkpoint_path and self.checkpoint_path.with_suffix(".yaml").exists():
|
|
|
|
return None
|
|
|
|
|
2023-06-12 20:07:04 +00:00
|
|
|
type = self.get_base_type()
|
2023-09-24 16:22:29 +00:00
|
|
|
if type == BaseModelType.StableDiffusion2:
|
|
|
|
checkpoint = self.checkpoint
|
|
|
|
state_dict = self.checkpoint.get("state_dict") or checkpoint
|
|
|
|
key_name = "model.diffusion_model.input_blocks.2.1.transformer_blocks.0.attn2.to_k.weight"
|
|
|
|
if key_name in state_dict and state_dict[key_name].shape[-1] == 1024:
|
|
|
|
if "global_step" in checkpoint:
|
|
|
|
if checkpoint["global_step"] == 220000:
|
|
|
|
return SchedulerPredictionType.Epsilon
|
|
|
|
elif checkpoint["global_step"] == 110000:
|
|
|
|
return SchedulerPredictionType.VPrediction
|
|
|
|
if self.helper and self.checkpoint_path:
|
|
|
|
if helper_guess := self.helper(self.checkpoint_path):
|
|
|
|
return helper_guess
|
|
|
|
return SchedulerPredictionType.VPrediction # a guess for sd2 ckpts
|
|
|
|
|
|
|
|
elif type == BaseModelType.StableDiffusion1:
|
|
|
|
if self.helper and self.checkpoint_path:
|
|
|
|
if helper_guess := self.helper(self.checkpoint_path):
|
|
|
|
return helper_guess
|
|
|
|
return SchedulerPredictionType.Epsilon # a reasonable guess for sd1 ckpts
|
|
|
|
else:
|
|
|
|
return None
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class VaeCheckpointProbe(CheckpointProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-11 16:51:50 +00:00
|
|
|
# I can't find any standalone 2.X VAEs to test with!
|
2023-06-12 20:07:04 +00:00
|
|
|
return BaseModelType.StableDiffusion1
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class LoRACheckpointProbe(CheckpointProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_format(self) -> str:
|
|
|
|
return "lycoris"
|
2023-06-27 16:30:53 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-11 16:51:50 +00:00
|
|
|
checkpoint = self.checkpoint
|
2023-08-07 20:19:57 +00:00
|
|
|
token_vector_length = lora_token_vector_length(checkpoint)
|
2023-08-03 14:26:52 +00:00
|
|
|
|
2023-08-07 20:19:57 +00:00
|
|
|
if token_vector_length == 768:
|
2023-06-12 20:07:04 +00:00
|
|
|
return BaseModelType.StableDiffusion1
|
2023-08-07 20:19:57 +00:00
|
|
|
elif token_vector_length == 1024:
|
2023-06-11 16:51:50 +00:00
|
|
|
return BaseModelType.StableDiffusion2
|
2024-01-08 22:18:26 +00:00
|
|
|
elif token_vector_length == 1280:
|
|
|
|
return BaseModelType.StableDiffusionXL # recognizes format at https://civitai.com/models/224641
|
2023-08-07 20:38:58 +00:00
|
|
|
elif token_vector_length == 2048:
|
2023-08-07 20:19:57 +00:00
|
|
|
return BaseModelType.StableDiffusionXL
|
2023-06-11 16:51:50 +00:00
|
|
|
else:
|
2023-08-07 20:38:58 +00:00
|
|
|
raise InvalidModelException(f"Unknown LoRA type: {self.checkpoint_path}")
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class TextualInversionCheckpointProbe(CheckpointProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_format(self) -> str:
|
2023-06-27 16:30:53 +00:00
|
|
|
return None
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-11 16:51:50 +00:00
|
|
|
checkpoint = self.checkpoint
|
2023-07-28 13:46:44 +00:00
|
|
|
if "string_to_token" in checkpoint:
|
|
|
|
token_dim = list(checkpoint["string_to_param"].values())[0].shape[-1]
|
|
|
|
elif "emb_params" in checkpoint:
|
|
|
|
token_dim = checkpoint["emb_params"].shape[-1]
|
2023-12-01 06:28:28 +00:00
|
|
|
elif "clip_g" in checkpoint:
|
|
|
|
token_dim = checkpoint["clip_g"].shape[-1]
|
2023-06-11 16:51:50 +00:00
|
|
|
else:
|
2023-12-15 22:56:49 +00:00
|
|
|
token_dim = list(checkpoint.values())[0].shape[-1]
|
2023-06-11 16:51:50 +00:00
|
|
|
if token_dim == 768:
|
2023-06-12 20:07:04 +00:00
|
|
|
return BaseModelType.StableDiffusion1
|
2023-06-11 16:51:50 +00:00
|
|
|
elif token_dim == 1024:
|
2023-06-12 20:07:04 +00:00
|
|
|
return BaseModelType.StableDiffusion2
|
2023-12-01 06:28:28 +00:00
|
|
|
elif token_dim == 1280:
|
|
|
|
return BaseModelType.StableDiffusionXL
|
2023-06-11 16:51:50 +00:00
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class ControlNetCheckpointProbe(CheckpointProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-11 16:51:50 +00:00
|
|
|
checkpoint = self.checkpoint
|
2023-07-28 13:46:44 +00:00
|
|
|
for key_name in (
|
|
|
|
"control_model.input_blocks.2.1.transformer_blocks.0.attn2.to_k.weight",
|
|
|
|
"input_blocks.2.1.transformer_blocks.0.attn2.to_k.weight",
|
|
|
|
):
|
2023-06-11 16:51:50 +00:00
|
|
|
if key_name not in checkpoint:
|
|
|
|
continue
|
|
|
|
if checkpoint[key_name].shape[-1] == 768:
|
2023-06-12 20:07:04 +00:00
|
|
|
return BaseModelType.StableDiffusion1
|
2023-06-13 05:27:51 +00:00
|
|
|
elif checkpoint[key_name].shape[-1] == 1024:
|
|
|
|
return BaseModelType.StableDiffusion2
|
2023-06-11 16:51:50 +00:00
|
|
|
elif self.checkpoint_path and self.helper:
|
|
|
|
return self.helper(self.checkpoint_path)
|
2023-07-18 03:08:39 +00:00
|
|
|
raise InvalidModelException("Unable to determine base type for {self.checkpoint_path}")
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-09-11 20:08:15 +00:00
|
|
|
class IPAdapterCheckpointProbe(CheckpointProbeBase):
|
|
|
|
def get_base_type(self) -> BaseModelType:
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
2023-09-13 21:14:20 +00:00
|
|
|
class CLIPVisionCheckpointProbe(CheckpointProbeBase):
|
|
|
|
def get_base_type(self) -> BaseModelType:
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
2023-10-05 05:29:16 +00:00
|
|
|
class T2IAdapterCheckpointProbe(CheckpointProbeBase):
|
|
|
|
def get_base_type(self) -> BaseModelType:
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
########################################################
|
|
|
|
# classes for probing folders
|
|
|
|
#######################################################
|
|
|
|
class FolderProbeBase(ProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def __init__(self, folder_path: Path, model: ModelMixin = None, helper: Callable = None): # not used
|
2023-06-11 16:51:50 +00:00
|
|
|
self.model = model
|
|
|
|
self.folder_path = folder_path
|
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_variant_type(self) -> ModelVariantType:
|
2023-06-12 20:07:04 +00:00
|
|
|
return ModelVariantType.Normal
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_format(self) -> str:
|
|
|
|
return "diffusers"
|
|
|
|
|
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class PipelineFolderProbe(FolderProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-11 23:51:53 +00:00
|
|
|
if self.model:
|
|
|
|
unet_conf = self.model.unet.config
|
2023-06-11 16:51:50 +00:00
|
|
|
else:
|
2023-07-28 13:46:44 +00:00
|
|
|
with open(self.folder_path / "unet" / "config.json", "r") as file:
|
2023-06-12 20:07:04 +00:00
|
|
|
unet_conf = json.load(file)
|
2023-07-28 13:46:44 +00:00
|
|
|
if unet_conf["cross_attention_dim"] == 768:
|
|
|
|
return BaseModelType.StableDiffusion1
|
|
|
|
elif unet_conf["cross_attention_dim"] == 1024:
|
2023-06-12 20:07:04 +00:00
|
|
|
return BaseModelType.StableDiffusion2
|
2023-07-28 13:46:44 +00:00
|
|
|
elif unet_conf["cross_attention_dim"] == 1280:
|
2023-07-10 00:42:03 +00:00
|
|
|
return BaseModelType.StableDiffusionXLRefiner
|
2023-07-28 13:46:44 +00:00
|
|
|
elif unet_conf["cross_attention_dim"] == 2048:
|
2023-07-09 19:47:06 +00:00
|
|
|
return BaseModelType.StableDiffusionXL
|
2023-06-11 23:51:53 +00:00
|
|
|
else:
|
2023-07-28 13:46:44 +00:00
|
|
|
raise InvalidModelException(f"Unknown base model for {self.folder_path}")
|
2023-06-12 20:07:04 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_scheduler_prediction_type(self) -> SchedulerPredictionType:
|
2023-06-12 20:07:04 +00:00
|
|
|
if self.model:
|
|
|
|
scheduler_conf = self.model.scheduler.config
|
|
|
|
else:
|
2023-07-28 13:46:44 +00:00
|
|
|
with open(self.folder_path / "scheduler" / "scheduler_config.json", "r") as file:
|
2023-06-12 20:07:04 +00:00
|
|
|
scheduler_conf = json.load(file)
|
2023-07-28 13:46:44 +00:00
|
|
|
if scheduler_conf["prediction_type"] == "v_prediction":
|
2023-06-12 20:07:04 +00:00
|
|
|
return SchedulerPredictionType.VPrediction
|
2023-07-28 13:46:44 +00:00
|
|
|
elif scheduler_conf["prediction_type"] == "epsilon":
|
2023-06-12 20:07:04 +00:00
|
|
|
return SchedulerPredictionType.Epsilon
|
|
|
|
else:
|
|
|
|
return None
|
2023-07-28 13:46:44 +00:00
|
|
|
|
|
|
|
def get_variant_type(self) -> ModelVariantType:
|
2023-06-11 23:51:53 +00:00
|
|
|
# This only works for pipelines! Any kind of
|
|
|
|
# exception results in our returning the
|
|
|
|
# "normal" variant type
|
|
|
|
try:
|
|
|
|
if self.model:
|
|
|
|
conf = self.model.unet.config
|
|
|
|
else:
|
2023-07-28 13:46:44 +00:00
|
|
|
config_file = self.folder_path / "unet" / "config.json"
|
|
|
|
with open(config_file, "r") as file:
|
2023-06-12 20:07:04 +00:00
|
|
|
conf = json.load(file)
|
2023-07-28 13:46:44 +00:00
|
|
|
|
|
|
|
in_channels = conf["in_channels"]
|
2023-06-11 23:51:53 +00:00
|
|
|
if in_channels == 9:
|
2023-07-20 00:57:14 +00:00
|
|
|
return ModelVariantType.Inpaint
|
2023-06-11 23:51:53 +00:00
|
|
|
elif in_channels == 5:
|
2023-06-12 20:07:04 +00:00
|
|
|
return ModelVariantType.Depth
|
2023-06-11 23:51:53 +00:00
|
|
|
elif in_channels == 4:
|
2023-06-12 20:07:04 +00:00
|
|
|
return ModelVariantType.Normal
|
2023-08-17 22:45:25 +00:00
|
|
|
except Exception:
|
2023-06-11 23:51:53 +00:00
|
|
|
pass
|
2023-06-12 20:07:04 +00:00
|
|
|
return ModelVariantType.Normal
|
2023-06-11 23:51:53 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class VaeFolderProbe(FolderProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-09-20 19:03:15 +00:00
|
|
|
if self._config_looks_like_sdxl():
|
|
|
|
return BaseModelType.StableDiffusionXL
|
|
|
|
elif self._name_looks_like_sdxl():
|
|
|
|
# but SD and SDXL VAE are the same shape (3-channel RGB to 4-channel float scaled down
|
2023-09-20 19:07:12 +00:00
|
|
|
# by a factor of 8), we can't necessarily tell them apart by config hyperparameters.
|
2023-09-20 19:03:15 +00:00
|
|
|
return BaseModelType.StableDiffusionXL
|
|
|
|
else:
|
|
|
|
return BaseModelType.StableDiffusion1
|
|
|
|
|
|
|
|
def _config_looks_like_sdxl(self) -> bool:
|
|
|
|
# config values that distinguish Stability's SD 1.x VAE from their SDXL VAE.
|
2023-07-28 13:46:44 +00:00
|
|
|
config_file = self.folder_path / "config.json"
|
2023-07-27 03:06:27 +00:00
|
|
|
if not config_file.exists():
|
|
|
|
raise InvalidModelException(f"Cannot determine base type for {self.folder_path}")
|
2023-07-28 13:46:44 +00:00
|
|
|
with open(config_file, "r") as file:
|
2023-07-27 03:06:27 +00:00
|
|
|
config = json.load(file)
|
2023-09-20 19:03:15 +00:00
|
|
|
return config.get("scaling_factor", 0) == 0.13025 and config.get("sample_size") in [512, 1024]
|
|
|
|
|
|
|
|
def _name_looks_like_sdxl(self) -> bool:
|
|
|
|
return bool(re.search(r"xl\b", self._guess_name(), re.IGNORECASE))
|
|
|
|
|
|
|
|
def _guess_name(self) -> str:
|
|
|
|
name = self.folder_path.name
|
|
|
|
if name == "vae":
|
|
|
|
name = self.folder_path.parent.name
|
|
|
|
return name
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
|
|
|
|
class TextualInversionFolderProbe(FolderProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_format(self) -> str:
|
2023-06-27 16:30:53 +00:00
|
|
|
return None
|
2023-07-28 13:46:44 +00:00
|
|
|
|
|
|
|
def get_base_type(self) -> BaseModelType:
|
|
|
|
path = self.folder_path / "learned_embeds.bin"
|
2023-06-11 16:51:50 +00:00
|
|
|
if not path.exists():
|
|
|
|
return None
|
|
|
|
checkpoint = ModelProbe._scan_and_load_checkpoint(path)
|
2023-07-28 13:46:44 +00:00
|
|
|
return TextualInversionCheckpointProbe(None, checkpoint=checkpoint).get_base_type()
|
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-07-28 20:54:03 +00:00
|
|
|
class ONNXFolderProbe(FolderProbeBase):
|
|
|
|
def get_format(self) -> str:
|
|
|
|
return "onnx"
|
|
|
|
|
|
|
|
def get_base_type(self) -> BaseModelType:
|
|
|
|
return BaseModelType.StableDiffusion1
|
|
|
|
|
|
|
|
def get_variant_type(self) -> ModelVariantType:
|
|
|
|
return ModelVariantType.Normal
|
|
|
|
|
2023-07-31 20:47:48 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
class ControlNetFolderProbe(FolderProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
|
|
|
config_file = self.folder_path / "config.json"
|
2023-06-11 16:51:50 +00:00
|
|
|
if not config_file.exists():
|
2023-07-18 03:08:39 +00:00
|
|
|
raise InvalidModelException(f"Cannot determine base type for {self.folder_path}")
|
2023-07-28 13:46:44 +00:00
|
|
|
with open(config_file, "r") as file:
|
2023-06-13 05:27:51 +00:00
|
|
|
config = json.load(file)
|
2023-06-11 16:51:50 +00:00
|
|
|
# no obvious way to distinguish between sd2-base and sd2-768
|
2023-08-15 15:46:37 +00:00
|
|
|
dimension = config["cross_attention_dim"]
|
|
|
|
base_model = (
|
|
|
|
BaseModelType.StableDiffusion1
|
|
|
|
if dimension == 768
|
2023-09-11 20:08:15 +00:00
|
|
|
else (
|
|
|
|
BaseModelType.StableDiffusion2
|
|
|
|
if dimension == 1024
|
2023-09-15 03:49:02 +00:00
|
|
|
else BaseModelType.StableDiffusionXL
|
|
|
|
if dimension == 2048
|
|
|
|
else None
|
2023-09-11 20:08:15 +00:00
|
|
|
)
|
2023-07-28 13:46:44 +00:00
|
|
|
)
|
2023-08-15 15:46:37 +00:00
|
|
|
if not base_model:
|
|
|
|
raise InvalidModelException(f"Unable to determine model base for {self.folder_path}")
|
|
|
|
return base_model
|
2023-07-28 13:46:44 +00:00
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
|
|
|
|
class LoRAFolderProbe(FolderProbeBase):
|
2023-07-28 13:46:44 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-06-20 15:08:27 +00:00
|
|
|
model_file = None
|
2023-07-28 13:46:44 +00:00
|
|
|
for suffix in ["safetensors", "bin"]:
|
|
|
|
base_file = self.folder_path / f"pytorch_lora_weights.{suffix}"
|
2023-06-20 15:08:27 +00:00
|
|
|
if base_file.exists():
|
|
|
|
model_file = base_file
|
|
|
|
break
|
|
|
|
if not model_file:
|
2023-07-28 13:46:44 +00:00
|
|
|
raise InvalidModelException("Unknown LoRA format encountered")
|
|
|
|
return LoRACheckpointProbe(model_file, None).get_base_type()
|
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
|
2023-09-11 20:08:15 +00:00
|
|
|
class IPAdapterFolderProbe(FolderProbeBase):
|
2023-09-14 15:18:43 +00:00
|
|
|
def get_format(self) -> str:
|
|
|
|
return IPAdapterModelFormat.InvokeAI.value
|
|
|
|
|
2023-09-11 20:08:15 +00:00
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-09-14 15:18:43 +00:00
|
|
|
model_file = self.folder_path / "ip_adapter.bin"
|
|
|
|
if not model_file.exists():
|
|
|
|
raise InvalidModelException("Unknown IP-Adapter model format.")
|
|
|
|
|
2023-09-15 03:06:57 +00:00
|
|
|
state_dict = torch.load(model_file, map_location="cpu")
|
2023-09-14 15:18:43 +00:00
|
|
|
cross_attention_dim = state_dict["ip_adapter"]["1.to_k_ip.weight"].shape[-1]
|
|
|
|
if cross_attention_dim == 768:
|
|
|
|
return BaseModelType.StableDiffusion1
|
|
|
|
elif cross_attention_dim == 1024:
|
|
|
|
return BaseModelType.StableDiffusion2
|
|
|
|
elif cross_attention_dim == 2048:
|
|
|
|
return BaseModelType.StableDiffusionXL
|
|
|
|
else:
|
|
|
|
raise InvalidModelException(f"IP-Adapter had unexpected cross-attention dimension: {cross_attention_dim}.")
|
2023-09-11 20:08:15 +00:00
|
|
|
|
|
|
|
|
2023-09-13 21:14:20 +00:00
|
|
|
class CLIPVisionFolderProbe(FolderProbeBase):
|
|
|
|
def get_base_type(self) -> BaseModelType:
|
2023-09-14 12:19:55 +00:00
|
|
|
return BaseModelType.Any
|
2023-09-13 21:14:20 +00:00
|
|
|
|
|
|
|
|
2023-10-05 05:29:16 +00:00
|
|
|
class T2IAdapterFolderProbe(FolderProbeBase):
|
|
|
|
def get_base_type(self) -> BaseModelType:
|
|
|
|
config_file = self.folder_path / "config.json"
|
|
|
|
if not config_file.exists():
|
|
|
|
raise InvalidModelException(f"Cannot determine base type for {self.folder_path}")
|
|
|
|
with open(config_file, "r") as file:
|
|
|
|
config = json.load(file)
|
|
|
|
|
|
|
|
adapter_type = config.get("adapter_type", None)
|
|
|
|
if adapter_type == "full_adapter_xl":
|
|
|
|
return BaseModelType.StableDiffusionXL
|
|
|
|
elif adapter_type == "full_adapter" or "light_adapter":
|
|
|
|
# I haven't seen any T2I adapter models for SD2, so assume that this is an SD1 adapter.
|
|
|
|
return BaseModelType.StableDiffusion1
|
|
|
|
else:
|
|
|
|
raise InvalidModelException(
|
|
|
|
f"Unable to determine base model for '{self.folder_path}' (adapter_type = {adapter_type})."
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-06-11 16:51:50 +00:00
|
|
|
############## register probe classes ######
|
2023-07-28 13:46:44 +00:00
|
|
|
ModelProbe.register_probe("diffusers", ModelType.Main, PipelineFolderProbe)
|
|
|
|
ModelProbe.register_probe("diffusers", ModelType.Vae, VaeFolderProbe)
|
|
|
|
ModelProbe.register_probe("diffusers", ModelType.Lora, LoRAFolderProbe)
|
|
|
|
ModelProbe.register_probe("diffusers", ModelType.TextualInversion, TextualInversionFolderProbe)
|
|
|
|
ModelProbe.register_probe("diffusers", ModelType.ControlNet, ControlNetFolderProbe)
|
2023-09-11 20:08:15 +00:00
|
|
|
ModelProbe.register_probe("diffusers", ModelType.IPAdapter, IPAdapterFolderProbe)
|
2023-09-13 21:14:20 +00:00
|
|
|
ModelProbe.register_probe("diffusers", ModelType.CLIPVision, CLIPVisionFolderProbe)
|
2023-10-05 05:29:16 +00:00
|
|
|
ModelProbe.register_probe("diffusers", ModelType.T2IAdapter, T2IAdapterFolderProbe)
|
2023-09-11 20:08:15 +00:00
|
|
|
|
2023-07-28 13:46:44 +00:00
|
|
|
ModelProbe.register_probe("checkpoint", ModelType.Main, PipelineCheckpointProbe)
|
|
|
|
ModelProbe.register_probe("checkpoint", ModelType.Vae, VaeCheckpointProbe)
|
|
|
|
ModelProbe.register_probe("checkpoint", ModelType.Lora, LoRACheckpointProbe)
|
|
|
|
ModelProbe.register_probe("checkpoint", ModelType.TextualInversion, TextualInversionCheckpointProbe)
|
|
|
|
ModelProbe.register_probe("checkpoint", ModelType.ControlNet, ControlNetCheckpointProbe)
|
2023-09-11 20:08:15 +00:00
|
|
|
ModelProbe.register_probe("checkpoint", ModelType.IPAdapter, IPAdapterCheckpointProbe)
|
2023-09-13 21:14:20 +00:00
|
|
|
ModelProbe.register_probe("checkpoint", ModelType.CLIPVision, CLIPVisionCheckpointProbe)
|
2023-10-05 05:29:16 +00:00
|
|
|
ModelProbe.register_probe("checkpoint", ModelType.T2IAdapter, T2IAdapterCheckpointProbe)
|
2023-09-11 20:08:15 +00:00
|
|
|
|
2023-07-28 20:54:03 +00:00
|
|
|
ModelProbe.register_probe("onnx", ModelType.ONNX, ONNXFolderProbe)
|