From 2ec5e9d136f5d1786a41621a8b6826c0c165fa7f Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 11 Jan 2024 12:39:06 -0500 Subject: [PATCH] remove eol cmdflag no-download --- README.md | 1 - modules/cmd_args.py | 1 - modules/modelloader.py | 2 -- modules/sd_models.py | 25 ++++--------------------- webui.py | 6 +++--- 5 files changed, 7 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 1b3679de2..28009ce60 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,6 @@ Below is partial list of all available parameters, run `webui --help` for the fu --docs Mount Gradio docs at /docs, default: False --no-hashing Disable hashing of checkpoints, default: False --no-metadata Disable reading of metadata from models, default: False - --no-download Disable download of default model, default: False --backend {original,diffusers} force model pipeline type Setup options: diff --git a/modules/cmd_args.py b/modules/cmd_args.py index b86dfd154..ae9ecbc85 100644 --- a/modules/cmd_args.py +++ b/modules/cmd_args.py @@ -37,7 +37,6 @@ group.add_argument("--tls-selfsign", action="store_true", default=os.environ.get group.add_argument("--server-name", type=str, default=os.environ.get("SD_SERVERNAME", None), help="Sets hostname of server, default: %(default)s") group.add_argument("--no-hashing", default=os.environ.get("SD_NOHASHING", False), action='store_true', help="Disable hashing of checkpoints, default: %(default)s") group.add_argument("--no-metadata", default=os.environ.get("SD_NOMETADATA", False), action='store_true', help="Disable reading of metadata from models, default: %(default)s") -group.add_argument("--no-download", default=os.environ.get("SD_DOWNLOAD", False), action='store_true', help="Disable download of default model, default: %(default)s") group.add_argument("--profile", default=os.environ.get("SD_PROFILE", False), action='store_true', help="Run profiler, default: %(default)s") group.add_argument("--disable-queue", default=os.environ.get("SD_DISABLEQUEUE", False), action='store_true', help="Disable queues, default: %(default)s") group.add_argument('--debug', default=os.environ.get("SD_DEBUG", False), action='store_true', help = "Run installer with debug logging, default: %(default)s") diff --git a/modules/modelloader.py b/modules/modelloader.py index 093dc6e0c..bab1ff306 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -306,8 +306,6 @@ def find_diffuser(name: str): repo = [r for r in diffuser_repos if name == r['name'] or name == r['friendly'] or name == r['path']] if len(repo) > 0: return repo['name'] - if shared.cmd_opts.no_download: - return None import huggingface_hub as hf hf_api = hf.HfApi() hf_filter = hf.ModelFilter( diff --git a/modules/sd_models.py b/modules/sd_models.py index fa4705c09..0a82e0e07 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -162,27 +162,8 @@ def list_models(): elif shared.cmd_opts.ckpt != shared.default_sd_model_file and shared.cmd_opts.ckpt is not None: shared.log.warning(f"Checkpoint not found: {shared.cmd_opts.ckpt}") shared.log.info(f'Available models: path="{shared.opts.ckpt_dir}" items={len(checkpoints_list)} time={time.time()-t0:.2f}') - checkpoints_list = dict(sorted(checkpoints_list.items(), key=lambda cp: cp[1].filename)) - """ - if len(checkpoints_list) == 0: - if not shared.cmd_opts.no_download: - key = input('Download the default model? (y/N) ') - if key.lower().startswith('y'): - if shared.backend == shared.Backend.ORIGINAL: - model_url = "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" - shared.opts.data['sd_model_checkpoint'] = "v1-5-pruned-emaonly.safetensors" - model_list = modelloader.load_models(model_path=model_path, model_url=model_url, command_path=shared.opts.ckpt_dir, ext_filter=[".ckpt", ".safetensors"], download_name="v1-5-pruned-emaonly.safetensors", ext_blacklist=[".vae.ckpt", ".vae.safetensors"]) - else: - default_model_id = "runwayml/stable-diffusion-v1-5" - modelloader.download_diffusers_model(default_model_id, shared.opts.diffusers_dir) - model_list = modelloader.load_diffusers_models(model_path=os.path.join(models_path, 'Diffusers'), command_path=shared.opts.diffusers_dir) - for filename in sorted(model_list, key=str.lower): - checkpoint_info = CheckpointInfo(filename) - if checkpoint_info.name is not None: - checkpoint_info.register() - """ def update_model_hashes(): txt = [] @@ -251,10 +232,12 @@ def select_checkpoint(op='model'): if checkpoint_info is not None: shared.log.info(f'Select: {op}="{checkpoint_info.title if checkpoint_info is not None else None}"') return checkpoint_info - if len(checkpoints_list) == 0 and not shared.cmd_opts.no_download: + if len(checkpoints_list) == 0: shared.log.warning("Cannot generate without a checkpoint") shared.log.info("Set system paths to use existing folders in a different location") - shared.log.info("Or use --ckpt to force using existing checkpoint") + shared.log.info(" or use --models_dir to specify base folder with all models") + shared.log.info(" or use --ckpt_dir to specify folder with models") + shared.log.info(" or use --ckpt to force using existing model") return None checkpoint_info = next(iter(checkpoints_list.values())) if model_checkpoint is not None: diff --git a/webui.py b/webui.py index 303963543..8bf274e4a 100644 --- a/webui.py +++ b/webui.py @@ -151,7 +151,9 @@ def initialize(): def load_model(): - if opts.sd_checkpoint_autoload and (shared.cmd_opts.ckpt is not None and shared.cmd_opts.ckpt.lower() != 'none'): + if not opts.sd_checkpoint_autoload or (shared.cmd_opts.ckpt is not None and shared.cmd_opts.ckpt.lower() != 'none'): + log.debug('Model auto load disabled') + else: shared.state.begin('load') thread_model = Thread(target=lambda: shared.sd_model) thread_model.start() @@ -160,8 +162,6 @@ def load_model(): shared.state.end() thread_model.join() thread_refiner.join() - else: - log.debug('Model auto load disabled') shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(op='model')), call=False) shared.opts.onchange("sd_model_refiner", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(op='refiner')), call=False) shared.opts.onchange("sd_model_dict", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(op='dict')), call=False)