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.
|
2023-02-17 19:34:48 +00:00
|
|
|
The work is actually done in backend code in model_install_backend.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
|
2023-02-13 04:59:18 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2023-06-03 20:17:53 +00:00
|
|
|
import textwrap
|
2023-02-13 04:59:18 +00:00
|
|
|
from argparse import Namespace
|
2023-06-03 02:24:46 +00:00
|
|
|
from multiprocessing import Process
|
|
|
|
from multiprocessing.connection import Connection, Pipe
|
2023-02-21 19:12:57 +00:00
|
|
|
from pathlib import Path
|
2023-03-03 06:02:00 +00:00
|
|
|
from shutil import get_terminal_size
|
2023-02-15 06:07:39 +00:00
|
|
|
from typing import List
|
2023-02-13 04:59:18 +00:00
|
|
|
|
2023-06-03 02:24:46 +00:00
|
|
|
import logging
|
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
|
|
|
from omegaconf import OmegaConf
|
|
|
|
|
2023-04-29 13:43:40 +00:00
|
|
|
import invokeai.backend.util.logging as logger
|
2023-03-03 06:02:00 +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
|
|
|
from invokeai.backend.install.model_install_backend import (
|
2023-03-03 06:02:00 +00:00
|
|
|
Dataset_path,
|
|
|
|
default_config_file,
|
|
|
|
default_dataset,
|
|
|
|
install_requested_models,
|
|
|
|
recommended_datasets,
|
2023-06-01 04:31:46 +00:00
|
|
|
ModelInstallList,
|
2023-06-03 03:19:14 +00:00
|
|
|
UserSelections,
|
2023-03-03 06:02:00 +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
|
|
|
from invokeai.backend import ModelManager
|
|
|
|
from invokeai.backend.util import choose_precision, choose_torch_device
|
|
|
|
from invokeai.backend.util.logging import InvokeAILogger
|
|
|
|
from invokeai.frontend.install.widgets import (
|
2023-03-03 06:02:00 +00:00
|
|
|
CenteredTitleText,
|
|
|
|
MultiSelectColumns,
|
2023-06-01 04:31:46 +00:00
|
|
|
SingleSelectColumns,
|
2023-03-03 06:02:00 +00:00
|
|
|
TextBox,
|
2023-06-03 02:24:46 +00:00
|
|
|
BufferBox,
|
2023-06-04 15:27:44 +00:00
|
|
|
FileBox,
|
2023-03-03 06:02:00 +00:00
|
|
|
set_min_terminal_size,
|
2023-06-04 15:27:44 +00:00
|
|
|
select_stable_diffusion_config_file,
|
2023-06-06 20:53:11 +00:00
|
|
|
CyclingForm,
|
2023-06-06 19:17:15 +00:00
|
|
|
MIN_COLS,
|
|
|
|
MIN_LINES,
|
2023-03-03 06:02:00 +00:00
|
|
|
)
|
2023-05-26 00:41:26 +00:00
|
|
|
from invokeai.app.services.config import InvokeAIAppConfig
|
2023-02-23 00:18:07 +00:00
|
|
|
|
2023-05-26 00:41:26 +00:00
|
|
|
config = InvokeAIAppConfig.get_config()
|
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()
|
|
|
|
}
|
|
|
|
|
|
|
|
def make_printable(s:str)->str:
|
|
|
|
'''Replace non-printable characters in a string'''
|
|
|
|
return s.translate(NOPRINT_TRANS_TABLE)
|
2023-03-03 06:02:00 +00:00
|
|
|
|
2023-06-06 20:53:11 +00:00
|
|
|
class addModelsForm(CyclingForm, npyscreen.FormMultiPage):
|
2023-02-22 12:05:51 +00:00
|
|
|
# for responsive resizing - disabled
|
2023-03-03 06:02:00 +00:00
|
|
|
# FIX_MINIMUM_SIZE_WHEN_CREATED = False
|
2023-06-02 21:20:50 +00:00
|
|
|
|
|
|
|
# for persistence
|
|
|
|
current_tab = 0
|
2023-03-03 06:02:00 +00:00
|
|
|
|
2023-02-19 21:55:09 +00:00
|
|
|
def __init__(self, parentApp, name, multipage=False, *args, **keywords):
|
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
|
2023-06-03 02:24:46 +00:00
|
|
|
super().__init__(parentApp=parentApp, name=name, *args, **keywords)
|
2023-06-01 04:31:46 +00:00
|
|
|
|
2023-06-03 02:24:46 +00:00
|
|
|
def create(self):
|
|
|
|
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
|
|
|
|
|
|
|
if not config.model_conf_path.exists():
|
|
|
|
with open(config.model_conf_path,'w') as file:
|
|
|
|
print('# InvokeAI model configuration file',file=file)
|
2023-06-01 04:31:46 +00:00
|
|
|
model_manager = ModelManager(config.model_conf_path)
|
2023-05-30 17:49:43 +00:00
|
|
|
|
2023-06-03 20:17:53 +00:00
|
|
|
self.starter_models = OmegaConf.load(Dataset_path)['diffusers']
|
|
|
|
self.installed_diffusers_models = self.list_additional_diffusers_models(
|
|
|
|
model_manager,
|
|
|
|
self.starter_models,
|
|
|
|
)
|
2023-06-01 04:31:46 +00:00
|
|
|
self.installed_cn_models = model_manager.list_controlnet_models()
|
2023-06-02 04:40:15 +00:00
|
|
|
self.installed_lora_models = model_manager.list_lora_models()
|
|
|
|
self.installed_ti_models = model_manager.list_ti_models()
|
2023-06-01 04:31:46 +00:00
|
|
|
|
2023-02-13 04:59:18 +00:00
|
|
|
try:
|
2023-02-16 05:34:15 +00:00
|
|
|
self.existing_models = OmegaConf.load(default_config_file())
|
2023-02-13 04:59:18 +00:00
|
|
|
except:
|
|
|
|
self.existing_models = dict()
|
2023-06-03 02:24:46 +00:00
|
|
|
|
2023-06-03 20:17:53 +00:00
|
|
|
self.starter_model_list = list(self.starter_models.keys())
|
2023-02-21 19:12:57 +00:00
|
|
|
self.installed_models = dict()
|
2023-02-13 04:59:18 +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
|
|
|
|
2023-02-16 05:34:15 +00:00
|
|
|
self.nextrely -= 1
|
2023-02-15 06:07:39 +00:00
|
|
|
self.add_widget_intelligent(
|
|
|
|
npyscreen.FixedText,
|
2023-02-21 19:12:57 +00:00
|
|
|
value="Use ctrl-N and ctrl-P to move to the <N>ext and <P>revious fields,",
|
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
|
|
|
)
|
|
|
|
self.add_widget_intelligent(
|
|
|
|
npyscreen.FixedText,
|
2023-02-22 02:33:44 +00:00
|
|
|
value="Use cursor arrows to make a selection, and space to toggle checkboxes.",
|
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
|
|
|
)
|
2023-02-16 05:34:15 +00:00
|
|
|
self.nextrely += 1
|
2023-06-02 04:40:15 +00:00
|
|
|
self.tabs = self.add_widget_intelligent(
|
|
|
|
SingleSelectColumns,
|
|
|
|
values=[
|
2023-06-03 20:17:53 +00:00
|
|
|
'STARTER MODELS',
|
|
|
|
'MORE DIFFUSION MODELS',
|
2023-06-02 04:40:15 +00:00
|
|
|
'CONTROLNET MODELS',
|
|
|
|
'LORA/LYCORIS MODELS',
|
2023-06-03 20:17:53 +00:00
|
|
|
'TEXTUAL INVERSION MODELS',
|
2023-06-02 04:40:15 +00:00
|
|
|
],
|
2023-06-02 21:20:50 +00:00
|
|
|
value=[self.current_tab],
|
2023-06-03 20:17:53 +00:00
|
|
|
columns = 5,
|
2023-06-02 04:40:15 +00:00
|
|
|
max_height = 2,
|
|
|
|
relx=8,
|
|
|
|
scroll_exit = True,
|
|
|
|
)
|
|
|
|
self.tabs.on_changed = self._toggle_tables
|
|
|
|
|
|
|
|
top_of_table = self.nextrely
|
2023-06-03 20:17:53 +00:00
|
|
|
self.starter_diffusers_models = self.add_starter_diffusers()
|
2023-06-02 04:40:15 +00:00
|
|
|
bottom_of_table = self.nextrely
|
2023-06-02 21:20:50 +00:00
|
|
|
|
2023-06-02 04:40:15 +00:00
|
|
|
self.nextrely = top_of_table
|
2023-06-03 20:17:53 +00:00
|
|
|
self.diffusers_models = self.add_diffusers_widgets(
|
|
|
|
predefined_models=self.installed_diffusers_models,
|
|
|
|
model_type='Diffusers',
|
|
|
|
window_width=window_width,
|
|
|
|
)
|
|
|
|
bottom_of_table = max(bottom_of_table,self.nextrely)
|
|
|
|
|
|
|
|
self.nextrely = top_of_table
|
|
|
|
self.controlnet_models = self.add_model_widgets(
|
|
|
|
predefined_models=self.installed_cn_models,
|
|
|
|
model_type='ControlNet',
|
|
|
|
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(
|
|
|
|
predefined_models=self.installed_lora_models,
|
|
|
|
model_type="LoRA/LyCORIS",
|
|
|
|
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(
|
|
|
|
predefined_models=self.installed_ti_models,
|
|
|
|
model_type="Textual Inversion Embeddings",
|
|
|
|
window_width=window_width,
|
|
|
|
)
|
|
|
|
bottom_of_table = max(bottom_of_table,self.nextrely)
|
2023-06-02 04:40:15 +00:00
|
|
|
|
2023-06-03 02:24:46 +00:00
|
|
|
self.nextrely = bottom_of_table+1
|
|
|
|
|
|
|
|
self.monitor = self.add_widget_intelligent(
|
|
|
|
BufferBox,
|
|
|
|
name='Log Messages',
|
|
|
|
editable=False,
|
2023-06-06 21:23:13 +00:00
|
|
|
max_height = 20,
|
2023-06-03 02:24:46 +00:00
|
|
|
)
|
2023-06-02 04:40:15 +00:00
|
|
|
|
|
|
|
self.nextrely += 1
|
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
|
|
|
done_label = "INSTALL/REMOVE NOW"
|
2023-06-02 04:40:15 +00:00
|
|
|
back_label = "BACK"
|
|
|
|
button_length = len(done_label)
|
|
|
|
button_offset = 0
|
|
|
|
if self.multipage:
|
|
|
|
button_length += len(back_label) + 1
|
|
|
|
button_offset += len(back_label) + 1
|
|
|
|
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,
|
|
|
|
relx=(window_width - button_length) // 2,
|
|
|
|
rely=-3,
|
|
|
|
when_pressed_function=self.on_back,
|
|
|
|
)
|
|
|
|
self.ok_button = self.add_widget_intelligent(
|
2023-06-04 18:55:51 +00:00
|
|
|
npyscreen.ButtonPress, # OffsetButtonPress,
|
2023-06-02 04:40:15 +00:00
|
|
|
name=done_label,
|
|
|
|
relx=button_offset + 1 + (window_width - button_length) // 2,
|
|
|
|
rely=-3,
|
2023-06-03 02:24:46 +00:00
|
|
|
when_pressed_function=self.on_execute
|
2023-06-02 04:40:15 +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
|
|
|
label = "INSTALL AND EXIT"
|
|
|
|
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,
|
2023-06-02 21:20:50 +00:00
|
|
|
rely=-3,
|
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
|
|
|
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
|
|
|
|
for i in range(1,self.current_tab+1):
|
|
|
|
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-03 20:17:53 +00:00
|
|
|
def add_starter_diffusers(self)->dict[str, npyscreen.widget]:
|
2023-06-02 04:40:15 +00:00
|
|
|
'''Add widgets responsible for selecting diffusers models'''
|
|
|
|
widgets = dict()
|
|
|
|
|
|
|
|
starter_model_labels = self._get_starter_model_labels()
|
|
|
|
recommended_models = [
|
|
|
|
x
|
|
|
|
for x in self.starter_model_list
|
2023-06-03 20:17:53 +00:00
|
|
|
if self.starter_models[x].get("recommended", False)
|
2023-06-02 04:40:15 +00:00
|
|
|
]
|
|
|
|
self.installed_models = sorted(
|
2023-06-03 20:17:53 +00:00
|
|
|
[x for x in list(self.starter_models.keys()) if x in self.existing_models]
|
2023-06-02 04:40:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
widgets.update(
|
|
|
|
label1 = self.add_widget_intelligent(
|
2023-02-24 05:53:48 +00:00
|
|
|
CenteredTitleText,
|
|
|
|
name="Select from a starter set of Stable Diffusion models from HuggingFace.",
|
|
|
|
editable=False,
|
|
|
|
labelColor="CAUTION",
|
|
|
|
)
|
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
|
|
|
|
show_recommended = not self.existing_models
|
|
|
|
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",
|
|
|
|
values=starter_model_labels,
|
|
|
|
value=[
|
|
|
|
self.starter_model_list.index(x)
|
|
|
|
for x in self.starter_model_list
|
2023-05-30 04:38:37 +00:00
|
|
|
if (show_recommended and x in recommended_models)\
|
|
|
|
or (x in self.existing_models)
|
2023-02-24 05:53:48 +00:00
|
|
|
],
|
|
|
|
max_height=len(starter_model_labels) + 1,
|
|
|
|
relx=4,
|
|
|
|
scroll_exit=True,
|
|
|
|
)
|
2023-06-02 04:40:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
widgets.update(
|
|
|
|
purge_deleted = self.add_widget_intelligent(
|
2023-05-30 04:38:37 +00:00
|
|
|
npyscreen.Checkbox,
|
2023-05-30 17:49:43 +00:00
|
|
|
name="Purge unchecked diffusers models from disk",
|
2023-05-30 04:38:37 +00:00
|
|
|
value=False,
|
|
|
|
scroll_exit=True,
|
|
|
|
relx=4,
|
|
|
|
)
|
2023-02-22 02:33:44 +00:00
|
|
|
)
|
2023-06-03 20:17:53 +00:00
|
|
|
widgets['purge_deleted'].when_value_edited = lambda: self.sync_purge_buttons(widgets['purge_deleted'])
|
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,
|
|
|
|
predefined_models: dict[str,bool],
|
|
|
|
model_type: str,
|
|
|
|
window_width: int=120,
|
|
|
|
install_prompt: str=None,
|
|
|
|
)->dict[str,npyscreen.widget]:
|
|
|
|
'''Generic code to create model selection widgets'''
|
2023-06-02 04:40:15 +00:00
|
|
|
widgets = dict()
|
2023-06-03 20:17:53 +00:00
|
|
|
model_list = sorted(predefined_models.keys())
|
|
|
|
if len(model_list) > 0:
|
|
|
|
max_width = max([len(x) for x in model_list])
|
|
|
|
columns = window_width // (max_width+6) # 6 characters for "[x] " and padding
|
|
|
|
columns = min(len(model_list),columns) or 1
|
|
|
|
prompt = install_prompt or f"Select the desired {model_type} models to install. Unchecked models will be purged from disk."
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
widgets.update(
|
|
|
|
models_selected = self.add_widget_intelligent(
|
|
|
|
MultiSelectColumns,
|
|
|
|
columns=columns,
|
|
|
|
name=f"Install {model_type} Models",
|
|
|
|
values=model_list,
|
|
|
|
value=[
|
|
|
|
model_list.index(x)
|
|
|
|
for x in model_list
|
|
|
|
if predefined_models[x]
|
|
|
|
],
|
|
|
|
max_height=len(model_list)//columns + 1,
|
|
|
|
relx=4,
|
|
|
|
scroll_exit=True,
|
|
|
|
)
|
2023-06-02 04:40:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.nextrely += 1
|
|
|
|
widgets.update(
|
|
|
|
label2 = self.add_widget_intelligent(
|
|
|
|
npyscreen.TitleFixedText,
|
2023-06-03 20:17:53 +00:00
|
|
|
name="Additional URLs or HuggingFace repo_ids to install (Space separated. Use shift-control-V to paste):",
|
2023-06-02 04:40:15 +00:00
|
|
|
relx=4,
|
|
|
|
color='CONTROL',
|
|
|
|
editable=False,
|
|
|
|
scroll_exit=True
|
|
|
|
)
|
2023-05-30 17:49:43 +00:00
|
|
|
)
|
2023-06-01 04:31:46 +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,
|
|
|
|
max_height=4,
|
|
|
|
scroll_exit=True,
|
|
|
|
editable=True,
|
|
|
|
relx=4
|
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 ###
|
|
|
|
def add_diffusers_widgets(self,
|
|
|
|
predefined_models: dict[str,bool],
|
|
|
|
model_type: str='Diffusers',
|
|
|
|
window_width: int=120,
|
|
|
|
)->dict[str,npyscreen.widget]:
|
|
|
|
'''Similar to add_model_widgets() but adds some additional widgets at the bottom
|
|
|
|
to support the autoload directory'''
|
|
|
|
widgets = self.add_model_widgets(
|
|
|
|
predefined_models,
|
|
|
|
'Diffusers',
|
|
|
|
window_width,
|
|
|
|
install_prompt="Additional diffusers models already installed. Uncheck to purge from disk.",
|
|
|
|
)
|
|
|
|
|
|
|
|
self.nextrely += 2
|
2023-06-02 04:40:15 +00:00
|
|
|
widgets.update(
|
2023-06-03 20:17:53 +00:00
|
|
|
purge_deleted = self.add_widget_intelligent(
|
|
|
|
npyscreen.Checkbox,
|
|
|
|
name="Purge unchecked diffusers models from disk",
|
|
|
|
value=False,
|
2023-06-02 04:40:15 +00:00
|
|
|
scroll_exit=True,
|
|
|
|
relx=4,
|
|
|
|
)
|
2023-02-19 21:08:58 +00:00
|
|
|
)
|
2023-06-03 20:17:53 +00:00
|
|
|
label = "Directory to scan for models to automatically import (<tab> autocompletes):"
|
|
|
|
self.nextrely += 2
|
2023-06-02 21:20:50 +00:00
|
|
|
widgets.update(
|
2023-06-03 20:17:53 +00:00
|
|
|
autoload_directory = self.add_widget_intelligent(
|
2023-06-04 15:27:44 +00:00
|
|
|
# npyscreen.TitleFilename,
|
|
|
|
FileBox,
|
|
|
|
max_height=3,
|
2023-06-03 20:17:53 +00:00
|
|
|
name=label,
|
|
|
|
select_dir=True,
|
|
|
|
must_exist=True,
|
|
|
|
use_two_lines=False,
|
|
|
|
labelColor="DANGER",
|
|
|
|
begin_entry_at=len(label)+1,
|
2023-06-02 21:20:50 +00:00
|
|
|
scroll_exit=True,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
widgets.update(
|
2023-06-03 20:17:53 +00:00
|
|
|
autoscan_on_startup = self.add_widget_intelligent(
|
|
|
|
npyscreen.Checkbox,
|
|
|
|
name="Scan and import from this directory each time InvokeAI starts",
|
|
|
|
value=False,
|
2023-06-02 04:40:15 +00:00
|
|
|
relx=4,
|
|
|
|
scroll_exit=True,
|
|
|
|
)
|
|
|
|
)
|
2023-06-03 20:17:53 +00:00
|
|
|
widgets['purge_deleted'].when_value_edited = lambda: self.sync_purge_buttons(widgets['purge_deleted'])
|
2023-06-02 04:40:15 +00:00
|
|
|
return widgets
|
2023-02-21 16:47:41 +00:00
|
|
|
|
2023-06-03 20:17:53 +00:00
|
|
|
def sync_purge_buttons(self,checkbox):
|
|
|
|
value = checkbox.value
|
|
|
|
self.starter_diffusers_models['purge_deleted'].value = value
|
|
|
|
self.diffusers_models['purge_deleted'].value = value
|
|
|
|
|
2023-02-15 06:07:39 +00:00
|
|
|
def resize(self):
|
|
|
|
super().resize()
|
2023-06-03 20:17:53 +00:00
|
|
|
if (s := self.starter_diffusers_models.get("models_selected")):
|
2023-06-02 04:40:15 +00:00
|
|
|
s.values = self._get_starter_model_labels()
|
2023-02-21 16:47:41 +00:00
|
|
|
|
2023-06-01 04:31:46 +00:00
|
|
|
def _toggle_tables(self, value=None):
|
2023-06-01 04:45:07 +00:00
|
|
|
selected_tab = value[0]
|
2023-06-01 04:31:46 +00:00
|
|
|
widgets = [
|
2023-06-03 20:17:53 +00:00
|
|
|
self.starter_diffusers_models,
|
2023-06-02 04:40:15 +00:00
|
|
|
self.diffusers_models,
|
|
|
|
self.controlnet_models,
|
|
|
|
self.lora_models,
|
|
|
|
self.ti_models,
|
2023-06-01 04:31:46 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
for group in widgets:
|
2023-06-02 04:40:15 +00:00
|
|
|
for k,v in group.items():
|
|
|
|
v.hidden = True
|
2023-06-03 20:17:53 +00:00
|
|
|
v.editable = False
|
2023-06-02 04:40:15 +00:00
|
|
|
for k,v in widgets[selected_tab].items():
|
|
|
|
v.hidden = False
|
2023-06-03 20:17:53 +00:00
|
|
|
if not isinstance(v,(npyscreen.FixedText, npyscreen.TitleFixedText, CenteredTitleText)):
|
|
|
|
v.editable = True
|
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-02-21 19:12:57 +00:00
|
|
|
def _get_starter_model_labels(self) -> List[str]:
|
2023-02-23 00:18:07 +00:00
|
|
|
window_width, window_height = get_terminal_size()
|
2023-02-14 21:32:54 +00:00
|
|
|
label_width = 25
|
|
|
|
checkbox_width = 4
|
|
|
|
spacing_width = 2
|
|
|
|
description_width = window_width - label_width - checkbox_width - spacing_width
|
2023-06-03 20:17:53 +00:00
|
|
|
im = self.starter_models
|
2023-02-16 05:34:15 +00:00
|
|
|
names = self.starter_model_list
|
2023-02-21 19:12:57 +00:00
|
|
|
descriptions = [
|
|
|
|
im[x].description[0 : description_width - 3] + "..."
|
|
|
|
if len(im[x].description) > description_width
|
|
|
|
else im[x].description
|
|
|
|
for x in names
|
|
|
|
]
|
2023-02-14 21:32:54 +00:00
|
|
|
return [
|
2023-02-21 19:12:57 +00:00
|
|
|
f"%-{label_width}s %s" % (names[x], descriptions[x])
|
|
|
|
for x in range(0, len(names))
|
2023-02-14 21:32:54 +00:00
|
|
|
]
|
2023-02-13 04:59:18 +00:00
|
|
|
|
2023-05-30 17:49:43 +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-06-03 02:24:46 +00:00
|
|
|
def on_execute(self):
|
2023-06-03 20:17:53 +00:00
|
|
|
self.monitor.entry_widget.buffer(['Processing...'],scroll_end=True)
|
2023-06-03 02:24:46 +00:00
|
|
|
self.marshall_arguments()
|
|
|
|
app = self.parentApp
|
2023-06-05 02:00:11 +00:00
|
|
|
self.ok_button.hidden = True
|
2023-06-03 02:24:46 +00:00
|
|
|
self.display()
|
|
|
|
|
|
|
|
# for communication with the subprocess
|
|
|
|
parent_conn, child_conn = Pipe()
|
|
|
|
p = Process(
|
|
|
|
target = process_and_execute,
|
|
|
|
kwargs=dict(
|
2023-06-04 18:55:51 +00:00
|
|
|
opt = app.program_opts,
|
2023-06-03 02:24:46 +00:00
|
|
|
selections = app.user_selections,
|
|
|
|
conn_out = child_conn,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
p.start()
|
|
|
|
child_conn.close()
|
|
|
|
self.subprocess_connection = parent_conn
|
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 = p
|
|
|
|
app.user_selections = UserSelections()
|
2023-06-03 02:24:46 +00:00
|
|
|
# process_and_execute(app.opt, app.user_selections)
|
|
|
|
|
2023-02-19 21:08:58 +00:00
|
|
|
def on_back(self):
|
|
|
|
self.parentApp.switchFormPrevious()
|
2023-02-15 06:07:39 +00:00
|
|
|
self.editing = False
|
|
|
|
|
2023-02-19 21:08:58 +00:00
|
|
|
def on_cancel(self):
|
2023-06-02 21:20:50 +00:00
|
|
|
self.parentApp.setNextForm(None)
|
|
|
|
self.parentApp.user_cancelled = True
|
|
|
|
self.editing = False
|
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 on_done(self):
|
|
|
|
self.marshall_arguments()
|
|
|
|
self.parentApp.setNextForm(None)
|
|
|
|
self.parentApp.user_cancelled = False
|
|
|
|
self.editing = False
|
2023-02-19 21:08:58 +00:00
|
|
|
|
2023-06-04 15:27:44 +00:00
|
|
|
########## This routine monitors the child process that is performing model installation and removal #####
|
2023-06-03 02:24:46 +00:00
|
|
|
def while_waiting(self):
|
2023-06-04 15:27:44 +00:00
|
|
|
'''Called during idle periods. Main task is to update the Log Messages box with messages
|
|
|
|
from the child process that does the actual installation/removal'''
|
|
|
|
c = self.subprocess_connection
|
|
|
|
if not c:
|
|
|
|
return
|
|
|
|
|
2023-06-03 20:17:53 +00:00
|
|
|
monitor_widget = self.monitor.entry_widget
|
2023-06-04 15:27:44 +00:00
|
|
|
while c.poll():
|
|
|
|
try:
|
|
|
|
data = c.recv_bytes().decode('utf-8')
|
|
|
|
data.strip('\n')
|
|
|
|
|
|
|
|
# processing child is requesting user input to select the
|
|
|
|
# right configuration file
|
|
|
|
if data.startswith('*need v2 config'):
|
|
|
|
_,model_path,*_ = data.split(":",2)
|
|
|
|
self._return_v2_config(model_path)
|
|
|
|
|
|
|
|
# processing child is done
|
|
|
|
elif data=='*done*':
|
|
|
|
self._close_subprocess_and_regenerate_form()
|
|
|
|
break
|
|
|
|
|
|
|
|
# update the log message box
|
|
|
|
else:
|
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
|
|
|
data=make_printable(data)
|
|
|
|
data=data.replace('[A','')
|
2023-06-04 15:27:44 +00:00
|
|
|
monitor_widget.buffer(
|
|
|
|
textwrap.wrap(data,
|
|
|
|
width=monitor_widget.width,
|
|
|
|
subsequent_indent=' ',
|
|
|
|
),
|
|
|
|
scroll_end=True
|
|
|
|
)
|
|
|
|
self.display()
|
|
|
|
except (EOFError,OSError):
|
|
|
|
self.subprocess_connection = None
|
|
|
|
|
|
|
|
def _return_v2_config(self,model_path: str):
|
|
|
|
c = self.subprocess_connection
|
|
|
|
model_name = Path(model_path).name
|
|
|
|
message = select_stable_diffusion_config_file(model_name=model_name)
|
|
|
|
c.send_bytes(message.encode('utf-8'))
|
|
|
|
|
|
|
|
def _close_subprocess_and_regenerate_form(self):
|
|
|
|
app = self.parentApp
|
|
|
|
self.subprocess_connection.close()
|
|
|
|
self.subprocess_connection = None
|
|
|
|
self.monitor.entry_widget.buffer(['** Action Complete **'])
|
|
|
|
self.display()
|
|
|
|
# rebuild the form, saving log messages
|
|
|
|
saved_messages = self.monitor.entry_widget.values
|
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
|
|
|
multipage = self.multipage
|
2023-06-04 15:27:44 +00:00
|
|
|
app.main_form = app.addForm(
|
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
|
|
|
"MAIN", addModelsForm, name="Install Stable Diffusion Models", multipage=multipage,
|
2023-06-04 15:27:44 +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
|
|
|
app.switchForm("MAIN")
|
2023-06-04 15:27:44 +00:00
|
|
|
app.main_form.monitor.entry_widget.values = saved_messages
|
|
|
|
app.main_form.monitor.entry_widget.buffer([''],scroll_end=True)
|
2023-06-03 02:24:46 +00:00
|
|
|
|
2023-06-04 15:27:44 +00:00
|
|
|
###############################################################
|
|
|
|
|
2023-06-03 20:17:53 +00:00
|
|
|
def list_additional_diffusers_models(self,
|
|
|
|
manager: ModelManager,
|
|
|
|
starters:dict
|
|
|
|
)->dict[str,bool]:
|
|
|
|
'''Return a dict of all the currently installed models that are not on the starter list'''
|
|
|
|
model_info = manager.list_models()
|
|
|
|
additional_models = {
|
|
|
|
x:True for x in model_info \
|
|
|
|
if model_info[x]['format']=='diffusers' \
|
|
|
|
and x not in starters
|
|
|
|
}
|
|
|
|
return additional_models
|
|
|
|
|
2023-02-15 06:07:39 +00:00
|
|
|
def marshall_arguments(self):
|
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-02-19 18:12:05 +00:00
|
|
|
# we're using a global here rather than storing the result in the parentapp
|
|
|
|
# due to some bug in npyscreen that is causing attributes to be lost
|
|
|
|
selections = self.parentApp.user_selections
|
|
|
|
|
2023-06-03 20:17:53 +00:00
|
|
|
# Starter models to install/remove
|
2023-06-02 04:40:15 +00:00
|
|
|
starter_models = dict(
|
|
|
|
map(
|
|
|
|
lambda x: (self.starter_model_list[x], True),
|
2023-06-03 20:17:53 +00:00
|
|
|
self.starter_diffusers_models['models_selected'].value,
|
2023-02-21 19:12:57 +00:00
|
|
|
)
|
2023-06-02 04:40:15 +00:00
|
|
|
)
|
2023-06-03 20:17:53 +00:00
|
|
|
selections.purge_deleted_models = self.starter_diffusers_models['purge_deleted'].value or \
|
|
|
|
self.diffusers_models['purge_deleted'].value
|
2023-05-30 04:38:37 +00:00
|
|
|
|
|
|
|
selections.install_models = [x for x in starter_models if x not in self.existing_models]
|
|
|
|
selections.remove_models = [x for x in self.starter_model_list if x in self.existing_models and x not in starter_models]
|
|
|
|
|
2023-06-03 20:17:53 +00:00
|
|
|
# "More" models
|
|
|
|
selections.import_model_paths = self.diffusers_models['download_ids'].value.split()
|
|
|
|
if diffusers_selected := self.diffusers_models.get('models_selected'):
|
|
|
|
selections.remove_models.extend([x
|
|
|
|
for x in diffusers_selected.values
|
|
|
|
if self.installed_diffusers_models[x]
|
|
|
|
and diffusers_selected.values.index(x) not in diffusers_selected.value
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2023-06-02 21:20:50 +00:00
|
|
|
# TODO: REFACTOR THIS REPETITIVE CODE
|
2023-06-03 20:17:53 +00:00
|
|
|
if cn_models_selected := self.controlnet_models.get('models_selected'):
|
|
|
|
selections.install_cn_models = [cn_models_selected.values[x]
|
|
|
|
for x in cn_models_selected.value
|
|
|
|
if not self.installed_cn_models[cn_models_selected.values[x]]
|
|
|
|
]
|
|
|
|
selections.remove_cn_models = [x
|
|
|
|
for x in cn_models_selected.values
|
|
|
|
if self.installed_cn_models[x]
|
|
|
|
and cn_models_selected.values.index(x) not in cn_models_selected.value
|
|
|
|
]
|
2023-06-02 04:40:15 +00:00
|
|
|
if (additional_cns := self.controlnet_models['download_ids'].value.split()):
|
2023-05-30 17:49:43 +00:00
|
|
|
valid_cns = [x for x in additional_cns if '/' in x]
|
|
|
|
selections.install_cn_models.extend(valid_cns)
|
2023-02-15 06:07:39 +00:00
|
|
|
|
2023-06-02 04:40:15 +00:00
|
|
|
# same thing, for LoRAs
|
2023-06-03 20:17:53 +00:00
|
|
|
if loras_selected := self.lora_models.get('models_selected'):
|
|
|
|
selections.install_lora_models = [loras_selected.values[x]
|
|
|
|
for x in loras_selected.value
|
|
|
|
if not self.installed_lora_models[loras_selected.values[x]]
|
|
|
|
]
|
|
|
|
selections.remove_lora_models = [x
|
|
|
|
for x in loras_selected.values
|
|
|
|
if self.installed_lora_models[x]
|
|
|
|
and loras_selected.values.index(x) not in loras_selected.value
|
|
|
|
]
|
2023-06-02 04:40:15 +00:00
|
|
|
if (additional_loras := self.lora_models['download_ids'].value.split()):
|
2023-06-02 21:20:50 +00:00
|
|
|
selections.install_lora_models.extend(additional_loras)
|
|
|
|
|
|
|
|
# same thing, for TIs
|
|
|
|
# TODO: refactor
|
2023-06-03 20:17:53 +00:00
|
|
|
if tis_selected := self.ti_models.get('models_selected'):
|
|
|
|
selections.install_ti_models = [tis_selected.values[x]
|
|
|
|
for x in tis_selected.value
|
|
|
|
if not self.installed_ti_models[tis_selected.values[x]]
|
|
|
|
]
|
|
|
|
selections.remove_ti_models = [x
|
|
|
|
for x in tis_selected.values
|
|
|
|
if self.installed_ti_models[x]
|
|
|
|
and tis_selected.values.index(x) not in tis_selected.value
|
|
|
|
]
|
2023-06-02 21:20:50 +00:00
|
|
|
|
|
|
|
if (additional_tis := self.ti_models['download_ids'].value.split()):
|
|
|
|
selections.install_ti_models.extend(additional_tis)
|
|
|
|
|
2023-02-15 06:07:39 +00:00
|
|
|
# load directory and whether to scan on startup
|
2023-06-02 04:40:15 +00:00
|
|
|
selections.scan_directory = self.diffusers_models['autoload_directory'].value
|
|
|
|
selections.autoscan_on_startup = self.diffusers_models['autoscan_on_startup'].value
|
2023-02-15 06:07:39 +00:00
|
|
|
|
2023-02-21 19:12:57 +00:00
|
|
|
|
2023-02-14 05:02:19 +00:00
|
|
|
class AddModelApplication(npyscreen.NPSAppManaged):
|
2023-06-03 02:24:46 +00:00
|
|
|
def __init__(self,opt):
|
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-01 04:31:46 +00:00
|
|
|
self.user_selections = UserSelections()
|
2023-02-13 04:59:18 +00:00
|
|
|
|
|
|
|
def onStart(self):
|
|
|
|
npyscreen.setTheme(npyscreen.Themes.DefaultTheme)
|
2023-02-19 18:12:05 +00:00
|
|
|
self.main_form = self.addForm(
|
2023-06-04 15:27:44 +00:00
|
|
|
"MAIN", addModelsForm, name="Install Stable Diffusion Models", cycle_widgets=True,
|
2023-02-13 04:59:18 +00:00
|
|
|
)
|
|
|
|
|
2023-06-03 02:24:46 +00:00
|
|
|
class StderrToMessage():
|
|
|
|
def __init__(self, connection: Connection):
|
|
|
|
self.connection = connection
|
2023-03-03 06:02:00 +00:00
|
|
|
|
2023-06-03 02:24:46 +00:00
|
|
|
def write(self, data:str):
|
|
|
|
self.connection.send_bytes(data.encode('utf-8'))
|
|
|
|
|
|
|
|
def flush(self):
|
|
|
|
pass
|
2023-06-04 15:27:44 +00:00
|
|
|
|
|
|
|
# --------------------------------------------------------
|
|
|
|
def ask_user_for_config_file(model_path: Path,
|
|
|
|
tui_conn: Connection=None
|
|
|
|
)->Path:
|
|
|
|
if tui_conn:
|
2023-06-06 21:21:50 +00:00
|
|
|
logger.debug('Waiting for user response...')
|
2023-06-04 15:27:44 +00:00
|
|
|
return _ask_user_for_cf_tui(model_path, tui_conn)
|
|
|
|
else:
|
|
|
|
return _ask_user_for_cf_cmdline(model_path)
|
|
|
|
|
|
|
|
def _ask_user_for_cf_cmdline(model_path):
|
|
|
|
choices = [
|
2023-06-06 21:21:50 +00:00
|
|
|
config.legacy_conf_path / x
|
2023-06-04 15:27:44 +00:00
|
|
|
for x in ['v2-inference.yaml','v2-inference-v.yaml']
|
|
|
|
]
|
2023-06-06 21:21:50 +00:00
|
|
|
choices.extend([None])
|
2023-06-04 15:27:44 +00:00
|
|
|
print(
|
|
|
|
f"""
|
|
|
|
Please select the type of the V2 checkpoint named {model_path.name}:
|
|
|
|
[1] A Stable Diffusion v2.x base model (512 pixels; there should be no 'parameterization:' line in its yaml file)
|
|
|
|
[2] A Stable Diffusion v2.x v-predictive model (768 pixels; look for a 'parameterization: "v"' line in its yaml file)
|
2023-06-06 21:21:50 +00:00
|
|
|
[3] Skip this model and come back later.
|
2023-06-04 15:27:44 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
choice = None
|
|
|
|
ok = False
|
|
|
|
while not ok:
|
|
|
|
try:
|
|
|
|
choice = input('select> ').strip()
|
|
|
|
choice = choices[int(choice)-1]
|
|
|
|
ok = True
|
|
|
|
except (ValueError, IndexError):
|
|
|
|
print(f'{choice} is not a valid choice')
|
|
|
|
except EOFError:
|
|
|
|
return
|
|
|
|
return choice
|
|
|
|
|
|
|
|
def _ask_user_for_cf_tui(model_path: Path, tui_conn: Connection)->Path:
|
|
|
|
try:
|
|
|
|
tui_conn.send_bytes(f'*need v2 config for:{model_path}'.encode('utf-8'))
|
|
|
|
# note that we don't do any status checking here
|
|
|
|
response = tui_conn.recv_bytes().decode('utf-8')
|
|
|
|
if response is None:
|
|
|
|
return None
|
|
|
|
elif response == 'epsilon':
|
|
|
|
return config.legacy_conf_path / 'v2-inference.yaml'
|
|
|
|
elif response == 'v':
|
|
|
|
return config.legacy_conf_path / 'v2-inference-v.yaml'
|
2023-06-06 21:21:50 +00:00
|
|
|
elif response == 'abort':
|
|
|
|
logger.info('Conversion aborted')
|
|
|
|
return None
|
2023-06-04 15:27:44 +00:00
|
|
|
else:
|
|
|
|
return Path(response)
|
|
|
|
except:
|
|
|
|
return None
|
2023-06-03 02:24:46 +00:00
|
|
|
|
2023-02-16 05:34:15 +00:00
|
|
|
# --------------------------------------------------------
|
2023-06-03 02:24:46 +00:00
|
|
|
def process_and_execute(opt: Namespace,
|
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
|
|
|
selections: UserSelections,
|
2023-06-03 02:24:46 +00:00
|
|
|
conn_out: Connection=None,
|
|
|
|
):
|
|
|
|
# set up so that stderr is sent to conn_out
|
|
|
|
if conn_out:
|
|
|
|
translator = StderrToMessage(conn_out)
|
|
|
|
sys.stderr = translator
|
|
|
|
sys.stdout = translator
|
2023-06-04 15:27:44 +00:00
|
|
|
logger = InvokeAILogger.getLogger()
|
|
|
|
logger.handlers.clear()
|
|
|
|
logger.addHandler(logging.StreamHandler(translator))
|
2023-06-03 02:24:46 +00:00
|
|
|
|
2023-05-30 04:38:37 +00:00
|
|
|
models_to_install = selections.install_models
|
|
|
|
models_to_remove = selections.remove_models
|
2023-02-19 18:12:05 +00:00
|
|
|
directory_to_scan = selections.scan_directory
|
|
|
|
scan_at_startup = selections.autoscan_on_startup
|
|
|
|
potential_models_to_install = selections.import_model_paths
|
2023-06-04 15:27:44 +00:00
|
|
|
|
2023-05-30 17:49:43 +00:00
|
|
|
install_requested_models(
|
2023-06-01 04:31:46 +00:00
|
|
|
diffusers = ModelInstallList(models_to_install, models_to_remove),
|
|
|
|
controlnet = ModelInstallList(selections.install_cn_models, selections.remove_cn_models),
|
2023-06-02 04:40:15 +00:00
|
|
|
lora = ModelInstallList(selections.install_lora_models, selections.remove_lora_models),
|
2023-06-02 21:20:50 +00:00
|
|
|
ti = ModelInstallList(selections.install_ti_models, selections.remove_ti_models),
|
2023-05-30 17:49:43 +00:00
|
|
|
scan_directory=Path(directory_to_scan) if directory_to_scan else None,
|
|
|
|
external_models=potential_models_to_install,
|
|
|
|
scan_at_startup=scan_at_startup,
|
|
|
|
precision="float32"
|
|
|
|
if opt.full_precision
|
|
|
|
else choose_precision(torch.device(choose_torch_device())),
|
|
|
|
purge_deleted=selections.purge_deleted_models,
|
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
|
|
|
config_file_path=Path(opt.config_file) if opt.config_file else config.model_conf_path,
|
2023-06-04 15:27:44 +00:00
|
|
|
model_config_file_callback = lambda x: ask_user_for_config_file(x,conn_out)
|
2023-05-30 17:49:43 +00:00
|
|
|
)
|
2023-02-21 19:12:57 +00:00
|
|
|
|
2023-06-03 02:24:46 +00:00
|
|
|
if conn_out:
|
|
|
|
conn_out.send_bytes('*done*'.encode('utf-8'))
|
|
|
|
conn_out.close()
|
|
|
|
|
2023-02-21 19:12:57 +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 do_listings(opt)->bool:
|
|
|
|
"""List installed models of various sorts, and return
|
|
|
|
True if any were requested."""
|
|
|
|
model_manager = ModelManager(config.model_conf_path)
|
|
|
|
if opt.list_models == 'diffusers':
|
|
|
|
print("Diffuser models:")
|
|
|
|
model_manager.print_models()
|
|
|
|
elif opt.list_models == 'controlnets':
|
|
|
|
print("Installed Controlnet Models:")
|
|
|
|
cnm = model_manager.list_controlnet_models()
|
|
|
|
print(textwrap.indent("\n".join([x for x in cnm if cnm[x]]),prefix=' '))
|
|
|
|
elif opt.list_models == 'loras':
|
|
|
|
print("Installed LoRA/LyCORIS Models:")
|
|
|
|
cnm = model_manager.list_lora_models()
|
|
|
|
print(textwrap.indent("\n".join([x for x in cnm if cnm[x]]),prefix=' '))
|
|
|
|
elif opt.list_models == 'tis':
|
|
|
|
print("Installed Textual Inversion Embeddings:")
|
|
|
|
cnm = model_manager.list_ti_models()
|
|
|
|
print(textwrap.indent("\n".join([x for x in cnm if cnm[x]]),prefix=' '))
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2023-02-13 04:59:18 +00:00
|
|
|
# --------------------------------------------------------
|
|
|
|
def select_and_download_models(opt: Namespace):
|
2023-02-21 19:12:57 +00:00
|
|
|
precision = (
|
|
|
|
"float32"
|
|
|
|
if opt.full_precision
|
|
|
|
else choose_precision(torch.device(choose_torch_device()))
|
|
|
|
)
|
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 do_listings(opt):
|
|
|
|
pass
|
|
|
|
elif opt.diffusers or opt.controlnets or opt.textual_inversions or opt.loras:
|
|
|
|
action = 'remove_models' if opt.delete else 'install_models'
|
|
|
|
diffusers_args = {'diffusers':ModelInstallList(remove_models=opt.diffusers or [])} \
|
|
|
|
if opt.delete \
|
|
|
|
else {'external_models':opt.diffusers or []}
|
|
|
|
install_requested_models(
|
|
|
|
**diffusers_args,
|
|
|
|
controlnet=ModelInstallList(**{action:opt.controlnets or []}),
|
|
|
|
ti=ModelInstallList(**{action:opt.textual_inversions or []}),
|
|
|
|
lora=ModelInstallList(**{action:opt.loras or []}),
|
|
|
|
precision=precision,
|
|
|
|
purge_deleted=True,
|
|
|
|
model_config_file_callback=lambda x: ask_user_for_config_file(x),
|
|
|
|
)
|
|
|
|
elif opt.default_only:
|
2023-02-17 02:37:50 +00:00
|
|
|
install_requested_models(
|
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
|
|
|
diffusers=ModelInstallList(install_models=default_dataset()),
|
2023-02-21 19:12:57 +00:00
|
|
|
precision=precision,
|
2023-02-19 21:08:58 +00:00
|
|
|
)
|
|
|
|
elif opt.yes_to_all:
|
|
|
|
install_requested_models(
|
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
|
|
|
diffusers=ModelInstallList(install_models=recommended_datasets()),
|
2023-02-21 19:12:57 +00:00
|
|
|
precision=precision,
|
2023-02-17 02:37:50 +00:00
|
|
|
)
|
2023-02-13 04:59:18 +00:00
|
|
|
else:
|
2023-06-03 02:24:46 +00:00
|
|
|
# needed because the torch library is loaded, even though we don't use it
|
|
|
|
torch.multiprocessing.set_start_method("spawn")
|
2023-06-06 19:17:15 +00:00
|
|
|
|
|
|
|
# the third argument is needed in the Windows 11 environment in
|
|
|
|
# order to launch and resize a console window running this program
|
|
|
|
set_min_terminal_size(MIN_COLS, MIN_LINES,'invokeai-model-install')
|
2023-06-03 02:24:46 +00:00
|
|
|
installApp = AddModelApplication(opt)
|
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()
|
2023-06-07 11:23:14 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(str(e))
|
|
|
|
if hasattr(installApp,'main_form'):
|
|
|
|
form = installApp.main_form
|
|
|
|
if form.subprocess and form.subprocess.is_alive():
|
|
|
|
logger.info('Terminating subprocesses')
|
|
|
|
form.subprocess.terminate()
|
|
|
|
form.subprocess = None
|
2023-06-02 21:20:50 +00:00
|
|
|
process_and_execute(opt, installApp.user_selections)
|
2023-02-21 19:12:57 +00:00
|
|
|
|
2023-02-13 04:59:18 +00:00
|
|
|
# -------------------------------------
|
|
|
|
def main():
|
|
|
|
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(
|
|
|
|
"--diffusers",
|
|
|
|
nargs="*",
|
|
|
|
help="List of URLs or repo_ids of diffusers to install/delete",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--loras",
|
|
|
|
nargs="*",
|
|
|
|
help="List of URLs or repo_ids of LoRA/LyCORIS models to install/delete",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--controlnets",
|
|
|
|
nargs="*",
|
|
|
|
help="List of URLs or repo_ids of controlnet models to install/delete",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--textual-inversions",
|
|
|
|
nargs="*",
|
|
|
|
help="List of URLs or repo_ids of textual inversion embeddings to install/delete",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--delete",
|
|
|
|
action="store_true",
|
|
|
|
help="Delete models listed on command line rather than installing them",
|
|
|
|
)
|
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",
|
|
|
|
help="only install the default 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
|
|
|
parser.add_argument(
|
|
|
|
"--list-models",
|
|
|
|
choices=["diffusers","loras","controlnets","tis"],
|
|
|
|
help="list installed models",
|
|
|
|
)
|
2023-02-13 04:59:18 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--config_file",
|
|
|
|
"-c",
|
|
|
|
dest="config_file",
|
|
|
|
type=str,
|
|
|
|
default=None,
|
|
|
|
help="path to configuration file to create",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--root_dir",
|
|
|
|
dest="root",
|
|
|
|
type=str,
|
|
|
|
default=None,
|
|
|
|
help="path to root of install directory",
|
|
|
|
)
|
|
|
|
opt = parser.parse_args()
|
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
|
|
|
|
|
|
|
invoke_args = []
|
|
|
|
if opt.root:
|
|
|
|
invoke_args.extend(['--root',opt.root])
|
|
|
|
if opt.full_precision:
|
|
|
|
invoke_args.extend(['--precision','float32'])
|
|
|
|
config.parse_args(invoke_args)
|
2023-05-30 04:38:37 +00:00
|
|
|
|
2023-05-22 21:51:47 +00:00
|
|
|
if not (config.root_dir / config.conf_path.parent).exists():
|
2023-04-29 13:43:40 +00:00
|
|
|
logger.info(
|
2023-04-19 00:49:00 +00:00
|
|
|
"Your InvokeAI root directory is not set up. Calling invokeai-configure."
|
2023-02-21 19:12:57 +00:00
|
|
|
)
|
2023-03-03 06:02:00 +00:00
|
|
|
from invokeai.frontend.install 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-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-29 13:43:40 +00:00
|
|
|
logger.error(
|
2023-04-19 00:49:00 +00:00
|
|
|
"Insufficient vertical space for the interface. Please make your window taller and try again"
|
2023-02-14 21:32:54 +00:00
|
|
|
)
|
2023-02-21 19:12:57 +00:00
|
|
|
elif 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
|
|
|
)
|
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-03-03 06:02:00 +00:00
|
|
|
|
2023-02-13 04:59:18 +00:00
|
|
|
# -------------------------------------
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|