From b52be4b6de93f350686cfd8dbfd0785a31d44fd3 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 21 Jan 2023 10:40:37 -0500 Subject: [PATCH] add secure startup options --- .gitignore | 3 +++ TODO.md | 21 ++++++++++++++------- cli/train.py | 26 +++++++++++++++----------- config.json | 4 ++-- secure.sh | 7 +++++++ 5 files changed, 41 insertions(+), 20 deletions(-) create mode 100755 secure.sh diff --git a/.gitignore b/.gitignore index dfb31d972..ba220cf0f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ __pycache__ *.bin *.optim *.lock +*.zip +*.rar # all dynamic stuff /repositories/**/* @@ -20,6 +22,7 @@ __pycache__ /train/log/**/* /tmp /log +/cert # unexcluded so folders get created !/repositories/.placeholder diff --git a/TODO.md b/TODO.md index 119142543..2495ce338 100644 --- a/TODO.md +++ b/TODO.md @@ -11,15 +11,16 @@ Things I'm actively investigating... ## Embeddings Need to study more to determine best out-of-the-box settings: -- Impact of Codeformer +- Train object +- Train style - Impact of Hires fix: - e.g 25 steps and denoising strength 0.25-0.7 - Impact of non-square target resolution -## SDAPI +## Hypernetworks + +## LORA -- Support TLS -- Support auth # Ideas @@ -29,7 +30,6 @@ Things I'm looking into... Stuff to be fixed... -- Torch 2.0 model compile / Accelerate test - Reconnect WebUI Tech that can be integrated as part of the core workflow... @@ -51,7 +51,6 @@ Tech that can be integrated as part of the core workflow... - - - ## Video Generation - [Deforum](https://github.com/deforum-art/deforum-for-automatic1111-webui) @@ -60,7 +59,8 @@ Tech that can be integrated as part of the core workflow... - [Tune-a-Video](https://github.com/showlab/Tune-A-Video) - [Animator extension](https://github.com/Animator-Anon/animator_extension) - [Prompt travel](https://github.com/Kahsolt/stable-diffusion-webui-prompt-travel) -- [KLMC2 animation](https://colab.research.google.com/github/dmarx/notebooks/blob/main/Stable_Diffusion_KLMC2_Animation.ipynb) +- [KLMC2 animation](https://colab.research.google.com/github/dmarx/notebooks/blob/main/Stable_Diffusion_KLMC2_Animation.ipynb) +- [BOAAB-limit animation](https://colab.research.google.com/drive/17kesyBVqubV_Zzchf2XoR-7MHk5jxTuo?usp=sharing) - [Disco diffusion](https://colab.research.google.com/github/alembics/disco-diffusion/blob/main/Disco_Diffusion.ipynb) - [Video killed the radio star](https://colab.research.google.com/github/dmarx/video-killed-the-radio-star/blob/main/Video_Killed_The_Radio_Star_Defusion.ipynb) - [Seed travel](https://github.com/yownas/seed_travel) @@ -74,3 +74,10 @@ Cool stuff that is not integrated anywhere... - Bunch of stuff: - Prevalent colors to interrogate - Auto-Sort inputs by face recognition + +## Lee + +- Impact of non-square image sizes +- Model vs embedding +- Monitor MEM when switching models +- Emulate model shoot using img2img diff --git a/cli/train.py b/cli/train.py index 3aae287a3..15e95b466 100755 --- a/cli/train.py +++ b/cli/train.py @@ -181,17 +181,20 @@ async def check(params): options['training_xattention_optimizations'] = False options['training_image_repeats_per_epoch'] = 1 - log.debug({ 'check model': args.training_model }) - if len(args.training_model) > 0 and not options['sd_model_checkpoint'].startswith(args.training_model): - models = await get('/sdapi/v1/sd-models') - models = [obj["title"] for obj in models] - found = [i for i in models if i.startswith(args.training_model)] - if len(found) == 0: - log.error({ 'model not found': args.training_model, 'available': models }) - exit() - else: - log.warning({ 'switching model': found[0] }) - options['sd_model_checkpoint'] = found[0] + if params.skipmodel: + log.info({ 'using model': options['sd_model_checkpoint'] }) + else: + log.debug({ 'check model': args.training_model }) + if len(args.training_model) > 0 and not options['sd_model_checkpoint'].startswith(args.training_model): + models = await get('/sdapi/v1/sd-models') + models = [obj["title"] for obj in models] + found = [i for i in models if i.startswith(args.training_model)] + if len(found) == 0: + log.error({ 'model not found': args.training_model, 'available': models }) + exit() + else: + log.warning({ 'switching model': found[0] }) + options['sd_model_checkpoint'] = found[0] log.debug({ 'check embedding': params.name }) global cmdflags # pylint: disable=global-statement @@ -425,6 +428,7 @@ async def main(): parser.add_argument("--vstart", type = float, default = 0, required = False, help = "if processing video skip first n seconds, default: %(default)s") parser.add_argument("--vend", type = float, default = 0, required = False, help = "if processing video skip last n seconds, default: %(default)s") parser.add_argument('--skipcaption', default = False, action='store_true', help = "do not auto-generate captions, default: %(default)s") + parser.add_argument('--skipmodel', default = False, action='store_true', help = "skip model validation and switch, default: %(default)s") parser.add_argument('--preprocess', type = str, choices=['builtin', 'custom', 'none'], default = 'custom', help = "preprocessing type, default: %(default)s") parser.add_argument('--nocleanup', default = False, action='store_true', help = "skip cleanup after completion, default: %(default)s") parser.add_argument("--monitor", type = int, default = 30, required = False, help = "progress monitor frequency, default: : %(default)s") diff --git a/config.json b/config.json index d566e01ec..bf471c9b0 100644 --- a/config.json +++ b/config.json @@ -60,7 +60,7 @@ "training_enable_tensorboard": true, "training_tensorboard_save_images": false, "training_tensorboard_flush_every": 120, - "sd_model_checkpoint": "sd-v15-runwayml.ckpt [cc6cb27103]", + "sd_model_checkpoint": "zeipher-f222.ckpt [9e2c6ceff3]", "sd_checkpoint_cache": 0, "sd_vae_checkpoint_cache": 0, "sd_vae": "vae-ft-mse-840000-ema-pruned.ckpt", @@ -144,7 +144,7 @@ "ScuNET", "roll-artist" ], - "sd_checkpoint_hash": "cc6cb27103417325ff94f52b7a5d2dde45a7515b25c255d8e396c90014281516", + "sd_checkpoint_hash": "9e2c6ceff3f6d6f65c6fb0e10d8e69d772871813be647fd2ea5d06e00db33c1f", "ldsr_steps": 100, "ldsr_cached": false, "SWIN_tile": 192, diff --git a/secure.sh b/secure.sh new file mode 100755 index 000000000..47b853f06 --- /dev/null +++ b/secure.sh @@ -0,0 +1,7 @@ +#/bin/env bash + +export TF_CPP_MIN_LOG_LEVEL=2 +export FORCE_CUDA="1" +export ATTN_PRECISION=fp16 +export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 +exec accelerate launch --num_cpu_threads_per_process=6 launch.py --api --xformers --disable-console-progressbars --port 8000 --gradio-auth admin:pwd --listen --enable-insecure-extension-access "$@"