Skip to content

Commit 298ccda

Browse files
authored
fix the "import from directory" function in console model installer (#3211)
- This was inadvertently broken when we stopped supporting direct loading of checkpoint models. - Now fixed. - May fix #3209
2 parents d81584c + 203a715 commit 298ccda

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

ldm/invoke/config/model_install.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,6 @@ def create(self):
196196
scroll_exit=True,
197197
)
198198
self.nextrely += 1
199-
self.convert_models = self.add_widget_intelligent(
200-
npyscreen.TitleSelectOne,
201-
name="== CONVERT IMPORTED MODELS INTO DIFFUSERS==",
202-
values=["Keep original format", "Convert to diffusers"],
203-
value=0,
204-
begin_entry_at=4,
205-
max_height=4,
206-
hidden=True, # will appear when imported models box is edited
207-
scroll_exit=True,
208-
)
209199
self.cancel = self.add_widget_intelligent(
210200
npyscreen.ButtonPress,
211201
name="CANCEL",
@@ -240,8 +230,6 @@ def create(self):
240230
self.show_directory_fields.addVisibleWhenSelected(i)
241231

242232
self.show_directory_fields.when_value_edited = self._clear_scan_directory
243-
self.import_model_paths.when_value_edited = self._show_hide_convert
244-
self.autoload_directory.when_value_edited = self._show_hide_convert
245233

246234
def resize(self):
247235
super().resize()
@@ -252,13 +240,6 @@ def _clear_scan_directory(self):
252240
if not self.show_directory_fields.value:
253241
self.autoload_directory.value = ""
254242

255-
def _show_hide_convert(self):
256-
model_paths = self.import_model_paths.value or ""
257-
autoload_directory = self.autoload_directory.value or ""
258-
self.convert_models.hidden = (
259-
len(model_paths) == 0 and len(autoload_directory) == 0
260-
)
261-
262243
def _get_starter_model_labels(self) -> List[str]:
263244
window_width, window_height = get_terminal_size()
264245
label_width = 25
@@ -318,7 +299,6 @@ def marshall_arguments(self):
318299
.scan_directory: Path to a directory of models to scan and import
319300
.autoscan_on_startup: True if invokeai should scan and import at startup time
320301
.import_model_paths: list of URLs, repo_ids and file paths to import
321-
.convert_to_diffusers: if True, convert legacy checkpoints into diffusers
322302
"""
323303
# we're using a global here rather than storing the result in the parentapp
324304
# due to some bug in npyscreen that is causing attributes to be lost
@@ -354,7 +334,6 @@ def marshall_arguments(self):
354334

355335
# URLs and the like
356336
selections.import_model_paths = self.import_model_paths.value.split()
357-
selections.convert_to_diffusers = self.convert_models.value[0] == 1
358337

359338

360339
class AddModelApplication(npyscreen.NPSAppManaged):
@@ -367,7 +346,6 @@ def __init__(self):
367346
scan_directory=None,
368347
autoscan_on_startup=None,
369348
import_model_paths=None,
370-
convert_to_diffusers=None,
371349
)
372350

373351
def onStart(self):
@@ -387,15 +365,13 @@ def process_and_execute(opt: Namespace, selections: Namespace):
387365
directory_to_scan = selections.scan_directory
388366
scan_at_startup = selections.autoscan_on_startup
389367
potential_models_to_install = selections.import_model_paths
390-
convert_to_diffusers = selections.convert_to_diffusers
391368

392369
install_requested_models(
393370
install_initial_models=models_to_install,
394371
remove_models=models_to_remove,
395372
scan_directory=Path(directory_to_scan) if directory_to_scan else None,
396373
external_models=potential_models_to_install,
397374
scan_at_startup=scan_at_startup,
398-
convert_to_diffusers=convert_to_diffusers,
399375
precision="float32"
400376
if opt.full_precision
401377
else choose_precision(torch.device(choose_torch_device())),

ldm/invoke/config/model_install_backend.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def install_requested_models(
6868
scan_directory: Path = None,
6969
external_models: List[str] = None,
7070
scan_at_startup: bool = False,
71-
convert_to_diffusers: bool = False,
7271
precision: str = "float16",
7372
purge_deleted: bool = False,
7473
config_file_path: Path = None,
@@ -111,20 +110,20 @@ def install_requested_models(
111110
if len(external_models)>0:
112111
print("== INSTALLING EXTERNAL MODELS ==")
113112
for path_url_or_repo in external_models:
113+
print(f'DEBUG: path_url_or_repo = {path_url_or_repo}')
114114
try:
115115
model_manager.heuristic_import(
116116
path_url_or_repo,
117-
convert=convert_to_diffusers,
118117
config_file_callback=_pick_configuration_file,
119118
commit_to_conf=config_file_path
120119
)
121120
except KeyboardInterrupt:
122121
sys.exit(-1)
123-
except Exception:
124-
pass
122+
except Exception as e:
123+
print(f'An exception has occurred: {str(e)}')
125124

126125
if scan_at_startup and scan_directory.is_dir():
127-
argument = '--autoconvert' if convert_to_diffusers else '--autoimport'
126+
argument = '--autoconvert'
128127
initfile = Path(Globals.root, Globals.initfile)
129128
replacement = Path(Globals.root, f'{Globals.initfile}.new')
130129
directory = str(scan_directory).replace('\\','/')

0 commit comments

Comments
 (0)