From 77b7680b322cc52e8da9cd0cc2e6e182f7ada476 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 2 Jun 2023 23:19:14 -0400 Subject: [PATCH] slight refactoring of code; configure --yes should work now --- .../backend/install/invokeai_configure.py | 9 +++--- .../backend/install/model_install_backend.py | 16 ++++++++++ invokeai/frontend/install/model_install.py | 30 +++---------------- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/invokeai/backend/install/invokeai_configure.py b/invokeai/backend/install/invokeai_configure.py index 02a8c60dcb..97a79b1581 100755 --- a/invokeai/backend/install/invokeai_configure.py +++ b/invokeai/backend/install/invokeai_configure.py @@ -49,6 +49,7 @@ from invokeai.backend.install.model_install_backend import ( download_from_hf, hf_download_with_resume, recommended_datasets, + UserSelections, ) from invokeai.app.services.config import ( get_invokeai_config, @@ -636,9 +637,9 @@ def default_startup_options(init_file: Path) -> Namespace: opts.nsfw_checker = True return opts -def default_user_selections(program_opts: Namespace) -> Namespace: - return Namespace( - starter_models=default_dataset() +def default_user_selections(program_opts: Namespace) -> UserSelections: + return UserSelections( + install_models=default_dataset() if program_opts.default_only else recommended_datasets() if program_opts.yes_to_all @@ -646,8 +647,6 @@ def default_user_selections(program_opts: Namespace) -> Namespace: purge_deleted_models=False, scan_directory=None, autoscan_on_startup=None, - import_model_paths=None, - convert_to_diffusers=None, ) diff --git a/invokeai/backend/install/model_install_backend.py b/invokeai/backend/install/model_install_backend.py index e69be80136..845d98172a 100644 --- a/invokeai/backend/install/model_install_backend.py +++ b/invokeai/backend/install/model_install_backend.py @@ -12,6 +12,7 @@ from tempfile import TemporaryFile from typing import List, Dict import requests +from dataclasses import dataclass,field from diffusers import AutoencoderKL from huggingface_hub import hf_hub_url, HfFolder from omegaconf import OmegaConf @@ -56,6 +57,21 @@ class ModelInstallList: install_models: List[str] remove_models: List[str] +@dataclass +class UserSelections(): + install_models: List[str]= field(default_factory=list) + remove_models: List[str]=field(default_factory=list) + purge_deleted_models: bool=field(default_factory=list) + install_cn_models: List[str] = field(default_factory=list) + remove_cn_models: List[str] = field(default_factory=list) + install_lora_models: List[str] = field(default_factory=list) + remove_lora_models: List[str] = field(default_factory=list) + install_ti_models: List[str] = field(default_factory=list) + remove_ti_models: List[str] = field(default_factory=list) + scan_directory: Path = None + autoscan_on_startup: bool=False + import_model_paths: str=None + def default_config_file(): return config.model_conf_path diff --git a/invokeai/frontend/install/model_install.py b/invokeai/frontend/install/model_install.py index de7b9b6c0a..4dd96ba3c4 100644 --- a/invokeai/frontend/install/model_install.py +++ b/invokeai/frontend/install/model_install.py @@ -14,7 +14,6 @@ import curses import os import sys from argparse import Namespace -from collections import deque from multiprocessing import Process from multiprocessing.connection import Connection, Pipe from pathlib import Path @@ -28,7 +27,6 @@ from npyscreen import widget from omegaconf import OmegaConf import invokeai.backend.util.logging as logger -from dataclasses import dataclass,field from ...backend.install.model_install_backend import ( Dataset_path, @@ -37,10 +35,11 @@ from ...backend.install.model_install_backend import ( install_requested_models, recommended_datasets, ModelInstallList, + UserSelections, ) from ...backend import ModelManager from ...backend.util import choose_precision, choose_torch_device -from ...backend.util.logging import InvokeAILogger, InvokeAILogFormatter +from ...backend.util.logging import InvokeAILogger from .widgets import ( CenteredTitleText, MultiSelectColumns, @@ -54,7 +53,7 @@ from invokeai.app.services.config import get_invokeai_config # minimum size for the UI MIN_COLS = 120 -MIN_LINES = 50 +MIN_LINES = 52 config = get_invokeai_config() @@ -140,13 +139,8 @@ class addModelsForm(npyscreen.FormMultiPage): BufferBox, name='Log Messages', editable=False, - max_height = 20, + max_height = 15, ) - # self.monitor = self.add_widget_intelligent( - # npyscreen.BufferPager, - # editable=False, - # max_height = 20, - # ) self.nextrely += 1 done_label = "INSTALL/REMOVE" @@ -661,22 +655,6 @@ class addModelsForm(npyscreen.FormMultiPage): # URLs and the like selections.import_model_paths = self.diffusers_models['download_ids'].value.split() - -@dataclass -class UserSelections(): - install_models: List[str]= field(default_factory=list) - remove_models: List[str]=field(default_factory=list) - purge_deleted_models: bool=field(default_factory=list) - install_cn_models: List[str] = field(default_factory=list) - remove_cn_models: List[str] = field(default_factory=list) - install_lora_models: List[str] = field(default_factory=list) - remove_lora_models: List[str] = field(default_factory=list) - install_ti_models: List[str] = field(default_factory=list) - remove_ti_models: List[str] = field(default_factory=list) - scan_directory: Path = None - autoscan_on_startup: bool=False - import_model_paths: str=None - class AddModelApplication(npyscreen.NPSAppManaged): def __init__(self,opt): super().__init__()