mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
test and fix edge cases
This commit is contained in:
parent
ddb3f4b02b
commit
294b1e83e6
@ -442,46 +442,46 @@ to allow InvokeAI to download restricted styles & subjects from the "Concept Lib
|
||||
begin_entry_at=4,
|
||||
scroll_exit=True,
|
||||
)
|
||||
self.nextrely += 1
|
||||
self.add_widget_intelligent(
|
||||
npyscreen.FixedText,
|
||||
value="Directories containing textual inversion, controlnet and LoRA models (<tab> autocompletes, ctrl-N advances):",
|
||||
editable=False,
|
||||
color="CONTROL",
|
||||
)
|
||||
self.embedding_dir = self.add_widget_intelligent(
|
||||
npyscreen.TitleFilename,
|
||||
name=" Textual Inversion Embeddings:",
|
||||
value=str(default_embedding_dir()),
|
||||
select_dir=True,
|
||||
must_exist=False,
|
||||
use_two_lines=False,
|
||||
labelColor="GOOD",
|
||||
begin_entry_at=32,
|
||||
scroll_exit=True,
|
||||
)
|
||||
self.lora_dir = self.add_widget_intelligent(
|
||||
npyscreen.TitleFilename,
|
||||
name=" LoRA and LyCORIS:",
|
||||
value=str(default_lora_dir()),
|
||||
select_dir=True,
|
||||
must_exist=False,
|
||||
use_two_lines=False,
|
||||
labelColor="GOOD",
|
||||
begin_entry_at=32,
|
||||
scroll_exit=True,
|
||||
)
|
||||
self.controlnet_dir = self.add_widget_intelligent(
|
||||
npyscreen.TitleFilename,
|
||||
name=" ControlNets:",
|
||||
value=str(default_controlnet_dir()),
|
||||
select_dir=True,
|
||||
must_exist=False,
|
||||
use_two_lines=False,
|
||||
labelColor="GOOD",
|
||||
begin_entry_at=32,
|
||||
scroll_exit=True,
|
||||
)
|
||||
# self.nextrely += 1
|
||||
# self.add_widget_intelligent(
|
||||
# npyscreen.FixedText,
|
||||
# value="Directories containing textual inversion, controlnet and LoRA models (<tab> autocompletes, ctrl-N advances):",
|
||||
# editable=False,
|
||||
# color="CONTROL",
|
||||
# )
|
||||
# self.embedding_dir = self.add_widget_intelligent(
|
||||
# npyscreen.TitleFilename,
|
||||
# name=" Textual Inversion Embeddings:",
|
||||
# value=str(default_embedding_dir()),
|
||||
# select_dir=True,
|
||||
# must_exist=False,
|
||||
# use_two_lines=False,
|
||||
# labelColor="GOOD",
|
||||
# begin_entry_at=32,
|
||||
# scroll_exit=True,
|
||||
# )
|
||||
# self.lora_dir = self.add_widget_intelligent(
|
||||
# npyscreen.TitleFilename,
|
||||
# name=" LoRA and LyCORIS:",
|
||||
# value=str(default_lora_dir()),
|
||||
# select_dir=True,
|
||||
# must_exist=False,
|
||||
# use_two_lines=False,
|
||||
# labelColor="GOOD",
|
||||
# begin_entry_at=32,
|
||||
# scroll_exit=True,
|
||||
# )
|
||||
# self.controlnet_dir = self.add_widget_intelligent(
|
||||
# npyscreen.TitleFilename,
|
||||
# name=" ControlNets:",
|
||||
# value=str(default_controlnet_dir()),
|
||||
# select_dir=True,
|
||||
# must_exist=False,
|
||||
# use_two_lines=False,
|
||||
# labelColor="GOOD",
|
||||
# begin_entry_at=32,
|
||||
# scroll_exit=True,
|
||||
# )
|
||||
self.nextrely += 1
|
||||
self.add_widget_intelligent(
|
||||
npyscreen.TitleFixedText,
|
||||
@ -546,10 +546,10 @@ https://huggingface.co/spaces/CompVis/stable-diffusion-license
|
||||
bad_fields.append(
|
||||
f"The output directory does not seem to be valid. Please check that {str(Path(opt.outdir).parent)} is an existing directory."
|
||||
)
|
||||
if not Path(opt.embedding_dir).parent.exists():
|
||||
bad_fields.append(
|
||||
f"The embedding directory does not seem to be valid. Please check that {str(Path(opt.embedding_dir).parent)} is an existing directory."
|
||||
)
|
||||
# if not Path(opt.embedding_dir).parent.exists():
|
||||
# bad_fields.append(
|
||||
# f"The embedding directory does not seem to be valid. Please check that {str(Path(opt.embedding_dir).parent)} is an existing directory."
|
||||
# )
|
||||
if len(bad_fields) > 0:
|
||||
message = "The following problems were detected and must be corrected:\n"
|
||||
for problem in bad_fields:
|
||||
@ -569,9 +569,9 @@ https://huggingface.co/spaces/CompVis/stable-diffusion-license
|
||||
"max_loaded_models",
|
||||
"xformers_enabled",
|
||||
"always_use_cpu",
|
||||
"embedding_dir",
|
||||
"lora_dir",
|
||||
"controlnet_dir",
|
||||
# "embedding_dir",
|
||||
# "lora_dir",
|
||||
# "controlnet_dir",
|
||||
]:
|
||||
setattr(new_opts, attr, getattr(self, attr).value)
|
||||
|
||||
@ -591,6 +591,7 @@ class EditOptApplication(npyscreen.NPSAppManaged):
|
||||
self.program_opts = program_opts
|
||||
self.invokeai_opts = invokeai_opts
|
||||
self.user_cancelled = False
|
||||
self.autoload_pending = True
|
||||
self.install_selections = default_user_selections(program_opts)
|
||||
|
||||
def onStart(self):
|
||||
@ -719,17 +720,17 @@ def write_opts(opts: Namespace, init_file: Path):
|
||||
def default_output_dir() -> Path:
|
||||
return config.root_path / "outputs"
|
||||
|
||||
# -------------------------------------
|
||||
def default_embedding_dir() -> Path:
|
||||
return config.root_path / "embeddings"
|
||||
# # -------------------------------------
|
||||
# def default_embedding_dir() -> Path:
|
||||
# return config.root_path / "embeddings"
|
||||
|
||||
# -------------------------------------
|
||||
def default_lora_dir() -> Path:
|
||||
return config.root_path / "loras"
|
||||
# # -------------------------------------
|
||||
# def default_lora_dir() -> Path:
|
||||
# return config.root_path / "loras"
|
||||
|
||||
# -------------------------------------
|
||||
def default_controlnet_dir() -> Path:
|
||||
return config.root_path / "controlnets"
|
||||
# # -------------------------------------
|
||||
# def default_controlnet_dir() -> Path:
|
||||
# return config.root_path / "controlnets"
|
||||
|
||||
# -------------------------------------
|
||||
def write_default_options(program_opts: Namespace, initfile: Path):
|
||||
@ -755,7 +756,7 @@ def migrate_init_file(legacy_format:Path):
|
||||
new.nsfw_checker = old.safety_checker
|
||||
new.xformers_enabled = old.xformers
|
||||
new.conf_path = old.conf
|
||||
new.embedding_dir = old.embedding_path
|
||||
# new.embedding_dir = old.embedding_path
|
||||
|
||||
invokeai_yaml = legacy_format.parent / 'invokeai.yaml'
|
||||
with open(invokeai_yaml,"w", encoding="utf-8") as outfile:
|
||||
|
@ -227,10 +227,14 @@ class ModelInstall(object):
|
||||
# the model from being probed twice in the event that it has already been probed.
|
||||
def _install_path(self, path: Path, info: ModelProbeInfo=None):
|
||||
try:
|
||||
logger.info(f'Probing {path}')
|
||||
info = info or ModelProbe().heuristic_probe(path,self.prediction_helper)
|
||||
if info.model_type == ModelType.Pipeline:
|
||||
model_name = path.stem if info.format=='checkpoint' else path.name
|
||||
if self.mgr.model_exists(model_name, info.base_type, info.model_type):
|
||||
raise Exception(f'A model named "{model_name}" is already installed.')
|
||||
attributes = self._make_attributes(path,info)
|
||||
self.mgr.add_model(model_name = path.stem if info.format=='checkpoint' else path.name,
|
||||
self.mgr.add_model(model_name = model_name,
|
||||
base_model = info.base_type,
|
||||
model_type = info.model_type,
|
||||
model_attributes = attributes
|
||||
@ -322,7 +326,7 @@ class ModelInstall(object):
|
||||
)
|
||||
if info.format=="checkpoint":
|
||||
try:
|
||||
legacy_conf = LEGACY_CONFIGS[info.base_type][info.variant_type][info.prediction_type] if BaseModelType.StableDiffusion2 \
|
||||
legacy_conf = LEGACY_CONFIGS[info.base_type][info.variant_type][info.prediction_type] if info.base_type == BaseModelType.StableDiffusion2 \
|
||||
else LEGACY_CONFIGS[info.base_type][info.variant_type]
|
||||
except KeyError:
|
||||
legacy_conf = 'v1-inference.yaml' # best guess
|
||||
|
@ -131,6 +131,7 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage):
|
||||
window_width=window_width,
|
||||
exclude = self.starter_models
|
||||
)
|
||||
self.pipeline_models['autoload_pending'] = True
|
||||
bottom_of_table = max(bottom_of_table,self.nextrely)
|
||||
|
||||
self.nextrely = top_of_table
|
||||
@ -545,7 +546,9 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage):
|
||||
selections.install_models.extend(downloads.value.split())
|
||||
|
||||
# load directory and whether to scan on startup
|
||||
selections.scan_directory = self.pipeline_models['autoload_directory'].value
|
||||
if self.parentApp.autoload_pending:
|
||||
selections.scan_directory = self.pipeline_models['autoload_directory'].value
|
||||
self.parentApp.autoload_pending = False
|
||||
selections.autoscan_on_startup = self.pipeline_models['autoscan_on_startup'].value
|
||||
|
||||
class AddModelApplication(npyscreen.NPSAppManaged):
|
||||
@ -553,6 +556,7 @@ class AddModelApplication(npyscreen.NPSAppManaged):
|
||||
super().__init__()
|
||||
self.program_opts = opt
|
||||
self.user_cancelled = False
|
||||
self.autoload_pending = True
|
||||
self.install_selections = InstallSelections()
|
||||
|
||||
def onStart(self):
|
||||
|
@ -378,7 +378,7 @@ def select_stable_diffusion_config_file(
|
||||
wrap:bool =True,
|
||||
model_name:str='Unknown',
|
||||
):
|
||||
message = "Please select the correct base model for the V2 checkpoint named {model_name}. Press <CANCEL> to skip installation."
|
||||
message = f"Please select the correct base model for the V2 checkpoint named '{model_name}'. Press <CANCEL> to skip installation."
|
||||
title = "CONFIG FILE SELECTION"
|
||||
options=[
|
||||
"An SD v2.x base model (512 pixels; no 'parameterization:' line in its yaml file)",
|
||||
|
Loading…
Reference in New Issue
Block a user