scraed / CharacteristicGuidanceWebUI

Provide large guidance scale correction for Stable Diffusion web UI (AUTOMATIC1111), implementing the paper "Characteristic Guidance: Non-linear Correction for Diffusion Model at Large Guidance Scale"
https://scraed.github.io/CharacteristicGuidance/
Apache License 2.0
78 stars 8 forks source link

speed tanked with base settings #10

Closed springheeledjack66 closed 7 months ago

springheeledjack66 commented 8 months ago

image took 727 min. 15.9 sec. to generate with base out the box settings is this normal?

scraed commented 8 months ago

no, it's not normal. Please click the check convergence button and see if Iterations converged. If not, please increase the Regularization strength and time range.

scraed commented 8 months ago

Hi, I have changed the Num basis default value, it should give a more reasonable out the box generation speed even if you are at high CFG value.

springheeledjack66 commented 8 months ago

its not taking all day anymore but still takes a while, what are the best ways to reduce gen time?

springheeledjack66 commented 8 months ago

found another far greater problem however, the images aren't saving

scraed commented 8 months ago

The best way to reduce gen time is to increase the Regularization strength and time range. But you will get less correction. It is important to click the check convergence button to check how many Iteration you have and convergence.

About saving: If you are using txt2img, the image will be saved at your SD root directory/outputs/txt2img–images. img2img will be saved to img2img–images. You can also use the PromptHistory extension to save both image and prompts. Both of them works on my SD. Could you provide more detailed information about what saving method you are using?

springheeledjack66 commented 8 months ago

I'm just using the standard auto save method to my txt2img outputs folder

scraed commented 8 months ago

I have tested again using txt2img, the image saved to SD/outputs/txt2img–images automatically without error. Maybe there are other extensions causing conflict, you could check it by deactivating them one by one to see if the problem persists.

springheeledjack66 commented 8 months ago

I can't find any conflicting exstenions, the problem persists however and some combinations of the settings resault in a error and no image generation, I also found that convergence check image doesn't always update and instead sticks to its first generation, I'm trying both clean and reused seed attempts, does anyone have any recommended settings?

scraed commented 8 months ago

Could you paste the console information of your SD about the error? It's hard to reproduce and debug without detailed information.

PS. I guess the reason for convergence check image doesn't always update is that the first Iteration hasn't finished yet. (It will iterate 50 times if fails to converge). You can lower the maximal number of Iteration to 20 or lower and use high Regularization to accelerate it if you are running on CPU or using an old GPU.

ThisIsNetsu commented 8 months ago

I am having the same problem. Terminal window keeps repeating:

"Characteristic iteration happens tensor([6], device='cuda:0') times" as it updates the steps Even though it shows about 2s/it it actually only updates a single step every ~2s

It looks like this:

Characteristic Guidance parameters registered | 5/35 [00:10<01:10, 2.33s/it] Characteristic Guidance enabled, warpping the sample method Characteristic Guidance injecting the CFGDenoiser Characteristic Guidance sampling: 0%| | 0/35 [00:00<?, ?it/s]Characteristic iteration happens tensor([3], device='cuda:0') times 3%|██▋ | 1/35 [00:01<00:58, 1.74s/it]Characteristic iteration happens tensor([3], device='cuda:0') times | 0/35 [00:00<?, ?it/s] 6%|█████▍ | 2/35 [00:03<00:52, 1.60s/it]Characteristic iteration happens tensor([4], device='cuda:0') times | 2/35 [00:01<00:24, 1.33it/s] 9%|████████▏ | 3/35 [00:05<00:53, 1.67s/it]Characteristic iteration happens tensor([4], device='cuda:0') times | 3/35 [00:03<00:37, 1.17s/it] 11%|██████████▊ | 4/35 [00:06<00:52, 1.70s/it]Characteristic iteration happens tensor([4], device='cuda:0') times | 4/35 [00:05<00:42, 1.38s/it] 14%|█████████████▌ | 5/35 [00:08<00:51, 1.71s/it]Characteristic iteration happens tensor([5], device='cuda:0') times | 5/35 [00:06<00:45, 1.50s/it] 17%|████████████████▎ | 6/35 [00:10<00:52, 1.80s/it]Characteristic iteration happens tensor([5], device='cuda:0') times | 6/35 [00:08<00:48, 1.66s/it] 20%|███████████████████ | 7/35 [00:12<00:51, 1.86s/it]Characteristic iteration happens tensor([6], device='cuda:0') times | 7/35 [00:10<00:49, 1.76s/it] 23%|█████████████████████▋ | 8/35 [00:14<00:53, 1.96s/it]Characteristic iteration happens tensor([6], device='cuda:0') times | 8/35 [00:12<00:51, 1.90s/it] 26%|████████████████████████▍ | 9/35 [00:16<00:52, 2.03s/it]Characteristic iteration happens tensor([5], device='cuda:0') times | 9/35 [00:15<00:51, 1.98s/it] 29%|██████████████████████████▊ | 10/35 [00:18<00:50, 2.02s/it]Characteristic iteration happens tensor([6], device='cuda:0') times | 10/35 [00:17<00:49, 1.99s/it] 31%|█████████████████████████████▌ | 11/35 [00:20<00:49, 2.07s/it]Characteristic iteration happens tensor([7], device='cuda:0') times | 11/35 [00:19<00:49, 2.05s/it] 34%|████████████████████████████████▏ | 12/35 [00:23<00:49, 2.16s/it]Characteristic iteration happens tensor([5], device='cuda:0') times | 12/35 [00:21<00:49, 2.15s/it] 37%|██████████████████████████████████▉ | 13/35 [00:25<00:46, 2.10s/it]Characteristic iteration happens tensor([8], device='cuda:0') times | 13/35 [00:23<00:45, 2.09s/it] 40%|█████████████████████████████████████▌ | 14/35 [00:27<00:47, 2.25s/it]Characteristic iteration happens tensor([11], device='cuda:0') times | 14/35 [00:26<00:46, 2.24s/it] 43%|████████████████████████████████████████▎ | 15/35 [00:31<00:50, 2.54s/it]Characteristic iteration happens tensor([7], device='cuda:0') times | 15/35 [00:29<00:50, 2.54s/it] 46%|██████████████████████████████████████████▉ | 16/35 [00:33<00:47, 2.51s/it]Characteristic iteration happens tensor([6], device='cuda:0') times | 16/35 [00:31<00:47, 2.50s/it] 49%|█████████████████████████████████████████████▋ | 17/35 [00:35<00:43, 2.41s/it]Characteristic iteration happens tensor([8], device='cuda:0') times | 17/35 [00:33<00:43, 2.41s/it] 51%|████████████████████████████████████████████████▎ | 18/35 [00:38<00:36, 2.13s/it]

My apologies for the weird formatting. The progress bar does not display properly with this error. Changing the settings has no effect on this problem.

scraed commented 8 months ago

Hi, are you having the same problem about images are not saving or no generation? The "Characteristic iteration happens tensor([6], device='cuda:0') times" is a normal debug information I have added previously. It tells if Characteristic guidance works as expected. Judging from your console information it works fine.

ThisIsNetsu commented 8 months ago

Hi, are you having the same problem about images are not saving or no generation? The "Characteristic iteration happens tensor([6], device='cuda:0') times" is a normal debug information I have added previously. It tells if Characteristic guidance works as expected. Judging from your console information it works fine.

The image generates fine, but it takes extremely long. A 1024x1024 generation at 50 steps with various samplers takes several minutes to complete on my RTX4090

scraed commented 8 months ago

Hi, to accelerate the generation, check this PR