@@ -158,10 +158,16 @@ def main():
158
158
except Exception as e :
159
159
report_model_error (opt , e )
160
160
161
+ # completer is the readline object
162
+ completer = get_completer (opt , models = gen .model_manager .list_models ())
163
+
161
164
# try to autoconvert new models
162
165
if path := opt .autoimport :
163
166
gen .model_manager .heuristic_import (
164
- str (path ), convert = False , commit_to_conf = opt .conf
167
+ str (path ),
168
+ convert = False ,
169
+ commit_to_conf = opt .conf ,
170
+ config_file_callback = lambda x : _pick_configuration_file (completer ,x ),
165
171
)
166
172
167
173
if path := opt .autoconvert :
@@ -180,7 +186,7 @@ def main():
180
186
)
181
187
182
188
try :
183
- main_loop (gen , opt )
189
+ main_loop (gen , opt , completer )
184
190
except KeyboardInterrupt :
185
191
print (
186
192
f'\n Goodbye!\n You can start InvokeAI again by running the "invoke.bat" (or "invoke.sh") script from { Globals .root } '
@@ -191,7 +197,7 @@ def main():
191
197
192
198
193
199
# TODO: main_loop() has gotten busy. Needs to be refactored.
194
- def main_loop (gen , opt ):
200
+ def main_loop (gen , opt , completer ):
195
201
"""prompt/read/execute loop"""
196
202
global infile
197
203
done = False
@@ -202,7 +208,6 @@ def main_loop(gen, opt):
202
208
# The readline completer reads history from the .dream_history file located in the
203
209
# output directory specified at the time of script launch. We do not currently support
204
210
# changing the history file midstream when the output directory is changed.
205
- completer = get_completer (opt , models = gen .model_manager .list_models ())
206
211
set_default_output_dir (opt , completer )
207
212
if gen .model :
208
213
add_embedding_terms (gen , completer )
@@ -661,17 +666,8 @@ def import_model(model_path: str, gen, opt, completer, convert=False):
661
666
model_name = model_name ,
662
667
description = model_desc ,
663
668
convert = convert ,
669
+ config_file_callback = lambda x : _pick_configuration_file (completer ,x ),
664
670
)
665
-
666
- if not imported_name :
667
- if config_file := _pick_configuration_file (completer ):
668
- imported_name = gen .model_manager .heuristic_import (
669
- model_path ,
670
- model_name = model_name ,
671
- description = model_desc ,
672
- convert = convert ,
673
- model_config_file = config_file ,
674
- )
675
671
if not imported_name :
676
672
print ("** Aborting import." )
677
673
return
@@ -687,14 +683,14 @@ def import_model(model_path: str, gen, opt, completer, convert=False):
687
683
completer .update_models (gen .model_manager .list_models ())
688
684
print (f">> { imported_name } successfully installed" )
689
685
690
- def _pick_configuration_file (completer )-> Path :
686
+ def _pick_configuration_file (completer , checkpoint_path : Path )-> Path :
691
687
print (
692
- """
693
- Please select the type of this model:
688
+ f """
689
+ Please select the type of the model at checkpoint { checkpoint_path } :
694
690
[1] A Stable Diffusion v1.x ckpt/safetensors model
695
691
[2] A Stable Diffusion v1.x inpainting ckpt/safetensors model
696
- [3] A Stable Diffusion v2.x base model (512 pixels)
697
- [4] A Stable Diffusion v2.x v-predictive model (768 pixels)
692
+ [3] A Stable Diffusion v2.x base model (512 pixels; there should be no 'parameterization:' line in its yaml file )
693
+ [4] A Stable Diffusion v2.x v-predictive model (768 pixels; look for a 'parameterization: "v"' line in its yaml file )
698
694
[5] Other (you will be prompted to enter the config file path)
699
695
[Q] I have no idea! Skip the import.
700
696
""" )
0 commit comments