2023-02-13 04:59:18 +00:00
#!/usr/bin/env python
# Copyright (c) 2022 Lincoln D. Stein (https://github.com/lstein)
# Before running stable-diffusion on an internet-isolated machine,
# run this script from one with internet connectivity. The
# two machines must share a common .cache directory.
2023-02-15 06:07:39 +00:00
2023-02-21 19:12:57 +00:00
"""
2023-02-16 05:34:15 +00:00
This is the npyscreen frontend to the model installation application .
2024-02-09 21:42:33 +00:00
It is currently named model_install2 . py , but will ultimately replace model_install . py .
2023-02-21 19:12:57 +00:00
"""
2023-02-16 05:34:15 +00:00
2023-02-13 04:59:18 +00:00
import argparse
2023-06-02 21:20:50 +00:00
import curses
2024-03-17 00:28:49 +00:00
import pathlib
2023-02-13 04:59:18 +00:00
import sys
2023-06-07 21:32:00 +00:00
import traceback
2024-02-09 21:42:33 +00:00
import warnings
2023-02-13 04:59:18 +00:00
from argparse import Namespace
2023-03-03 06:02:00 +00:00
from shutil import get_terminal_size
2024-02-09 21:42:33 +00:00
from typing import Any , Dict , List , Optional , Set
2023-02-13 04:59:18 +00:00
import npyscreen
2023-02-15 06:07:39 +00:00
import torch
2023-02-14 21:32:54 +00:00
from npyscreen import widget
2023-02-13 04:59:18 +00:00
2024-03-11 12:16:21 +00:00
from invokeai . app . services . config . config_default import get_config
2024-02-09 21:42:33 +00:00
from invokeai . app . services . model_install import ModelInstallServiceBase
2024-03-18 10:18:05 +00:00
from invokeai . backend . install . check_directories import validate_directories
2024-02-09 21:42:33 +00:00
from invokeai . backend . install . install_helper import InstallHelper , InstallSelections , UnifiedModelInfo
from invokeai . backend . model_manager import ModelType
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
from invokeai . backend . util import choose_precision , choose_torch_device
2023-08-18 14:57:18 +00:00
from invokeai . backend . util . logging import InvokeAILogger
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
from invokeai . frontend . install . widgets import (
2023-08-18 14:57:18 +00:00
MIN_COLS ,
MIN_LINES ,
2023-03-03 06:02:00 +00:00
CenteredTitleText ,
2023-08-18 14:57:18 +00:00
CyclingForm ,
2023-03-03 06:02:00 +00:00
MultiSelectColumns ,
2023-06-01 04:31:46 +00:00
SingleSelectColumns ,
2023-03-03 06:02:00 +00:00
TextBox ,
2023-08-08 16:27:25 +00:00
WindowTooSmallException ,
2023-08-18 14:57:18 +00:00
set_min_terminal_size ,
2023-03-03 06:02:00 +00:00
)
2023-02-23 00:18:07 +00:00
2024-02-09 21:42:33 +00:00
warnings . filterwarnings ( " ignore " , category = UserWarning ) # noqa: E402
2024-03-11 12:16:21 +00:00
config = get_config ( )
logger = InvokeAILogger . get_logger ( " ModelInstallService " , config = config )
2024-02-18 23:02:58 +00:00
# logger.setLevel("WARNING")
2024-02-09 21:42:33 +00:00
# logger.setLevel('DEBUG')
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
# build a table mapping all non-printable characters to None
# for stripping control characters
# from https://stackoverflow.com/questions/92438/stripping-non-printable-characters-from-a-string-in-python
NOPRINT_TRANS_TABLE = { i : None for i in range ( 0 , sys . maxunicode + 1 ) if not chr ( i ) . isprintable ( ) }
2023-07-29 20:16:44 +00:00
# maximum number of installed models we can display before overflowing vertically
MAX_OTHER_MODELS = 72
2023-07-27 14:54:01 +00:00
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
def make_printable ( s : str ) - > str :
2024-02-09 21:42:33 +00:00
""" Replace non-printable characters in a string. """
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
return s . translate ( NOPRINT_TRANS_TABLE )
2023-03-03 06:02:00 +00:00
2023-07-27 14:54:01 +00:00
2023-06-06 20:53:11 +00:00
class addModelsForm ( CyclingForm , npyscreen . FormMultiPage ) :
2024-02-09 21:42:33 +00:00
""" Main form for interactive TUI. """
2023-06-25 22:50:15 +00:00
# for responsive resizing set to False, but this seems to cause a crash!
FIX_MINIMUM_SIZE_WHEN_CREATED = True
2023-07-27 14:54:01 +00:00
2023-06-02 21:20:50 +00:00
# for persistence
current_tab = 0
2023-03-03 06:02:00 +00:00
2024-02-09 21:42:33 +00:00
def __init__ ( self , parentApp : npyscreen . NPSAppManaged , name : str , multipage : bool = False , * * keywords : Any ) :
2023-02-21 19:12:57 +00:00
self . multipage = multipage
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
self . subprocess = None
2024-02-09 21:42:33 +00:00
super ( ) . __init__ ( parentApp = parentApp , name = name , * * keywords )
2023-06-01 04:31:46 +00:00
2024-02-09 21:42:33 +00:00
def create ( self ) - > None :
self . installer = self . parentApp . install_helper . installer
self . model_labels = self . _get_model_labels ( )
2023-06-03 02:24:46 +00:00
self . keypress_timeout = 10
self . counter = 0
self . subprocess_connection = None
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
2023-02-23 00:18:07 +00:00
window_width , window_height = get_terminal_size ( )
2023-05-30 04:38:37 +00:00
2024-02-09 21:42:33 +00:00
# npyscreen has no typing hints
self . nextrely - = 1 # type: ignore
2023-02-15 06:07:39 +00:00
self . add_widget_intelligent (
npyscreen . FixedText ,
2023-07-25 15:25:26 +00:00
value = " Use ctrl-N and ctrl-P to move to the <N>ext and <P>revious fields. Cursor keys navigate, and <space> selects. " ,
2023-02-15 06:07:39 +00:00
editable = False ,
2023-03-03 06:02:00 +00:00
color = " CAUTION " ,
2023-02-15 06:07:39 +00:00
)
2024-02-09 21:42:33 +00:00
self . nextrely + = 1 # type: ignore
2023-06-02 04:40:15 +00:00
self . tabs = self . add_widget_intelligent (
SingleSelectColumns ,
values = [
2023-10-08 22:53:21 +00:00
" STARTERS " ,
" MAINS " ,
2023-06-07 21:32:00 +00:00
" CONTROLNETS " ,
2023-10-08 22:53:21 +00:00
" T2I-ADAPTERS " ,
2023-09-24 21:31:08 +00:00
" IP-ADAPTERS " ,
2023-10-08 22:53:21 +00:00
" LORAS " ,
" TI EMBEDDINGS " ,
2023-06-02 04:40:15 +00:00
] ,
2023-06-02 21:20:50 +00:00
value = [ self . current_tab ] ,
2023-10-08 22:53:21 +00:00
columns = 7 ,
2023-06-02 04:40:15 +00:00
max_height = 2 ,
relx = 8 ,
scroll_exit = True ,
)
self . tabs . on_changed = self . _toggle_tables
2023-06-16 03:32:33 +00:00
2024-02-09 21:42:33 +00:00
top_of_table = self . nextrely # type: ignore
2023-06-16 03:32:33 +00:00
self . starter_pipelines = self . add_starter_pipelines ( )
2024-02-09 21:42:33 +00:00
bottom_of_table = self . nextrely # type: ignore
2023-06-02 21:20:50 +00:00
2023-06-02 04:40:15 +00:00
self . nextrely = top_of_table
2023-06-17 02:54:36 +00:00
self . pipeline_models = self . add_pipeline_widgets (
2023-06-03 20:17:53 +00:00
model_type = ModelType . Main , window_width = window_width , exclude = self . starter_models
)
2023-06-27 16:30:53 +00:00
# self.pipeline_models['autoload_pending'] = True
2023-06-03 20:17:53 +00:00
bottom_of_table = max ( bottom_of_table , self . nextrely )
self . nextrely = top_of_table
self . controlnet_models = self . add_model_widgets (
2023-06-16 03:32:33 +00:00
model_type = ModelType . ControlNet ,
2023-06-03 20:17:53 +00:00
window_width = window_width ,
)
bottom_of_table = max ( bottom_of_table , self . nextrely )
2023-06-02 04:40:15 +00:00
2023-10-08 22:53:21 +00:00
self . nextrely = top_of_table
self . t2i_models = self . add_model_widgets (
model_type = ModelType . T2IAdapter ,
window_width = window_width ,
)
bottom_of_table = max ( bottom_of_table , self . nextrely )
2023-09-24 21:31:08 +00:00
self . nextrely = top_of_table
self . ipadapter_models = self . add_model_widgets (
model_type = ModelType . IPAdapter ,
window_width = window_width ,
)
bottom_of_table = max ( bottom_of_table , self . nextrely )
2023-06-02 04:40:15 +00:00
self . nextrely = top_of_table
2023-06-03 20:17:53 +00:00
self . lora_models = self . add_model_widgets (
2024-03-05 06:37:17 +00:00
model_type = ModelType . LoRA ,
2023-06-03 20:17:53 +00:00
window_width = window_width ,
)
bottom_of_table = max ( bottom_of_table , self . nextrely )
2023-06-02 04:40:15 +00:00
self . nextrely = top_of_table
2023-06-03 20:17:53 +00:00
self . ti_models = self . add_model_widgets (
2023-06-16 03:32:33 +00:00
model_type = ModelType . TextualInversion ,
2023-06-03 20:17:53 +00:00
window_width = window_width ,
)
bottom_of_table = max ( bottom_of_table , self . nextrely )
2023-07-27 14:54:01 +00:00
2023-06-03 02:24:46 +00:00
self . nextrely = bottom_of_table + 1
2023-06-02 04:40:15 +00:00
self . nextrely + = 1
back_label = " BACK "
2023-07-25 15:25:26 +00:00
cancel_label = " CANCEL "
current_position = self . nextrely
2023-06-02 04:40:15 +00:00
if self . multipage :
self . back_button = self . add_widget_intelligent (
2023-06-04 18:55:51 +00:00
npyscreen . ButtonPress ,
2023-06-02 04:40:15 +00:00
name = back_label ,
when_pressed_function = self . on_back ,
)
2023-06-17 23:26:35 +00:00
else :
2023-07-25 15:25:26 +00:00
self . nextrely = current_position
self . cancel_button = self . add_widget_intelligent (
npyscreen . ButtonPress , name = cancel_label , when_pressed_function = self . on_cancel
)
self . nextrely = current_position
2023-06-02 04:40:15 +00:00
2024-02-09 21:42:33 +00:00
label = " APPLY CHANGES "
2023-07-25 15:25:26 +00:00
self . nextrely = current_position
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
self . done = self . add_widget_intelligent (
2023-06-02 21:20:50 +00:00
npyscreen . ButtonPress ,
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
name = label ,
relx = window_width - len ( label ) - 15 ,
when_pressed_function = self . on_done ,
2023-06-02 21:20:50 +00:00
)
# This restores the selected page on return from an installation
2023-11-10 23:51:21 +00:00
for _i in range ( 1 , self . current_tab + 1 ) :
2023-06-02 21:20:50 +00:00
self . tabs . h_cursor_line_down ( 1 )
self . _toggle_tables ( [ self . current_tab ] )
2023-06-02 04:40:15 +00:00
2023-06-03 02:24:46 +00:00
############# diffusers tab ##########
2023-06-16 03:32:33 +00:00
def add_starter_pipelines ( self ) - > dict [ str , npyscreen . widget ] :
2023-06-02 04:40:15 +00:00
""" Add widgets responsible for selecting diffusers models """
2024-02-09 21:42:33 +00:00
widgets : Dict [ str , npyscreen . widget ] = { }
2023-07-27 14:54:01 +00:00
2024-02-09 21:42:33 +00:00
all_models = self . all_models # master dict of all models, indexed by key
model_list = [ x for x in self . starter_models if all_models [ x ] . type in [ " main " , " vae " ] ]
model_labels = [ self . model_labels [ x ] for x in model_list ]
2023-06-02 04:40:15 +00:00
widgets . update (
label1 = self . add_widget_intelligent (
2023-02-24 05:53:48 +00:00
CenteredTitleText ,
2024-02-09 21:42:33 +00:00
name = " Select from a starter set of Stable Diffusion models from HuggingFace and Civitae. " ,
2023-02-24 05:53:48 +00:00
editable = False ,
labelColor = " CAUTION " ,
)
2023-06-02 04:40:15 +00:00
)
2023-07-27 14:54:01 +00:00
2023-06-02 04:40:15 +00:00
self . nextrely - = 1
# if user has already installed some initial models, then don't patronize them
# by showing more recommendations
2023-06-16 03:32:33 +00:00
show_recommended = len ( self . installed_models ) == 0
2024-02-09 21:42:33 +00:00
checked = [
model_list . index ( x )
for x in model_list
if ( show_recommended and all_models [ x ] . recommended ) or all_models [ x ] . installed
]
2023-06-02 04:40:15 +00:00
widgets . update (
models_selected = self . add_widget_intelligent (
2023-06-05 02:00:11 +00:00
MultiSelectColumns ,
columns = 1 ,
2023-02-24 05:53:48 +00:00
name = " Install Starter Models " ,
2024-02-09 21:42:33 +00:00
values = model_labels ,
value = checked ,
max_height = len ( model_list ) + 1 ,
2023-02-24 05:53:48 +00:00
relx = 4 ,
scroll_exit = True ,
2023-06-16 03:32:33 +00:00
) ,
2024-02-09 21:42:33 +00:00
models = model_list ,
2023-06-02 04:40:15 +00:00
)
self . nextrely + = 1
return widgets
2023-06-03 20:17:53 +00:00
############# Add a set of model install widgets ########
def add_model_widgets (
self ,
2023-06-16 03:32:33 +00:00
model_type : ModelType ,
2023-06-03 20:17:53 +00:00
window_width : int = 120 ,
2024-02-09 21:42:33 +00:00
install_prompt : Optional [ str ] = None ,
exclude : Optional [ Set [ str ] ] = None ,
2023-06-03 20:17:53 +00:00
) - > dict [ str , npyscreen . widget ] :
""" Generic code to create model selection widgets """
2023-11-10 23:51:21 +00:00
if exclude is None :
exclude = set ( )
2024-02-09 21:42:33 +00:00
widgets : Dict [ str , npyscreen . widget ] = { }
all_models = self . all_models
model_list = sorted (
[ x for x in all_models if all_models [ x ] . type == model_type and x not in exclude ] ,
key = lambda x : all_models [ x ] . name or " " ,
)
2023-06-16 03:32:33 +00:00
model_labels = [ self . model_labels [ x ] for x in model_list ]
2023-07-14 23:03:41 +00:00
show_recommended = len ( self . installed_models ) == 0
2023-07-30 14:17:04 +00:00
truncated = False
2023-06-03 20:17:53 +00:00
if len ( model_list ) > 0 :
2023-06-16 03:32:33 +00:00
max_width = max ( [ len ( x ) for x in model_labels ] )
2023-06-07 21:32:00 +00:00
columns = window_width / / ( max_width + 8 ) # 8 characters for "[x] " and padding
2023-06-03 20:17:53 +00:00
columns = min ( len ( model_list ) , columns ) or 1
2023-06-16 03:32:33 +00:00
prompt = (
install_prompt
or f " Select the desired { model_type . value . title ( ) } models to install. Unchecked models will be purged from disk. "
2023-07-27 14:54:01 +00:00
)
2023-06-03 20:17:53 +00:00
widgets . update (
label1 = self . add_widget_intelligent (
CenteredTitleText ,
name = prompt ,
editable = False ,
labelColor = " CAUTION " ,
)
2023-06-02 04:40:15 +00:00
)
2023-06-03 20:17:53 +00:00
2023-07-29 20:16:44 +00:00
if len ( model_labels ) > MAX_OTHER_MODELS :
model_labels = model_labels [ 0 : MAX_OTHER_MODELS ]
2023-07-30 14:17:04 +00:00
truncated = True
2023-07-29 20:16:44 +00:00
2023-06-03 20:17:53 +00:00
widgets . update (
models_selected = self . add_widget_intelligent (
MultiSelectColumns ,
columns = columns ,
name = f " Install { model_type } Models " ,
2023-06-16 03:32:33 +00:00
values = model_labels ,
2023-06-03 20:17:53 +00:00
value = [
model_list . index ( x )
for x in model_list
2024-02-09 21:42:33 +00:00
if ( show_recommended and all_models [ x ] . recommended ) or all_models [ x ] . installed
2023-06-03 20:17:53 +00:00
] ,
max_height = len ( model_list ) / / columns + 1 ,
relx = 4 ,
scroll_exit = True ,
2023-06-16 03:32:33 +00:00
) ,
models = model_list ,
2023-06-02 04:40:15 +00:00
)
2023-06-01 04:31:46 +00:00
2023-07-30 14:17:04 +00:00
if truncated :
2023-07-29 20:16:44 +00:00
widgets . update (
2023-07-29 23:20:20 +00:00
warning_message = self . add_widget_intelligent (
2023-07-29 20:16:44 +00:00
npyscreen . FixedText ,
value = f " Too many models to display (max= { MAX_OTHER_MODELS } ). Some are not displayed. " ,
editable = False ,
color = " CAUTION " ,
)
)
2023-06-07 21:32:00 +00:00
self . nextrely + = 1
2023-06-02 04:40:15 +00:00
widgets . update (
download_ids = self . add_widget_intelligent (
2023-06-02 21:20:50 +00:00
TextBox ,
2023-06-07 21:32:00 +00:00
name = " Additional URLs, or HuggingFace repo_ids to install (Space separated. Use shift-control-V to paste): " ,
2024-02-09 21:42:33 +00:00
max_height = 6 ,
2023-06-02 21:20:50 +00:00
scroll_exit = True ,
editable = True ,
2023-06-02 04:40:15 +00:00
)
2023-06-01 04:31:46 +00:00
)
2023-06-02 04:40:15 +00:00
return widgets
2023-06-03 20:17:53 +00:00
### Tab for arbitrary diffusers widgets ###
2023-06-17 02:54:36 +00:00
def add_pipeline_widgets (
self ,
2023-06-24 15:45:49 +00:00
model_type : ModelType = ModelType . Main ,
2023-06-17 02:54:36 +00:00
window_width : int = 120 ,
* * kwargs ,
) - > dict [ str , npyscreen . widget ] :
2023-06-03 20:17:53 +00:00
""" Similar to add_model_widgets() but adds some additional widgets at the bottom
to support the autoload directory """
widgets = self . add_model_widgets (
2023-06-16 03:32:33 +00:00
model_type = model_type ,
window_width = window_width ,
2023-07-29 23:49:58 +00:00
install_prompt = f " Installed { model_type . value . title ( ) } models. Unchecked models in the InvokeAI root directory will be deleted. Enter URLs, paths or repo_ids to import. " ,
2023-06-17 02:54:36 +00:00
* * kwargs ,
2023-06-03 20:17:53 +00:00
)
2023-06-02 04:40:15 +00:00
return widgets
2023-02-21 16:47:41 +00:00
2024-02-09 21:42:33 +00:00
def resize ( self ) - > None :
2023-02-15 06:07:39 +00:00
super ( ) . resize ( )
2023-06-16 03:32:33 +00:00
if s := self . starter_pipelines . get ( " models_selected " ) :
2024-02-09 21:42:33 +00:00
if model_list := self . starter_pipelines . get ( " models " ) :
s . values = [ self . model_labels [ x ] for x in model_list ]
2023-02-21 16:47:41 +00:00
2024-02-09 21:42:33 +00:00
def _toggle_tables ( self , value : List [ int ] ) - > None :
2023-06-01 04:45:07 +00:00
selected_tab = value [ 0 ]
2023-06-01 04:31:46 +00:00
widgets = [
2023-06-16 03:32:33 +00:00
self . starter_pipelines ,
self . pipeline_models ,
2023-06-02 04:40:15 +00:00
self . controlnet_models ,
2023-10-08 22:53:21 +00:00
self . t2i_models ,
2023-09-24 21:31:08 +00:00
self . ipadapter_models ,
2023-06-02 04:40:15 +00:00
self . lora_models ,
self . ti_models ,
2023-06-01 04:31:46 +00:00
]
for group in widgets :
2023-11-10 23:51:21 +00:00
for _k , v in group . items ( ) :
2023-06-16 03:32:33 +00:00
try :
v . hidden = True
v . editable = False
2023-08-17 22:45:25 +00:00
except Exception :
2023-06-16 03:32:33 +00:00
pass
2023-11-10 23:51:21 +00:00
for _k , v in widgets [ selected_tab ] . items ( ) :
2023-06-16 03:32:33 +00:00
try :
v . hidden = False
if not isinstance ( v , ( npyscreen . FixedText , npyscreen . TitleFixedText , CenteredTitleText ) ) :
v . editable = True
2023-08-17 22:45:25 +00:00
except Exception :
2023-06-16 03:32:33 +00:00
pass
2023-06-02 21:20:50 +00:00
self . __class__ . current_tab = selected_tab # for persistence
2023-06-01 04:31:46 +00:00
self . display ( )
2023-06-16 03:32:33 +00:00
def _get_model_labels ( self ) - > dict [ str , str ] :
2024-02-09 21:42:33 +00:00
""" Return a list of trimmed labels for all models. """
2023-02-23 00:18:07 +00:00
window_width , window_height = get_terminal_size ( )
2023-02-14 21:32:54 +00:00
checkbox_width = 4
spacing_width = 2
2024-02-09 21:42:33 +00:00
result = { }
2023-07-27 14:54:01 +00:00
2023-06-16 03:32:33 +00:00
models = self . all_models
2024-02-09 21:42:33 +00:00
label_width = max ( [ len ( models [ x ] . name or " " ) for x in self . starter_models ] )
2023-02-14 21:32:54 +00:00
description_width = window_width - label_width - checkbox_width - spacing_width
2023-02-13 04:59:18 +00:00
2024-02-09 21:42:33 +00:00
for key in self . all_models :
description = models [ key ] . description
2023-06-16 03:32:33 +00:00
description = (
description [ 0 : description_width - 3 ] + " ... "
if description and len ( description ) > description_width
else description
if description
else " "
2023-07-27 14:54:01 +00:00
)
2024-02-09 21:42:33 +00:00
result [ key ] = f " %- { label_width } s %s " % ( models [ key ] . name , description )
2023-06-16 03:32:33 +00:00
return result
2023-07-27 14:54:01 +00:00
2023-02-21 19:12:57 +00:00
def _get_columns ( self ) - > int :
2023-02-23 00:18:07 +00:00
window_width , window_height = get_terminal_size ( )
2023-02-21 19:12:57 +00:00
cols = 4 if window_width > 240 else 3 if window_width > 160 else 2 if window_width > 80 else 1
return min ( cols , len ( self . installed_models ) )
2023-02-15 06:07:39 +00:00
2023-07-05 13:57:23 +00:00
def confirm_deletions ( self , selections : InstallSelections ) - > bool :
remove_models = selections . remove_models
2024-02-09 21:42:33 +00:00
if remove_models :
model_names = [ self . all_models [ x ] . name or " " for x in remove_models ]
mods = " \n " . join ( model_names )
is_ok = npyscreen . notify_ok_cancel (
2023-07-05 13:57:23 +00:00
f " These unchecked models will be deleted from disk. Continue? \n --------- \n { mods } "
)
2024-02-09 21:42:33 +00:00
assert isinstance ( is_ok , bool ) # npyscreen doesn't have return type annotations
return is_ok
2023-07-05 13:57:23 +00:00
else :
return True
2024-02-09 21:42:33 +00:00
@property
def all_models ( self ) - > Dict [ str , UnifiedModelInfo ] :
# npyscreen doesn't having typing hints
return self . parentApp . install_helper . all_models # type: ignore
2023-07-27 14:54:01 +00:00
2024-02-09 21:42:33 +00:00
@property
def starter_models ( self ) - > List [ str ] :
return self . parentApp . install_helper . _starter_models # type: ignore
2023-07-27 14:54:01 +00:00
2024-02-09 21:42:33 +00:00
@property
def installed_models ( self ) - > List [ str ] :
return self . parentApp . install_helper . _installed_models # type: ignore
2023-06-03 02:24:46 +00:00
2024-02-09 21:42:33 +00:00
def on_back ( self ) - > None :
2023-02-19 21:08:58 +00:00
self . parentApp . switchFormPrevious ( )
2023-02-15 06:07:39 +00:00
self . editing = False
2024-02-09 21:42:33 +00:00
def on_cancel ( self ) - > None :
2023-06-02 21:20:50 +00:00
self . parentApp . setNextForm ( None )
self . parentApp . user_cancelled = True
self . editing = False
2023-07-27 14:54:01 +00:00
2024-02-09 21:42:33 +00:00
def on_done ( self ) - > None :
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
self . marshall_arguments ( )
2023-07-05 13:57:23 +00:00
if not self . confirm_deletions ( self . parentApp . install_selections ) :
return
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
self . parentApp . setNextForm ( None )
self . parentApp . user_cancelled = False
self . editing = False
2023-07-27 14:54:01 +00:00
2024-02-09 21:42:33 +00:00
def marshall_arguments ( self ) - > None :
2023-02-21 19:12:57 +00:00
"""
2023-02-15 06:07:39 +00:00
Assemble arguments and store as attributes of the application :
. starter_models : dict of model names to install from INITIAL_CONFIGURE . yaml
True = > Install
False = > Remove
. scan_directory : Path to a directory of models to scan and import
. autoscan_on_startup : True if invokeai should scan and import at startup time
. import_model_paths : list of URLs , repo_ids and file paths to import
2023-02-21 19:12:57 +00:00
"""
2023-06-17 02:54:36 +00:00
selections = self . parentApp . install_selections
all_models = self . all_models
2024-02-21 15:18:30 +00:00
# Defined models (in INITIAL_CONFIG.yaml or invokeai.db) to add/remove
2023-06-17 02:54:36 +00:00
ui_sections = [
self . starter_pipelines ,
self . pipeline_models ,
self . controlnet_models ,
2023-10-08 22:53:21 +00:00
self . t2i_models ,
2023-09-24 21:31:08 +00:00
self . ipadapter_models ,
2023-06-17 02:54:36 +00:00
self . lora_models ,
self . ti_models ,
]
for section in ui_sections :
2023-08-17 22:45:25 +00:00
if " models_selected " not in section :
2023-06-17 23:26:35 +00:00
continue
2023-11-10 23:44:43 +00:00
selected = { section [ " models " ] [ x ] for x in section [ " models_selected " ] . value }
2023-06-16 03:32:33 +00:00
models_to_install = [ x for x in selected if not self . all_models [ x ] . installed ]
models_to_remove = [ x for x in section [ " models " ] if x not in selected and self . all_models [ x ] . installed ]
2023-06-17 02:54:36 +00:00
selections . remove_models . extend ( models_to_remove )
2024-02-09 21:42:33 +00:00
selections . install_models . extend ( [ all_models [ x ] for x in models_to_install ] )
2023-06-17 02:54:36 +00:00
# models located in the 'download_ids" section
for section in ui_sections :
if downloads := section . get ( " download_ids " ) :
2024-02-09 21:42:33 +00:00
models = [ UnifiedModelInfo ( source = x ) for x in downloads . value . split ( ) ]
selections . install_models . extend ( models )
class AddModelApplication ( npyscreen . NPSAppManaged ) : # type: ignore
def __init__ ( self , opt : Namespace , install_helper : InstallHelper ) :
2023-02-13 04:59:18 +00:00
super ( ) . __init__ ( )
2023-06-04 18:55:51 +00:00
self . program_opts = opt
2023-02-19 18:12:05 +00:00
self . user_cancelled = False
2023-06-17 02:54:36 +00:00
self . install_selections = InstallSelections ( )
2024-02-09 21:42:33 +00:00
self . install_helper = install_helper
2023-02-13 04:59:18 +00:00
2024-02-09 21:42:33 +00:00
def onStart ( self ) - > None :
2023-02-13 04:59:18 +00:00
npyscreen . setTheme ( npyscreen . Themes . DefaultTheme )
2023-02-19 18:12:05 +00:00
self . main_form = self . addForm (
2023-07-25 15:25:26 +00:00
" MAIN " ,
addModelsForm ,
name = " Install Stable Diffusion Models " ,
cycle_widgets = False ,
2023-02-13 04:59:18 +00:00
)
2023-07-27 14:54:01 +00:00
2024-02-09 21:42:33 +00:00
def list_models ( installer : ModelInstallServiceBase , model_type : ModelType ) :
""" Print out all models of type model_type. """
models = installer . record_store . search_by_attr ( model_type = model_type )
print ( f " Installed models of type ` { model_type } `: " )
for model in models :
path = ( config . models_path / model . path ) . resolve ( )
print ( f " { model . name : 40 } { model . base . value : 5 } { model . type . value : 8 } { model . format . value : 12 } { path } " )
2023-06-04 15:27:44 +00:00
2023-07-27 14:54:01 +00:00
2023-06-04 15:27:44 +00:00
# --------------------------------------------------------
2024-02-09 21:42:33 +00:00
def select_and_download_models ( opt : Namespace ) - > None :
""" Prompt user for install/delete selections and execute. """
2023-02-21 19:12:57 +00:00
precision = " float32 " if opt . full_precision else choose_precision ( torch . device ( choose_torch_device ( ) ) )
2024-02-10 23:09:45 +00:00
config . precision = precision
2024-02-09 21:42:33 +00:00
install_helper = InstallHelper ( config , logger )
installer = install_helper . installer
2023-07-14 23:52:47 +00:00
if opt . list_models :
2024-02-09 21:42:33 +00:00
list_models ( installer , opt . list_models )
2023-07-14 23:52:47 +00:00
elif opt . add or opt . delete :
2024-02-09 21:42:33 +00:00
selections = InstallSelections (
install_models = [ UnifiedModelInfo ( source = x ) for x in ( opt . add or [ ] ) ] , remove_models = opt . delete or [ ]
)
install_helper . add_or_delete ( selections )
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
elif opt . default_only :
2024-02-09 21:42:33 +00:00
default_model = install_helper . default_model ( )
assert default_model is not None
selections = InstallSelections ( install_models = [ default_model ] )
install_helper . add_or_delete ( selections )
2023-02-19 21:08:58 +00:00
elif opt . yes_to_all :
2024-02-09 21:42:33 +00:00
selections = InstallSelections ( install_models = install_helper . recommended_models ( ) )
install_helper . add_or_delete ( selections )
2023-06-07 21:32:00 +00:00
# this is where the TUI is called
2023-02-13 04:59:18 +00:00
else :
2023-08-08 16:27:25 +00:00
if not set_min_terminal_size ( MIN_COLS , MIN_LINES ) :
raise WindowTooSmallException (
" Could not increase terminal size. Try running again with a larger window or smaller font size. "
)
2024-02-09 21:42:33 +00:00
installApp = AddModelApplication ( opt , install_helper )
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
try :
installApp . run ( )
2024-02-09 21:42:33 +00:00
except KeyboardInterrupt :
print ( " Aborted... " )
sys . exit ( - 1 )
install_helper . add_or_delete ( installApp . install_selections )
2023-02-21 19:12:57 +00:00
2023-07-27 14:54:01 +00:00
2023-02-13 04:59:18 +00:00
# -------------------------------------
2024-02-09 21:42:33 +00:00
def main ( ) - > None :
2023-02-13 04:59:18 +00:00
parser = argparse . ArgumentParser ( description = " InvokeAI model downloader " )
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
parser . add_argument (
2023-06-17 02:54:36 +00:00
" --add " ,
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
nargs = " * " ,
2023-06-17 02:54:36 +00:00
help = " List of URLs, local paths or repo_ids of models to install " ,
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
)
parser . add_argument (
" --delete " ,
2023-06-17 02:54:36 +00:00
nargs = " * " ,
2024-02-09 21:42:33 +00:00
help = " List of names of models to delete. Use type:name to disambiguate, as in `controlnet:my_model` " ,
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
)
2023-02-13 04:59:18 +00:00
parser . add_argument (
" --full-precision " ,
dest = " full_precision " ,
action = argparse . BooleanOptionalAction ,
type = bool ,
default = False ,
help = " use 32-bit weights instead of faster 16-bit weights " ,
)
parser . add_argument (
" --yes " ,
" -y " ,
dest = " yes_to_all " ,
action = " store_true " ,
help = ' answer " yes " to all prompts ' ,
)
parser . add_argument (
" --default_only " ,
action = " store_true " ,
2023-06-17 02:54:36 +00:00
help = " Only install the default model " ,
2023-02-13 04:59:18 +00:00
)
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
parser . add_argument (
" --list-models " ,
2023-07-14 23:52:47 +00:00
choices = [ x . value for x in ModelType ] ,
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
help = " list installed models " ,
)
2023-02-13 04:59:18 +00:00
parser . add_argument (
" --root_dir " ,
dest = " root " ,
2024-03-17 00:28:49 +00:00
type = pathlib . Path ,
2023-02-13 04:59:18 +00:00
default = None ,
help = " path to root of install directory " ,
)
opt = parser . parse_args ( )
2023-07-27 14:54:01 +00:00
2024-03-11 12:16:21 +00:00
invoke_args : dict [ str , Any ] = { }
Multiple fixes
1. Model installer works correctly under Windows 11 Terminal
2. Fixed crash when configure script hands control off to installer
3. Kill install subprocess on keyboard interrupt
4. Command-line functionality for --yes configuration and model installation
restored.
5. New command-line features:
- install/delete lists of diffusers, LoRAS, controlnets and textual inversions
using repo ids, paths or URLs.
Help:
```
usage: invokeai-model-install [-h] [--diffusers [DIFFUSERS ...]] [--loras [LORAS ...]] [--controlnets [CONTROLNETS ...]] [--textual-inversions [TEXTUAL_INVERSIONS ...]] [--delete] [--full-precision | --no-full-precision]
[--yes] [--default_only] [--list-models {diffusers,loras,controlnets,tis}] [--config_file CONFIG_FILE] [--root_dir ROOT]
InvokeAI model downloader
options:
-h, --help show this help message and exit
--diffusers [DIFFUSERS ...]
List of URLs or repo_ids of diffusers to install/delete
--loras [LORAS ...] List of URLs or repo_ids of LoRA/LyCORIS models to install/delete
--controlnets [CONTROLNETS ...]
List of URLs or repo_ids of controlnet models to install/delete
--textual-inversions [TEXTUAL_INVERSIONS ...]
List of URLs or repo_ids of textual inversion embeddings to install/delete
--delete Delete models listed on command line rather than installing them
--full-precision, --no-full-precision
use 32-bit weights instead of faster 16-bit weights (default: False)
--yes, -y answer "yes" to all prompts
--default_only only install the default model
--list-models {diffusers,loras,controlnets,tis}
list installed models
--config_file CONFIG_FILE, -c CONFIG_FILE
path to configuration file to create
--root_dir ROOT path to root of install directory
```
2023-06-06 01:45:35 +00:00
if opt . full_precision :
2024-03-11 12:16:21 +00:00
invoke_args [ " precision " ] = " float32 "
config . update_config ( invoke_args )
2024-03-17 00:28:49 +00:00
if opt . root :
config . set_root ( opt . root )
2023-08-17 23:17:38 +00:00
logger = InvokeAILogger ( ) . get_logger ( config = config )
2023-05-30 04:38:37 +00:00
2024-03-11 12:16:21 +00:00
try :
2024-03-18 10:17:37 +00:00
validate_directories ( config )
2024-03-11 12:16:21 +00:00
except AssertionError :
2023-04-19 00:49:00 +00:00
logger . info ( " Your InvokeAI root directory is not set up. Calling invokeai-configure. " )
2024-03-14 06:23:41 +00:00
sys . argv = [ " invokeai_configure " , " --yes " , " --skip-sd-weights " ]
2023-08-13 12:15:55 +00:00
from invokeai . frontend . install . invokeai_configure import invokeai_configure
2023-02-21 19:12:57 +00:00
2023-03-03 06:02:00 +00:00
invokeai_configure ( )
2023-02-21 16:47:41 +00:00
sys . exit ( 0 )
2023-02-13 04:59:18 +00:00
try :
select_and_download_models ( opt )
2023-02-14 21:32:54 +00:00
except AssertionError as e :
2023-04-29 13:43:40 +00:00
logger . error ( e )
2023-02-14 21:32:54 +00:00
sys . exit ( - 1 )
2023-02-13 04:59:18 +00:00
except KeyboardInterrupt :
2023-06-02 21:20:50 +00:00
curses . nocbreak ( )
curses . echo ( )
curses . endwin ( )
2023-04-29 13:43:40 +00:00
logger . info ( " Goodbye! Come back soon. " )
2023-08-08 16:27:25 +00:00
except WindowTooSmallException as e :
logger . error ( str ( e ) )
2023-02-23 05:43:25 +00:00
except widget . NotEnoughSpaceForWidget as e :
2023-02-14 21:32:54 +00:00
if str ( e ) . startswith ( " Height of 1 allocated " ) :
2023-04-19 00:49:00 +00:00
logger . error ( " Insufficient vertical space for the interface. Please make your window taller and try again " )
2023-06-08 20:37:10 +00:00
input ( " Press any key to continue... " )
except Exception as e :
if str ( e ) . startswith ( " addwstr " ) :
2023-04-29 13:43:40 +00:00
logger . error (
2023-04-19 00:49:00 +00:00
" Insufficient horizontal space for the interface. Please make your window wider and try again. "
2023-02-14 21:32:54 +00:00
)
2023-06-08 20:37:10 +00:00
else :
print ( f " An exception has occurred: { str ( e ) } Details: " )
print ( traceback . format_exc ( ) , file = sys . stderr )
2023-06-07 11:35:34 +00:00
input ( " Press any key to continue... " )
2023-07-27 14:54:01 +00:00
2023-03-03 06:02:00 +00:00
2023-02-13 04:59:18 +00:00
# -------------------------------------
if __name__ == " __main__ " :
main ( )