philz1337x / clarity-upscaler

Clarity AI | AI Image Upscaler & Enhancer - free and open-source Magnific Alternative
https://ClarityAI.co
GNU Affero General Public License v3.0
3.93k stars 409 forks source link

UnboundLocalError: local variable 'h' referenced before assignment #14

Closed olefirenko closed 2 months ago

olefirenko commented 8 months ago

Thank you for amazing upscaler.

Sometimes I am getting this error.

Running prediction
[Tiled Diffusion] upscaling image with 4x-UltraSharp...
[Tiled Diffusion] ControlNet found, support is enabled.
2024-03-31 06:48:41,693 - ControlNet - INFO - unit_separate = False, style_align = False
2024-03-31 06:48:41,694 - ControlNet - INFO - Loading model from cache: control_v11f1e_sd15_tile
2024-03-31 06:48:41,717 - ControlNet - INFO - Using preprocessor: tile_resample
2024-03-31 06:48:41,717 - ControlNet - INFO - preprocessor resolution = 2400
2024-03-31 06:48:41,860 - ControlNet - INFO - ControlNet Hooked - Time = 0.17113852500915527
MultiDiffusion hooked into 'DPM++ 3M SDE Karras' sampler, Tile size: 144x112, Tile count: 12, Batch size: 6, Tile batches: 2 (ext: ContrlNet)
[Tiled VAE]: input_size: torch.Size([1, 3, 2400, 3200]), tile_size: 3072, padding: 32
[Tiled VAE]: split to 1x2 = 2 tiles. Optimal tile size 1568x2336, original tile size 3072x3072
[Tiled VAE]: Fast mode enabled, estimating group norm parameters on 3072 x 2304 image
MultiDiffusion Sampling:   0%|          | 0/20 [00:00<?, ?it/s]
[Tiled VAE]: Executing Encoder Task Queue:   0%|          | 0/182 [00:00<?, ?it/s]
[Tiled VAE]: Executing Encoder Task Queue:  10%|█         | 19/182 [00:00<00:03, 46.32it/s]
[Tiled VAE]: Executing Encoder Task Queue:  21%|██        | 38/182 [00:00<00:03, 45.68it/s]
[Tiled VAE]: Executing Encoder Task Queue:  24%|██▎       | 43/182 [00:01<00:03, 35.46it/s]
[Tiled VAE]: Executing Encoder Task Queue:  26%|██▋       | 48/182 [00:01<00:03, 37.12it/s]
[Tiled VAE]: Executing Encoder Task Queue:  29%|██▊       | 52/182 [00:01<00:06, 20.83it/s]
[Tiled VAE]: Executing Encoder Task Queue:  30%|███       | 55/182 [00:02<00:07, 16.42it/s]
[Tiled VAE]: Executing Encoder Task Queue:  32%|███▏      | 58/182 [00:02<00:08, 14.34it/s]
[Tiled VAE]: Executing Encoder Task Queue:  35%|███▌      | 64/182 [00:02<00:06, 18.53it/s]
[Tiled VAE]: Executing Encoder Task Queue:  38%|███▊      | 70/182 [00:02<00:05, 21.99it/s]
[Tiled VAE]: Executing Encoder Task Queue:  40%|████      | 73/182 [00:02<00:05, 21.19it/s]
[Tiled VAE]: Executing Encoder Task Queue:  42%|████▏     | 76/182 [00:03<00:04, 21.22it/s]
[Tiled VAE]: Executing Encoder Task Queue:  46%|████▌     | 83/182 [00:03<00:03, 26.72it/s]
[Tiled VAE]: Executing Encoder Task Queue:  47%|████▋     | 86/182 [00:03<00:03, 24.86it/s]
[Tiled VAE]: Executing Encoder Task Queue:  49%|████▉     | 89/182 [00:03<00:04, 21.93it/s]
[Tiled VAE]: Executing Encoder Task Queue:  51%|█████     | 92/182 [00:03<00:04, 21.15it/s]
[Tiled VAE]: Executing Encoder Task Queue:  55%|█████▌    | 101/182 [00:03<00:02, 33.76it/s]
[Tiled VAE]: Executing Encoder Task Queue:  64%|██████▍   | 117/182 [00:03<00:01, 60.74it/s]
[Tiled VAE]: Executing Encoder Task Queue:  82%|████████▏ | 149/182 [00:04<00:00, 121.39it/s]
[Tiled VAE]: Executing Encoder Task Queue:  90%|█████████ | 164/182 [00:04<00:00, 94.79it/s] 
[Tiled VAE]: Executing Encoder Task Queue: 100%|██████████| 182/182 [00:04<00:00, 41.48it/s]
[Tiled VAE]: Done in 5.098s, max VRAM alloc 17733.351 MB
  0%|          | 0/1 [00:00<?, ?it/s]
MultiDiffusion Sampling:   5%|▌         | 1/20 [00:06<02:06,  6.66s/it]
0%|          | 0/1 [00:04<?, ?it/s]
Total progress:   0%|          | 0/1 [00:00<?, ?it/s]
Total progress: 100%|██████████| 1/1 [00:00<00:00,  1.82it/s]
Total progress: 100%|██████████| 1/1 [00:00<00:00,  1.82it/s]
Traceback (most recent call last):
File "/root/.pyenv/versions/3.10.4/lib/python3.10/site-packages/cog/server/worker.py", line 217, in _predict
result = predict(**payload)
File "/src/predict.py", line 234, in predict
resp = self.api.img2imgapi(req)
File "/src/modules/api/api.py", line 445, in img2imgapi
processed = process_images(p)
File "/src/modules/processing.py", line 734, in process_images
res = process_images_inner(p)
File "/src/extensions/sd-webui-controlnet/scripts/batch_hijack.py", line 41, in processing_process_images_hijack
return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
File "/src/modules/processing.py", line 869, in process_images_inner
samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)
File "/src/extensions/sd-webui-controlnet/scripts/hook.py", line 438, in process_sample
return process.sample_before_CN_hack(*args, **kwargs)
File "/src/modules/processing.py", line 1528, in sample
samples = self.sampler.sample_img2img(self, self.init_latent, x, conditioning, unconditional_conditioning, image_conditioning=self.image_conditioning)
File "/src/modules/sd_samplers_kdiffusion.py", line 188, in sample_img2img
samples = self.launch_sampling(t_enc + 1, lambda: self.func(self.model_wrap_cfg, xi, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, **extra_params_kwargs))
File "/src/modules/sd_samplers_common.py", line 261, in launch_sampling
return func()
File "/src/modules/sd_samplers_kdiffusion.py", line 188, in <lambda>
samples = self.launch_sampling(t_enc + 1, lambda: self.func(self.model_wrap_cfg, xi, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, **extra_params_kwargs))
File "/root/.pyenv/versions/3.10.4/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/src/repositories/k-diffusion/k_diffusion/sampling.py", line 701, in sample_dpmpp_3m_sde
h_1, h_2 = h, h_1
UnboundLocalError: local variable 'h' referenced before assignment
philz1337x commented 8 months ago

Are you using the official replicate model or something self hosted? Did you tried another input image?

Alexandr-git-bot commented 3 months ago

I have the same problem, I changed the original image, but it still gives an error.

Nikitosina commented 2 months ago

For me, this happens when I set creativity parameter to 0

philz1337x commented 2 months ago

you can't set

For me, this happens when I set creativity parameter to 0

You can't set creativity to 0. You need to choose a value >0