mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
mostly working
This commit is contained in:
parent
fe318775c3
commit
07be605dcb
@ -243,7 +243,7 @@ class addModelsForm(npyscreen.FormMultiPageAction):
|
|||||||
|
|
||||||
# URLs and the like
|
# URLs and the like
|
||||||
self.parentApp.import_model_paths = self.import_model_paths.value.split()
|
self.parentApp.import_model_paths = self.import_model_paths.value.split()
|
||||||
self.parentApp.convert_to_diffusers = self.convert_models.value != 0
|
self.parentApp.convert_to_diffusers = self.convert_models.value == 1
|
||||||
|
|
||||||
# big chunk of dead code
|
# big chunk of dead code
|
||||||
# was intended to be a status area in which output of installation steps (including tqdm) was logged in real time
|
# was intended to be a status area in which output of installation steps (including tqdm) was logged in real time
|
||||||
|
@ -92,11 +92,16 @@ def install_requested_models(
|
|||||||
if external_models and len(external_models)>0:
|
if external_models and len(external_models)>0:
|
||||||
print("== INSTALLING EXTERNAL MODELS ==")
|
print("== INSTALLING EXTERNAL MODELS ==")
|
||||||
for path_url_or_repo in external_models:
|
for path_url_or_repo in external_models:
|
||||||
|
try:
|
||||||
model_manager.heuristic_import(
|
model_manager.heuristic_import(
|
||||||
path_url_or_repo,
|
path_url_or_repo,
|
||||||
convert=convert_to_diffusers,
|
convert=convert_to_diffusers,
|
||||||
commit_to_conf=config_file_path
|
commit_to_conf=config_file_path
|
||||||
)
|
)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
sys.exit(-1)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
def yes_or_no(prompt: str, default_yes=True):
|
def yes_or_no(prompt: str, default_yes=True):
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import inspect
|
import inspect
|
||||||
|
import psutil
|
||||||
import secrets
|
import secrets
|
||||||
import sys
|
import sys
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
@ -643,7 +643,7 @@ class ModelManager(object):
|
|||||||
self.add_model(model_name, new_config, True)
|
self.add_model(model_name, new_config, True)
|
||||||
if commit_to_conf:
|
if commit_to_conf:
|
||||||
self.commit(commit_to_conf)
|
self.commit(commit_to_conf)
|
||||||
return True
|
return model_name
|
||||||
|
|
||||||
def import_ckpt_model(
|
def import_ckpt_model(
|
||||||
self,
|
self,
|
||||||
@ -710,6 +710,8 @@ class ModelManager(object):
|
|||||||
model_path = None
|
model_path = None
|
||||||
thing = path_url_or_repo # to save typing
|
thing = path_url_or_repo # to save typing
|
||||||
|
|
||||||
|
print(f'here i am; thing={thing}, convert={convert}')
|
||||||
|
|
||||||
if thing.startswith(('http:','https:','ftp:')):
|
if thing.startswith(('http:','https:','ftp:')):
|
||||||
print(f'* {thing} appears to be a URL')
|
print(f'* {thing} appears to be a URL')
|
||||||
model_path = self._resolve_path(thing, 'models/ldm/stable-diffusion-v1') # _resolve_path does a download if needed
|
model_path = self._resolve_path(thing, 'models/ldm/stable-diffusion-v1') # _resolve_path does a download if needed
|
||||||
@ -720,17 +722,23 @@ class ModelManager(object):
|
|||||||
|
|
||||||
elif Path(thing).is_dir() and Path(thing, 'model_index.json').exists():
|
elif Path(thing).is_dir() and Path(thing, 'model_index.json').exists():
|
||||||
print(f'* {thing} appears to be a diffusers file on disk')
|
print(f'* {thing} appears to be a diffusers file on disk')
|
||||||
self.import_diffusers_model(thing, commit_to_conf=commit_to_conf)
|
model_name = self.import_diffusers_model(
|
||||||
|
thing,
|
||||||
|
vae=dict(repo_id='stabilityai/sd-vae-ft-mse'),
|
||||||
|
commit_to_conf=commit_to_conf
|
||||||
|
)
|
||||||
|
|
||||||
elif Path(thing).is_dir():
|
elif Path(thing).is_dir():
|
||||||
print(f'* {thing} appears to be a directory. Will scan for models to import')
|
print(f'* {thing} appears to be a directory. Will scan for models to import')
|
||||||
for m in list(Path(thing).rglob('*.ckpt')) + list(Path(thing).rglob('*.safetensors')):
|
for m in list(Path(thing).rglob('*.ckpt')) + list(Path(thing).rglob('*.safetensors')):
|
||||||
self.heuristic_import(m, convert, commit_to_conf=commit_to_conf)
|
print('***',m)
|
||||||
|
self.heuristic_import(str(m), convert, commit_to_conf=commit_to_conf)
|
||||||
return
|
return
|
||||||
|
|
||||||
elif re.match(r'^[\w.+-]+/[\w.+-]+$', thing):
|
elif re.match(r'^[\w.+-]+/[\w.+-]+$', thing):
|
||||||
print(f'* {thing} appears to be a HuggingFace diffusers repo_id')
|
print(f'* {thing} appears to be a HuggingFace diffusers repo_id')
|
||||||
self.import_diffuser_model(thing, commit_to_conf=commit_to_conf)
|
model_name = self.import_diffuser_model(thing, commit_to_conf=commit_to_conf)
|
||||||
|
pipeline,_,_,_ = self._load_diffusers_model(self.config[model_name])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f"* {thing}: Unknown thing. Please provide a URL, file path, directory or HuggingFace repo_id")
|
print(f"* {thing}: Unknown thing. Please provide a URL, file path, directory or HuggingFace repo_id")
|
||||||
@ -749,7 +757,7 @@ class ModelManager(object):
|
|||||||
print(f'* {thing} appears to be an SD-v2 model; model will be converted to diffusers format')
|
print(f'* {thing} appears to be an SD-v2 model; model will be converted to diffusers format')
|
||||||
model_config_file = Path(Globals.root,'configs/stable-diffusion/v2-inference-v.yaml')
|
model_config_file = Path(Globals.root,'configs/stable-diffusion/v2-inference-v.yaml')
|
||||||
convert = True
|
convert = True
|
||||||
elif re.search('inpaint', model_path, flags=re.IGNORECASE):
|
elif re.search('inpaint', str(model_path), flags=re.IGNORECASE):
|
||||||
print(f'* {thing} appears to be an SD-v1 inpainting model')
|
print(f'* {thing} appears to be an SD-v1 inpainting model')
|
||||||
model_config_file = Path(Globals.root,'configs/stable-diffusion/v1-inpainting-inference.yaml')
|
model_config_file = Path(Globals.root,'configs/stable-diffusion/v1-inpainting-inference.yaml')
|
||||||
else:
|
else:
|
||||||
@ -833,7 +841,7 @@ class ModelManager(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
model_name = model_name or diffusers_path.name
|
model_name = model_name or diffusers_path.name
|
||||||
model_description = model_description or "Optimized version of {model_name}"
|
model_description = model_description or f"Optimized version of {model_name}"
|
||||||
print(f">> Optimizing {model_name} (30-60s)")
|
print(f">> Optimizing {model_name} (30-60s)")
|
||||||
try:
|
try:
|
||||||
# By passing the specified VAE to the conversion function, the autoencoder
|
# By passing the specified VAE to the conversion function, the autoencoder
|
||||||
|
@ -318,8 +318,6 @@ def download_with_resume(url: str, dest: Path, access_token: str = None) -> Path
|
|||||||
else:
|
else:
|
||||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
print(f'DEBUG: after many manipulations, dest={dest}')
|
|
||||||
|
|
||||||
header = {"Authorization": f"Bearer {access_token}"} if access_token else {}
|
header = {"Authorization": f"Bearer {access_token}"} if access_token else {}
|
||||||
open_mode = "wb"
|
open_mode = "wb"
|
||||||
exist_size = 0
|
exist_size = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user