Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions invokeai/backend/install/invokeai_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

# TO DO - Move all the frontend code into invokeai.frontend.install
from invokeai.frontend.install.widgets import (
SingleSelectColumns,
SingleSelectColumnsSimple,
MultiSelectColumns,
CenteredButtonPress,
FileBox,
Expand Down Expand Up @@ -354,7 +354,6 @@ def create(self):
device = old_opts.device
attention_type = old_opts.attention_type
attention_slice_size = old_opts.attention_slice_size

self.nextrely += 1
self.add_widget_intelligent(
npyscreen.TitleFixedText,
Expand Down Expand Up @@ -385,7 +384,7 @@ def create(self):
)
self.nextrely -= 2
self.precision = self.add_widget_intelligent(
SingleSelectColumns,
SingleSelectColumnsSimple,
columns=len(PRECISION_CHOICES),
name="Precision",
values=PRECISION_CHOICES,
Expand All @@ -406,10 +405,10 @@ def create(self):
)
self.nextrely -= 2
self.device = self.add_widget_intelligent(
SingleSelectColumns,
SingleSelectColumnsSimple,
columns=len(DEVICE_CHOICES),
values=DEVICE_CHOICES,
value=DEVICE_CHOICES.index(device),
value=[DEVICE_CHOICES.index(device)],
begin_entry_at=3,
relx=30,
max_height=2,
Expand All @@ -426,10 +425,10 @@ def create(self):
)
self.nextrely -= 2
self.attention_type = self.add_widget_intelligent(
SingleSelectColumns,
SingleSelectColumnsSimple,
columns=len(ATTENTION_CHOICES),
values=ATTENTION_CHOICES,
value=ATTENTION_CHOICES.index(attention_type),
value=[ATTENTION_CHOICES.index(attention_type)],
begin_entry_at=3,
max_height=2,
relx=30,
Expand All @@ -448,17 +447,16 @@ def create(self):
)
self.nextrely -= 2
self.attention_slice_size = self.add_widget_intelligent(
SingleSelectColumns,
SingleSelectColumnsSimple,
columns=len(ATTENTION_SLICE_CHOICES),
values=ATTENTION_SLICE_CHOICES,
value=ATTENTION_SLICE_CHOICES.index(attention_slice_size),
value=[ATTENTION_SLICE_CHOICES.index(attention_slice_size)],
relx=30,
hidden=attention_type != "sliced",
max_height=2,
max_width=110,
scroll_exit=True,
)

self.add_widget_intelligent(
npyscreen.TitleFixedText,
name="Model RAM cache size (GB). Make this at least large enough to hold a single full model.",
Expand Down Expand Up @@ -707,8 +705,6 @@ def initialize_rootdir(root: Path, yes_to_all: bool = False):
path = dest / "core"
path.mkdir(parents=True, exist_ok=True)

maybe_create_models_yaml(root)


def maybe_create_models_yaml(root: Path):
models_yaml = root / "configs" / "models.yaml"
Expand Down
20 changes: 13 additions & 7 deletions invokeai/frontend/install/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class FloatTitleSlider(npyscreen.TitleText):


class SelectColumnBase:
"""Base class for selection widget arranged in columns."""

def make_contained_widgets(self):
self._my_widgets = []
column_width = self.width // self.columns
Expand Down Expand Up @@ -253,34 +255,38 @@ def on_mouse_double_click(self, cursor_line):
class SingleSelectWithChanged(npyscreen.SelectOne):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.on_changed = None

def h_select(self, ch):
super().h_select(ch)
if self.on_changed:
self.on_changed(self.value)


class SingleSelectColumns(SelectColumnBase, SingleSelectWithChanged):
class SingleSelectColumnsSimple(SelectColumnBase, SingleSelectWithChanged):
"""Row of radio buttons. Spacebar to select."""

def __init__(self, screen, columns: int = 1, values: list = [], **keywords):
self.columns = columns
self.value_cnt = len(values)
self.rows = math.ceil(self.value_cnt / self.columns)
self.on_changed = None
super().__init__(screen, values=values, **keywords)

def when_value_edited(self):
self.h_select(self.cursor_line)

def when_cursor_moved(self):
self.h_select(self.cursor_line)

def h_cursor_line_right(self, ch):
self.h_exit_down("bye bye")

def h_cursor_line_left(self, ch):
self.h_exit_up("bye bye")


class SingleSelectColumns(SingleSelectColumnsSimple):
"""Row of radio buttons. When tabbing over a selection, it is auto selected."""

def when_cursor_moved(self):
self.h_select(self.cursor_line)


class TextBoxInner(npyscreen.MultiLineEdit):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down