Skip to content

Commit d2149a8

Browse files
authored
Fix gratuitous, parasitic, endlessly repeated, pointless menu in version 3.2.0 (invoke-ai#4864)
## What type of PR is this? (check all applicable) - [ ] Refactor - [ ] Feature - [X] Bug Fix - [ ] Optimization - [ ] Documentation Update - [ ] Community Node Submission ## Have you discussed this change with the InvokeAI team? - [X] Yes - [ ] No, because: ## Have you updated all relevant documentation? - [X] Yes - [ ] No ## Description A regression in 3.2.0 causes a seemingly nonsensical multiple choice menu to appear when importing an SD-1 checkpoint model from the autoimport directory. The menu asks the user to identify which type of SD-2 model they are trying to import, which makes no sense. In fact, the menu is popping up because there are now both "epsilon" and "vprediction" SchedulerPredictionTypes for SD-1 as well as SD-2 models, and the prober can't determine which prediction type to use. This PR does two things: 1) rewords the menu as shown below 2) defaults to the most likely choice -- epsilon for v1 models and vprediction for v2s Here is the revised multiple-choice menu: ``` Please select the scheduler prediction type of the checkpoint named v1-5-pruned-emaonly.safetensors: [1] "epsilon" - most v1.5 models and v2 models trained on 512 pixel images [2] "vprediction" - v2 models trained on 768 pixel images and a few v1.5 models [3] Accept the best guess; you can fix it in the Web UI later select [3]> ``` Note that one can also put the appropriate config file into the same directory as the checkpoint you wish to import. Give it the same name as the model file, but with the extension `.yaml`. For example `v1-5-pruned-emaonly.yaml`. The system will notice the yaml file and use that, suppressing the quiz entirely. ## Related Tickets & Documents - Closes invoke-ai#4768 - Closes invoke-ai#4827
2 parents 89db8c8 + 6532d9f commit d2149a8

2 files changed

Lines changed: 27 additions & 28 deletions

File tree

invokeai/frontend/install/model_install.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from multiprocessing.connection import Connection, Pipe
2121
from pathlib import Path
2222
from shutil import get_terminal_size
23+
from typing import Optional
2324

2425
import npyscreen
2526
import torch
@@ -630,21 +631,23 @@ def ask_user_for_prediction_type(model_path: Path, tui_conn: Connection = None)
630631
return _ask_user_for_pt_cmdline(model_path)
631632

632633

633-
def _ask_user_for_pt_cmdline(model_path: Path) -> SchedulerPredictionType:
634+
def _ask_user_for_pt_cmdline(model_path: Path) -> Optional[SchedulerPredictionType]:
634635
choices = [SchedulerPredictionType.Epsilon, SchedulerPredictionType.VPrediction, None]
635636
print(
636637
f"""
637-
Please select the type of the V2 checkpoint named {model_path.name}:
638-
[1] A model based on Stable Diffusion v2 trained on 512 pixel images (SD-2-base)
639-
[2] A model based on Stable Diffusion v2 trained on 768 pixel images (SD-2-768)
640-
[3] Skip this model and come back later.
638+
Please select the scheduler prediction type of the checkpoint named {model_path.name}:
639+
[1] "epsilon" - most v1.5 models and v2 models trained on 512 pixel images
640+
[2] "vprediction" - v2 models trained on 768 pixel images and a few v1.5 models
641+
[3] Accept the best guess; you can fix it in the Web UI later
641642
"""
642643
)
643644
choice = None
644645
ok = False
645646
while not ok:
646647
try:
647-
choice = input("select> ").strip()
648+
choice = input("select [3]> ").strip()
649+
if not choice:
650+
return None
648651
choice = choices[int(choice) - 1]
649652
ok = True
650653
except (ValueError, IndexError):
@@ -655,22 +658,18 @@ def _ask_user_for_pt_cmdline(model_path: Path) -> SchedulerPredictionType:
655658

656659

657660
def _ask_user_for_pt_tui(model_path: Path, tui_conn: Connection) -> SchedulerPredictionType:
658-
try:
659-
tui_conn.send_bytes(f"*need v2 config for:{model_path}".encode("utf-8"))
660-
# note that we don't do any status checking here
661-
response = tui_conn.recv_bytes().decode("utf-8")
662-
if response is None:
663-
return None
664-
elif response == "epsilon":
665-
return SchedulerPredictionType.epsilon
666-
elif response == "v":
667-
return SchedulerPredictionType.VPrediction
668-
elif response == "abort":
669-
logger.info("Conversion aborted")
670-
return None
671-
else:
672-
return response
673-
except Exception:
661+
tui_conn.send_bytes(f"*need v2 config for:{model_path}".encode("utf-8"))
662+
# note that we don't do any status checking here
663+
response = tui_conn.recv_bytes().decode("utf-8")
664+
if response is None:
665+
return None
666+
elif response == "epsilon":
667+
return SchedulerPredictionType.epsilon
668+
elif response == "v":
669+
return SchedulerPredictionType.VPrediction
670+
elif response == "guess":
671+
return None
672+
else:
674673
return None
675674

676675

invokeai/frontend/install/widgets.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,12 @@ def select_stable_diffusion_config_file(
381381
wrap: bool = True,
382382
model_name: str = "Unknown",
383383
):
384-
message = f"Please select the correct base model for the V2 checkpoint named '{model_name}'. Press <CANCEL> to skip installation."
384+
message = f"Please select the correct prediction type for the checkpoint named '{model_name}'. Press <CANCEL> to skip installation."
385385
title = "CONFIG FILE SELECTION"
386386
options = [
387-
"An SD v2.x base model (512 pixels; no 'parameterization:' line in its yaml file)",
388-
"An SD v2.x v-predictive model (768 pixels; 'parameterization: \"v\"' line in its yaml file)",
389-
"Skip installation for now and come back later",
387+
"'epsilon' - most v1.5 models and v2 models trained on 512 pixel images",
388+
"'vprediction' - v2 models trained on 768 pixel images and a few v1.5 models)",
389+
"Accept the best guess; you can fix it in the Web UI later",
390390
]
391391

392392
F = ConfirmCancelPopup(
@@ -410,7 +410,7 @@ def select_stable_diffusion_config_file(
410410
choice = F.add(
411411
npyscreen.SelectOne,
412412
values=options,
413-
value=[0],
413+
value=[2],
414414
max_height=len(options) + 1,
415415
scroll_exit=True,
416416
)
@@ -420,5 +420,5 @@ def select_stable_diffusion_config_file(
420420
if not F.value:
421421
return None
422422
assert choice.value[0] in range(0, 3), "invalid choice"
423-
choices = ["epsilon", "v", "abort"]
423+
choices = ["epsilon", "v", "guess"]
424424
return choices[choice.value[0]]

0 commit comments

Comments
 (0)