diff --git a/invokeai/app/services/config/config_default.py b/invokeai/app/services/config/config_default.py index 64d464002b..b942563804 100644 --- a/invokeai/app/services/config/config_default.py +++ b/invokeai/app/services/config/config_default.py @@ -256,6 +256,7 @@ class InvokeAIAppConfig(InvokeAISettings): profile_graphs : bool = Field(default=False, description="Enable graph profiling", json_schema_extra=Categories.Development) profile_prefix : Optional[str] = Field(default=None, description="An optional prefix for profile output files.", json_schema_extra=Categories.Development) profiles_dir : Path = Field(default=Path('profiles'), description="Directory for graph profiles", json_schema_extra=Categories.Development) + skip_model_hash : bool = Field(default=False, description="Skip model hashing, instead assigning a UUID to models. Useful when using a memory db to reduce startup time.", json_schema_extra=Categories.Development) version : bool = Field(default=False, description="Show InvokeAI version and exit", json_schema_extra=Categories.Other) diff --git a/invokeai/app/services/model_install/model_install_default.py b/invokeai/app/services/model_install/model_install_default.py index e7afa37b84..670da572d2 100644 --- a/invokeai/app/services/model_install/model_install_default.py +++ b/invokeai/app/services/model_install/model_install_default.py @@ -154,6 +154,9 @@ class ModelInstallService(ModelInstallServiceBase): model_path = Path(model_path) config = config or {} + if self._app_config.skip_model_hash: + config["hash"] = uuid_string() + info: AnyModelConfig = ModelProbe.probe(Path(model_path), config) if preferred_name := config.get("name"): @@ -528,15 +531,12 @@ class ModelInstallService(ModelInstallServiceBase): def _register( self, model_path: Path, config: Optional[Dict[str, Any]] = None, info: Optional[AnyModelConfig] = None ) -> str: - # Note that we may be passed a pre-populated AnyModelConfig object, - # in which case the key field should have been populated by the caller (e.g. in `install_path`). - if config is not None: - config["key"] = config.get("key", uuid_string()) - info = info or ModelProbe.probe(model_path, config) - override_key: Optional[str] = config.get("key") if config else None + config = config or {} - assert info.hash # always assigned by probe() - info.key = override_key or info.hash + if self._app_config.skip_model_hash: + config["hash"] = uuid_string() + + info = info or ModelProbe.probe(model_path, config) model_path = model_path.absolute() if model_path.is_relative_to(self.app_config.models_path):