mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
remove more dead code
This commit is contained in:
parent
58be915446
commit
55dce6cfdd
@ -532,30 +532,23 @@ def do_command(command: str, gen, opt: Args, completer) -> tuple:
|
|||||||
"** please provide (1) a URL to a .ckpt file to import; (2) a local path to a .ckpt file; or (3) a diffusers repository id in the form stabilityai/stable-diffusion-2-1"
|
"** please provide (1) a URL to a .ckpt file to import; (2) a local path to a .ckpt file; or (3) a diffusers repository id in the form stabilityai/stable-diffusion-2-1"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
import_model(path[1], gen, opt, completer)
|
import_model(path[1], gen, opt, completer)
|
||||||
completer.add_history(command)
|
completer.add_history(command)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('\n')
|
||||||
operation = None
|
operation = None
|
||||||
|
|
||||||
elif command.startswith("!convert"):
|
elif command.startswith(("!convert","!optimize")):
|
||||||
path = shlex.split(command)
|
path = shlex.split(command)
|
||||||
if len(path) < 2:
|
if len(path) < 2:
|
||||||
print("** please provide the path to a .ckpt or .safetensors model")
|
print("** please provide the path to a .ckpt or .safetensors model")
|
||||||
elif not os.path.exists(path[1]):
|
|
||||||
print(f"** {path[1]}: model not found")
|
|
||||||
else:
|
|
||||||
convert_model(path[1], gen, opt, completer)
|
|
||||||
completer.add_history(command)
|
|
||||||
operation = None
|
|
||||||
|
|
||||||
elif command.startswith("!optimize"):
|
|
||||||
path = shlex.split(command)
|
|
||||||
if len(path) < 2:
|
|
||||||
print("** please provide an installed model name")
|
|
||||||
elif not path[1] in gen.model_manager.list_models():
|
|
||||||
print(f"** {path[1]}: model not found")
|
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
convert_model(path[1], gen, opt, completer)
|
convert_model(path[1], gen, opt, completer)
|
||||||
completer.add_history(command)
|
completer.add_history(command)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('\n')
|
||||||
operation = None
|
operation = None
|
||||||
|
|
||||||
elif command.startswith("!edit"):
|
elif command.startswith("!edit"):
|
||||||
@ -646,6 +639,12 @@ def import_model(model_path: str, gen, opt, completer, convert=False) -> str:
|
|||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
if model_path.startswith(('http:','https:')):
|
||||||
|
try:
|
||||||
|
default_name = url_attachment_name(model_path)
|
||||||
|
default_name = Path(default_name).stem
|
||||||
|
except Exception as e:
|
||||||
|
print(f'** URL: {str(e)}')
|
||||||
model_name, model_desc = _get_model_name_and_desc(
|
model_name, model_desc = _get_model_name_and_desc(
|
||||||
gen.model_manager,
|
gen.model_manager,
|
||||||
completer,
|
completer,
|
||||||
@ -740,7 +739,10 @@ def convert_model(model_name_or_path: Union[Path, str], gen, opt, completer) ->
|
|||||||
vae=vae_repo,
|
vae=vae_repo,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
model_name = import_model(model_name_or_path, gen, opt, completer, convert=True)
|
model_name = import_model(model_name_or_path, gen, opt, completer, convert=True)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
return
|
||||||
|
|
||||||
if not model_name:
|
if not model_name:
|
||||||
print("** Conversion failed. Aborting.")
|
print("** Conversion failed. Aborting.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user