automatic icon indicating copy to clipboard operation
automatic copied to clipboard

[Issue]: Master + Dev: Restore botton causes error during rendering in Second Pass

Open Tillerz opened this issue 6 months ago • 0 comments

Issue Description

When I empty the PROMPT field and click the RESTORE button above it and start a render including Second Pass ON, the second pass always fails with an UnboundLocalError.

I can have a working prompt that renders, save it via "Set New Defaults". After reloading it via RESTORE, the Second Pass breaks.

Version Platform Description

WSL2/Win11, MASTER ( a874b27 ) + DEV ( b50a8601 ) branch

Relevant log output

Activate python venv: /home/tillerz/master/venv
Launch: venv/bin/python3
14:11:23-086714 INFO     Starting SD.Next
14:11:23-088400 INFO     Logger: file="/home/tillerz/master/sdnext.log" level=DEBUG size=64 mode=create
14:11:23-088973 INFO     Python version=3.10.12 platform=Linux bin="/home/tillerz/master/venv/bin/python3" venv="/home/tillerz/master/venv"
14:11:23-114299 INFO     Version: app=sd.next updated=2024-07-24 hash=a874b27 branch=master url=https://github.com/vladmandic/automatic.git/tree/master ui=main
14:11:23-455496 INFO     Platform: arch=x86_64 cpu=x86_64 system=Linux release=5.15.153.1-microsoft-standard-WSL2 python=3.10.12
14:11:23-456680 DEBUG    Setting environment tuning
14:11:23-457420 INFO     HF cache folder: /home/tillerz/.cache/huggingface/hub
14:11:23-458169 DEBUG    Torch allocator: "garbage_collection_threshold:0.80,max_split_size_mb:512"
14:11:23-458848 DEBUG    Torch overrides: cuda=False rocm=False ipex=False diml=False openvino=False
14:11:23-459662 DEBUG    Torch allowed: cuda=True rocm=True ipex=True diml=True openvino=True
14:11:23-461025 INFO     nVidia CUDA toolkit detected: nvidia-smi present
14:11:23-504379 INFO     Verifying requirements
14:11:23-508082 INFO     Verifying packages
14:11:23-508910 INFO     Startup: standard
14:11:23-509586 INFO     Verifying submodules
14:11:23-965674 DEBUG    Submodule: extensions-builtin/sd-extension-chainner / main
14:11:24-337087 DEBUG    Submodule: extensions-builtin/sd-extension-system-info / main
14:11:24-714907 DEBUG    Submodule: extensions-builtin/sd-webui-agent-scheduler / main
14:11:25-138463 DEBUG    Git detached head detected: folder="extensions-builtin/sdnext-modernui" reattach=main
14:11:25-139410 DEBUG    Submodule: extensions-builtin/sdnext-modernui / main
14:11:25-523917 DEBUG    Submodule: extensions-builtin/stable-diffusion-webui-rembg / master
14:11:25-903352 DEBUG    Submodule: modules/k-diffusion / master
14:11:26-322454 DEBUG    Git detached head detected: folder="wiki" reattach=master
14:11:26-323588 DEBUG    Submodule: wiki / master
14:11:26-743246 DEBUG    Register paths
14:11:26-767382 DEBUG    Installed packages: 229
14:11:26-768436 DEBUG    Extensions all: ['sd-extension-system-info', 'sd-webui-agent-scheduler', 'sd-extension-chainner', 'sdnext-modernui',
                         'stable-diffusion-webui-rembg', 'Lora']
14:11:26-769459 DEBUG    Submodule: extensions-builtin/sd-extension-system-info / main
14:11:26-792961 DEBUG    Submodule: extensions-builtin/sd-webui-agent-scheduler / main
14:11:26-793805 DEBUG    Running extension installer: /home/tillerz/master/extensions-builtin/sd-webui-agent-scheduler/install.py
14:11:26-898177 DEBUG    Submodule: extensions-builtin/sd-extension-chainner / main
14:11:26-911549 DEBUG    Git detached head detected: folder="extensions-builtin/sdnext-modernui" reattach=main
14:11:26-912093 DEBUG    Submodule: extensions-builtin/sdnext-modernui / main
14:11:26-924909 DEBUG    Submodule: extensions-builtin/stable-diffusion-webui-rembg / master
14:11:26-925416 DEBUG    Running extension installer: /home/tillerz/master/extensions-builtin/stable-diffusion-webui-rembg/install.py
14:11:27-388105 DEBUG    Extensions all: ['stable-diffusion-webui-promptgen', 'adetailer']
14:11:27-397183 DEBUG    Submodule: extensions/stable-diffusion-webui-promptgen / master
14:11:27-833869 DEBUG    Submodule: extensions/adetailer / main
14:11:28-219384 DEBUG    Running extension installer: /home/tillerz/master/extensions/adetailer/install.py
14:11:28-334787 INFO     Extensions enabled: ['sd-extension-system-info', 'sd-webui-agent-scheduler', 'sd-extension-chainner', 'sdnext-modernui',
                         'stable-diffusion-webui-rembg', 'Lora', 'stable-diffusion-webui-promptgen', 'adetailer']
14:11:28-335550 INFO     Verifying requirements
14:11:28-335977 INFO     Updating Wiki
14:11:28-341724 DEBUG    Submodule: /home/tillerz/master/wiki / master
14:11:28-742077 DEBUG    Setup complete without errors: 1722514289
14:11:28-744198 DEBUG    Extension preload: {'extensions-builtin': 0.0, 'extensions': 0.0}
14:11:28-745150 DEBUG    Starting module: <module 'webui' from '/home/tillerz/master/webui.py'>
14:11:28-746017 INFO     Command line args: ['--debug', '--upgrade', '--port', '7870'] port=7870 upgrade=True debug=True
14:11:28-746858 DEBUG    Env flags: []
14:11:30-983804 INFO     Load packages: {'torch': '2.3.0+cu121', 'diffusers': '0.29.1', 'gradio': '3.43.2'}
14:11:31-581645 INFO     VRAM: Detected=23.99 GB Optimization=none
14:11:31-583219 DEBUG    Read: file="config.json" json=84 bytes=3583 time=0.000
14:11:31-583956 DEBUG    Unknown settings: ['queue_paused', 'queue_keyboard_shortcut', 'ad_max_models', 'aesthetic_scorer_enabled',
                         'aesthetic_scorer_clip_model']
14:11:31-584978 INFO     Engine: backend=Backend.DIFFUSERS compute=cuda device=cuda attention="Scaled-Dot-Product" mode=no_grad
14:11:31-612707 INFO     Device: device=NVIDIA GeForce RTX 4090 n=1 arch=sm_90 cap=(8, 9) cuda=12.1 cudnn=8902 driver=560.70
14:11:31-613899 DEBUG    Read: file="html/reference.json" json=45 bytes=25676 time=0.000
14:11:31-717501 DEBUG    ONNX: version=1.18.0 provider=CUDAExecutionProvider, available=['AzureExecutionProvider', 'CPUExecutionProvider']
14:11:31-781555 DEBUG    Importing LDM
14:11:31-785218 DEBUG    Entering start sequence
14:11:31-785836 DEBUG    Initializing
14:11:31-791947 INFO     Available VAEs: path="/home/tillerz/models/VAE" items=3
14:11:31-792498 DEBUG    Available UNets: path="/home/tillerz/models/UNET" items=0
14:11:31-793077 INFO     Disabled extensions: []
14:11:31-793842 DEBUG    Read: file="cache.json" json=2 bytes=11828 time=0.000
14:11:31-795617 DEBUG    Read: file="metadata.json" json=222 bytes=519760 time=0.001
14:11:31-797258 DEBUG    Scanning diffusers cache: folder=/home/tillerz/models/Diffusers items=3 time=0.00
14:11:31-797816 INFO     Available models: path="/home/tillerz/models/Stable-diffusion" items=58 time=0.00
14:11:31-879475 DEBUG    Load extensions
14:11:31-907632 INFO     LoRA networks: available=173 folders=2
14:11:32-212821 INFO     Extension: script='extensions-builtin/sd-webui-agent-scheduler/scripts/task_scheduler.py' Using sqlite file:
                         extensions-builtin/sd-webui-agent-scheduler/task_scheduler.sqlite3
14:11:32-531254 INFO     Extension: script='extensions/adetailer/scripts/!adetailer.py' [-] ADetailer initialized. version: 24.6.0, num models: 14
14:11:32-538003 DEBUG    Extensions init time: 0.66 sd-webui-agent-scheduler=0.30 adetailer=0.32
14:11:32-542516 DEBUG    Read: file="html/upscalers.json" json=4 bytes=2640 time=0.000
14:11:32-543265 DEBUG    Read: file="extensions-builtin/sd-extension-chainner/models.json" json=24 bytes=2693 time=0.000
14:11:32-544183 DEBUG    chaiNNer models: path="/home/tillerz/models/chaiNNer" defined=24 discovered=0 downloaded=2
14:11:32-545177 DEBUG    Upscaler type=ESRGAN folder="/home/tillerz/models/ESRGAN" model="8x_NMKD-Superscale_150000_G"
                         path="/home/tillerz/models/ESRGAN/8x_NMKD-Superscale_150000_G.pth"
14:11:32-545987 DEBUG    Upscaler type=SwinIR folder="/home/tillerz/models/SwinIR" model="SwinIR_4x" path="/home/tillerz/models/SwinIR/SwinIR_4x.pth"
14:11:32-546717 DEBUG    Load upscalers: total=55 downloaded=16 user=2 time=0.01 ['None', 'Lanczos', 'Nearest', 'ChaiNNer', 'RealESRGAN', 'SCUNet', 'ESRGAN',
                         'LDSR', 'SwinIR', 'AuraSR', 'SD']
14:11:32-583508 DEBUG    Load styles: folder="/home/tillerz/models/styles" items=356 time=0.04
14:11:32-585064 DEBUG    Creating UI
14:11:32-585848 DEBUG    UI themes available: type=Modern themes=32
14:11:32-586479 INFO     UI theme: type=Modern name="Eoan-Cyan"
14:11:32-588106 DEBUG    UI theme: css="extensions-builtin/sdnext-modernui/themes/Eoan-Cyan.css" base="base.css" user="user.css"
14:11:32-589625 DEBUG    UI initialize: txt2img
14:11:32-785383 DEBUG    Networks: page='lora' items=173 subfolders=6 tab=txt2img folders=['/home/tillerz/models/Lora', '/home/tillerz/models/LyCORIS']
                         list=0.18 thumb=0.00 desc=0.03 info=0.48 workers=4 sort=Name [A-Z]
14:11:32-787961 DEBUG    Networks: page='embedding' items=11 subfolders=0 tab=txt2img folders=['/home/tillerz/models/embeddings'] list=0.10 thumb=0.03 desc=0.00
                         info=0.04 workers=4 sort=Name [A-Z]
14:11:32-812171 DEBUG    Networks: page='style' items=356 subfolders=3 tab=txt2img folders=['/home/tillerz/models/styles', 'html'] list=0.12 thumb=0.11
                         desc=0.00 info=0.00 workers=4 sort=Name [A-Z]
14:11:32-821777 DEBUG    Networks: page='model' items=102 subfolders=4 tab=txt2img folders=['/home/tillerz/models/Stable-diffusion',
                         '/home/tillerz/models/Diffusers', 'models/Reference'] list=0.16 thumb=0.09 desc=0.00 info=0.00 workers=4 sort=Name [A-Z]
14:11:32-909465 DEBUG    UI initialize: img2img
14:11:33-018707 DEBUG    UI initialize: control models=/home/tillerz/models/control
14:11:33-359671 DEBUG    Read: file="ui-config.json" json=78 bytes=4464 time=0.000
14:11:33-448357 DEBUG    UI themes available: type=Modern themes=32
14:11:33-867983 DEBUG    Extension list: processed=360 installed=8 enabled=8 disabled=0 visible=360 hidden=0
14:11:33-953091 DEBUG    Root paths: ['/home/tillerz/master']
14:11:33-996546 INFO     Local URL: http://127.0.0.1:7870/
14:11:33-997280 DEBUG    Gradio functions: registered=2085
14:11:33-997941 DEBUG    FastAPI middleware: ['Middleware', 'Middleware']
14:11:33-999635 DEBUG    Creating API
14:11:34-091504 INFO     [AgentScheduler] Runner is paused
14:11:34-092232 INFO     [AgentScheduler] Registering APIs
14:11:34-397293 DEBUG    Scripts setup: ['IP Adapters:0.021', 'AnimateDiff:0.01', 'ADetailer:0.065', 'X/Y/Z Grid:0.011', 'Face:0.013', 'Image-to-Video:0.006']
14:11:34-398252 DEBUG    Model metadata: file="metadata.json" no changes
14:11:34-398835 DEBUG    Torch mode: deterministic=False
14:11:34-418716 DEBUG    Desired Torch parameters: dtype=FP16 no-half=False no-half-vae=False upscast=False
14:11:34-419810 INFO     Setting Torch parameters: device=cuda dtype=torch.float16 vae=torch.float16 unet=torch.float16 context=no_grad fp16=True bf16=None
                         optimization=Scaled-Dot-Product
14:11:34-420955 DEBUG    Model requested: fn=<lambda>
14:11:34-421793 INFO     Select: model="SD15/zo4-ra-art-if-noo-fcb3 [e5ee81f4ce]"
14:11:34-422976 DEBUG    Load model: existing=False target=/home/tillerz/models/Stable-diffusion/SD15/zo4-ra-art-if-noo-fcb3.safetensors info=None
14:11:34-423905 DEBUG    Diffusers loading: path="/home/tillerz/models/Stable-diffusion/SD15/zo4-ra-art-if-noo-fcb3.safetensors"
14:11:34-424376 ERROR    Error loading diffusers pipeline: model=/home/tillerz/models/Stable-diffusion/SD15/zo4-ra-art-if-noo-fcb3.safetensors 'NoneType' object
                         has no attribute '__name__'
14:11:34-424912 WARNING  Autodetect: pipeline not recognized: SD15/zo4-ra-art-if-noo-fcb3-rcr-rpg [cc948ecdc4]:
                         model=/home/tillerz/models/Stable-diffusion/SD15/zo4-ra-art-if-noo-fcb3.safetensors size=3918
Fetching 11 files: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 11/11 [00:00<00:00, 40938.19it/s]
Loading pipeline components... 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6/6  [ 0:00:00 < 0:00:00 , 52 C/s ]

14:11:35-244144 DEBUG    Setting model: pipeline=StableDiffusionPipeline config={'low_cpu_mem_usage': True, 'torch_dtype': torch.float16,
                         'load_connected_pipeline': True, 'extract_ema': False, 'use_safetensors': True, 'cache_dir': '/home/tillerz/.cache/huggingface/hub'}
14:11:35-887375 INFO     Load embeddings: loaded=10 skipped=1 time=0.64
14:11:35-888233 DEBUG    Setting model: enable VAE slicing
14:11:36-542187 DEBUG    GC: utilization={'gpu': 15, 'ram': 3, 'threshold': 80} gc={'collected': 270, 'saved': 0.0} before={'gpu': 3.63, 'ram': 1.17}
                         after={'gpu': 3.63, 'ram': 1.17, 'retries': 0, 'oom': 0} device=cuda fn=load_diffuser time=0.25
14:11:36-545949 INFO     Load model: time=1.87 load=0.82 embeddings=0.64 move=0.40 native=512 {'ram': {'used': 1.17, 'total': 39.18}, 'gpu': {'used': 3.63,
                         'total': 23.99}, 'retries': 0, 'oom': 0}
14:11:36-547633 DEBUG    Script callback init time: task_scheduler.py:app_started=0.31
14:11:36-548498 INFO     Startup time: 7.79 torch=1.66 gradio=0.46 diffusers=0.11 libraries=0.80 extensions=0.66 face-restore=0.08 ui-en=0.31 ui-txt2img=0.07
                         ui-img2img=0.08 ui-control=0.11 ui-models=0.13 ui-settings=0.39 ui-extensions=0.13 launch=0.08 app-started=0.35 checkpoint=2.15
14:11:36-549539 DEBUG    Save: file="config.json" json=84 bytes=3583 time=0.002
14:11:36-551675 DEBUG    Unused settings: ['aesthetic_scorer_enabled', 'aesthetic_scorer_clip_model']
14:11:43-763965 INFO     MOTD: N/A
14:11:45-877317 DEBUG    UI themes available: type=Modern themes=32
14:11:46-086212 INFO     Browser session: user=None client=127.0.0.1 agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
                         Chrome/127.0.0.0 Safari/537.36
14:11:59-585237 DEBUG    Server: alive=True jobs=1 requests=59 uptime=28 memory=1.22/39.18 backend=Backend.DIFFUSERS state=idle
14:12:04-643450 DEBUG    Paste prompt: type="params" prompt="fast car
                         Negative prompt: boring
                         Steps: 10, Seed: 1969013612, Sampler: DPM++ 2M, CFG scale: 3.5, Size: 512x768, Parser: Full parser, Model: zo4-ra-art-if-noo-fcb3,
                         Model hash: e5ee81f4ce, Backend: Diffusers, App: SD.Next, Version: a874b27, Operations: upscale; hires; txt2img, Pipeline:
                         StableDiffusionPipeline, T5: T5 FP16, Second pass: True, Hires force: True, Hires steps: 20, Hires upscaler: ESRGAN 4x Remacri, Hires
                         upscale: 2, Hires size: 1024x1536, Denoising strength: 0.8, Hires sampler: Same as primary, Image CFG scale: 3, CFG rescale: 0.7, Size
                         before: 512x768, Size mode before: 1, Size scale before: 1, Size name before: ESRGAN 4x Remacri, Size after: 512x768, Size mode after:
                         1, Size scale after: 1, Size name after: ESRGAN 4x Remacri, Size mask: 512x768, Size mode mask: 1, Size scale mask: 1, Size name mask:
                         ESRGAN 4x Remacri, ToDo: 0.5, FreeU: b1=1.2 b2=1.4 s1=0.9 s2=0.2, Sampler options: sde-dpmsolver++/order 2/low order"
14:12:08-289135 DEBUG    Control process unit: i=1 process=None
14:12:08-291955 INFO     Applying ToDo: ratio=0.5
14:12:08-292642 INFO     Applying free-u: b1=1.2 b2=1.4 s1=0.9 s2=0.2
14:12:08-304753 INFO     Base: class=StableDiffusionPipeline
14:12:08-306252 DEBUG    Sampler: sampler="DPM++ 2M" config={'num_train_timesteps': 1000, 'beta_start': 0.00085, 'beta_end': 0.012, 'beta_schedule':
                         'scaled_linear', 'prediction_type': 'epsilon', 'thresholding': False, 'sample_max_value': 1.0, 'algorithm_type': 'sde-dpmsolver++',
                         'solver_type': 'midpoint', 'lower_order_final': True, 'use_karras_sigmas': False, 'final_sigmas_type': 'zero', 'timestep_spacing':
                         'linspace', 'solver_order': 2}
14:12:08-307571 DEBUG    Sampler: steps=10 timesteps=[999, 850, 736, 645, 545, 455, 343, 233, 124, 24]
14:12:08-444796 DEBUG    Torch generator: device=cuda seeds=[1969013612]
14:12:08-445638 DEBUG    Diffuser pipeline: StableDiffusionPipeline task=DiffusersTaskType.TEXT_2_IMAGE batch=1/1x1 set={'timesteps': [999, 850, 736, 645, 545,
                         455, 343, 233, 124, 24], 'prompt_embeds': torch.Size([1, 77, 768]), 'negative_prompt_embeds': torch.Size([1, 77, 768]),
                         'guidance_scale': 3.5, 'num_inference_steps': 10, 'eta': 1.0, 'guidance_rescale': 0.7, 'output_type': 'latent', 'width': 512, 'height':
                         768, 'parser': 'Full parser'}
Progress 10.81it/s ███████████████████████████▏        80% 8/10 00:01 00:00 Base14:12:09-599915 DEBUG    VAE load: type=taesd model=/home/tillerz/models/TAESD/taesd_decoder.pth
Progress  8.66it/s █████████████████████████████████ 100% 10/10 00:01 00:00 Base
14:12:09-822428 DEBUG    Control hires: upscaler="ESRGAN 4x Remacri" upscale=2 size=1024x1536
14:12:09-823516 INFO     Upscale: upscaler="ESRGAN 4x Remacri" resize=0x0 upscale=1024x1536
14:12:10-420106 INFO     Upscaler loaded: type=ESRGAN model=/home/tillerz/models/ESRGAN/ESRGAN-Remacri-4x.pth
Upscaling ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00 0:00:01
14:12:11-654713 DEBUG    Pipeline class change: original=StableDiffusionPipeline target=StableDiffusionImg2ImgPipeline device=cuda:0 fn=process_diffusers
14:12:11-655730 INFO     HiRes: class=StableDiffusionImg2ImgPipeline sampler="Same as primary"
14:12:11-664845 DEBUG    Sampler: steps=10 timesteps=[999, 850, 736, 645, 545, 455, 343, 233, 124, 24]
14:12:11-665808 DEBUG    Torch generator: device=cuda seeds=[1969013612]
14:12:11-666444 DEBUG    Diffuser pipeline: StableDiffusionImg2ImgPipeline task=DiffusersTaskType.IMAGE_2_IMAGE batch=1/1x1 set={'timesteps': [999, 850, 736,
                         645, 545, 455, 343, 233, 124, 24], 'prompt_embeds': torch.Size([1, 77, 768]), 'negative_prompt_embeds': torch.Size([1, 77, 768]),
                         'guidance_scale': 3, 'num_inference_steps': 67, 'eta': 1.0, 'output_type': 'latent', 'image': [<PIL.Image.Image image mode=RGB
                         size=1024x1536 at 0x7FE46A1548E0>], 'strength': 0.3, 'parser': 'Full parser'}
Progress  2.64it/s ██████████████████████████████████ 100% 3/3 00:01 00:00 Hires
14:12:15-606268 INFO     Processed: images=1 time=7.31 its=1.37 memory={'ram': {'used': 2.3, 'total': 39.18}, 'gpu': {'used': 4.52, 'total': 23.99}, 'retries':
                         0, 'oom': 0}
14:12:15-616786 ERROR    Control pipeline failed: type=controlnet units=0 error=local variable 'res' referenced before assignment
14:12:15-617965 ERROR    Control: UnboundLocalError
╭───────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────╮
│ /home/tillerz/master/modules/control/run.py:649 in control_run                                                                                               │
│                                                                                                                                                              │
│   648 │   │   │   │   │   │   │   │   debug(f'Control resize: op=after image={output_image} width={width_after} height={height_after} mode={resize_mode_afte │
│ ❱ 649 │   │   │   │   │   │   │   │   output_image = images.resize_image(resize_mode_after, output_image, width_after, height_after, resize_name_after)      │
│   650                                                                                                                                                        │
│                                                                                                                                                              │
│ /home/tillerz/master/modules/images.py:305 in resize_image                                                                                                   │
│                                                                                                                                                              │
│   304 │   │   return np.array(res)                                                                                                                           │
│ ❱ 305 │   return res                                                                                                                                         │
│   306                                                                                                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
UnboundLocalError: local variable 'res' referenced before assignment

Backend

Diffusers

UI

ModernUI

Branch

Master

Model

StableDiffusion 1.5

Acknowledgements

  • [X] I have read the above and searched for existing issues
  • [X] I confirm that this is classified correctly and its not an extension issue

Tillerz avatar Aug 01 '24 12:08 Tillerz