r/StableDiffusion • • Oct 24 '22

Resource | Update Interpolate script

I am releasing my interpolate.py script (https://github.com/DiceOwl/StableDiffusionStuff), which can interpolate between two input images and two or more prompts. For example look at

This has as input two images, a steam train and a car. These are blended and used for img2img. The corresponding prompt in this example is

a train. elegant intricate highly detailed digital painting, artstation, concept art, smooth, illustration, official game art:1~0.2 AND a car. elegant intricate highly detailed digital painting, artstation, concept art, smooth, illustration, official game art:0.2~1

The script changes 1~0.2 to a number between 1 and 0.2 depending on where in the interpolation the script is, so that as the script progresses the prompt changes from train to car. See the github page for more details.

The script has multiple blending modes: default is simply blending both images in pixel space. 'paste on mask' keeps the primary image intact outside of the mask, and rescales the secondary image to fit into the rectangle inscribed by the mask. 'interpolate in latent' blends the images in latent space instead of pixel space, which is experimental but seems to produce better interpolated images.

The script also supports loopback, for the effect of four loops in normal and latent space see normal.jpg and latent.jpg . It tends to improve consistency, but has quite a high computation cost.

There are still some bugs/missing features, for example 'blending in latent' with masks.

Edit: Since that was a frequent question, this is a script for automatic1111. Basic instructions are in the readme on github.

79 Upvotes

34 comments sorted by

View all comments

Show parent comment

6

u/StaplerGiraffe Oct 24 '22

Thanks for providing the basic instruction, I now added something similar to the readme.

As for your point 5, if you use 0-1[10] for interpolation, that means you do increments of about 0.11, that is, 0.0, 0.11, 0.22, ..., 0.89, 1.0 . If you write 1~0 in the prompt, this will be proportionally interpolated, that is, at interpolation value 0.0 this is 1.0, at interpolation 0.11 it is 0.89, at 0.22 it becomes 0.78 and so on until it becomes 0 at interpolation 1. If you write 0~1 it is the other way around, increasing from 0 to 1.

Generally you should have two prompts combined with AND, one increasing, one decreasing.

But you might find that these changes are too steep, and all the interesting stuff happens between 0.4 and 0.6. In that case it makes sense to write 1~0.3 and 0.3~1 instead. At 0.3 a prompt is hardly noticeable, but the influence starts earlier, making the transition less sudden.