Creative-comfyUI / seed_eng

Understanding ComfyUI seed
GNU General Public License v3.0
12 stars 1 forks source link

Variation logic behind KSampler Inspire. #1

Open ltdrdata opened 3 months ago

ltdrdata commented 3 months ago

When I first created the variation feature, I reflected a simple mixing ratio based on the strength between the noise generated by the two seeds and the variation seed, mixing them linearly.

However, during testing, I found that as the strength approached 0.5, a blurring effect occurred. Upon investigation, I discovered that when mixing two Gaussian noises, the variance of the Gaussian changes.

https://github.com/ltdrdata/ComfyUI-Inspire-Pack/blob/0916454bce870ae26776f617683123cc66e923a5/inspire/libs/utils.py#L69

sqrt( (1 - strength)^2 + strength^2 )

Therefore, after mixing the two, the current algorithm adjusts the scale of the latent value according to the mixing ratio.

And one consideration when applying variation is that, while variation tends to show slight modifications based on the original noise, it can become completely different once a certain threshold is exceeded.

If the noise of the seed is already close to this threshold, even a slight increase in variation strength can cause significant changes in the composition of the image.

Creative-comfyUI commented 3 months ago

Thank you very much for your explanations.

Could we envisage a Ksampler where we choose the type of noise for the variation chosen and ask for a batch size which would include a range of different variations which would remain within a certain framework so as not to have too great a difference or is this not possible?

ltdrdata commented 3 months ago

variation

I recommend list instead of batch.

ltdrdata commented 3 months ago

I adde variation_method for slerp.

slerp method uses same logic with KSamplerVariationsWithNoise

image

Creative-comfyUI commented 3 months ago

Thank you so much! I updated Inspire and did some tests. Fantastic! The number of possibilities can be huge.

I don't know why, but this time, compared to the regular sampler, the luminosity is much better, especially for the glass and the bottle. How do you explain this difference?

Some photo have a composition problem format 832 * 1216 with linear

Here is the perfect image

BottleWine_Linear

Here is the image with the distortion

WineBottle_linear_diform

With Slerp the glasse diseapeared

WineBottle_Slerp

I will continue to test and keep you informed

Creative-comfyUI commented 3 months ago

I have some answers

When the stop (en step) in the float range are at their maximum, the luminosity is higher and this can explain the deformation. With low stop (end step) (0.7) the images are perfect. Reducing the stop reduces the number of images generated :-) With a limit of 5 I get 3 images.

You've opened up new possibilities for me, thank you.

WineBottle_linear_steps