Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variation logic behind KSampler Inspire. #1

Open
ltdrdata opened this issue May 26, 2024 · 5 comments
Open

Variation logic behind KSampler Inspire. #1

ltdrdata opened this issue May 26, 2024 · 5 comments

Comments

@ltdrdata
Copy link

ltdrdata commented May 26, 2024

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
Copy link
Owner

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
Copy link
Author

variation

I recommend list instead of batch.

@ltdrdata
Copy link
Author

I adde variation_method for slerp.

slerp method uses same logic with KSamplerVariationsWithNoise

image

@Creative-comfyUI
Copy link
Owner

Creative-comfyUI commented May 26, 2024

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
Copy link
Owner

Creative-comfyUI commented May 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants