r/StableDiffusion • u/StaplerGiraffe • 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.
11
u/Striking-Long-2960 Oct 24 '22 edited Oct 24 '22
1- It can be installed in automatic, just copy the scripts (.py files) in the scripts folder. Then start the app and select the script "Interpolate" in img2img.
2- To make it work I recommend to read the readme.
https://github.com/DiceOwl/StableDiffusionStuff/blob/main/README.md
3- I've tried the interpolation between pictures, and it can work without prompts (but your risk to strange changes in the interpolation). In interpolation values you need to write something like
0-1[10]
It means it goes from 0% of the target picture to the 100% of the target picture giving 10 pictures.
4- If you are going to use masks, you can load it Inpaint
5- I'm still trying to make sense of how the prompt is written and what is the relationship between the numbers in the prompt and the numbers in Interpolation values.
5
u/bennyboy_uk_77 Oct 24 '22
This looks great. If you can update the text on your github page with some basic instructions on how to use it, that would help the less techy Stable Diffusion enthusiasts (like me). Does it plug into Automatic1111, for instance?
2
u/TalkToTheLord Oct 24 '22
Nice work! I think this can be made into an Automatic 'extension' quite easily now, fulfilling what a lot of the comments are probably asking for.
2
u/ImpossibleAd436 Oct 24 '22
I really like the idea of this, thanks for working on it, hopefully it can be implemented the popular GUIs going forward.
2
u/Interesting-Bug-3636 Oct 24 '22
Can't seem to find the script from webui. Can you explain how to install this?
1
u/Silvia_Kitty Oct 25 '22
is it possible to make this work with vae weights?
1
u/thunder-t Oct 25 '22
This is absolutely fantastic!!! I've been waiting for weeks for someone amazing to develop something that can interpolate between two random pictures!
Along with the seed travel script, you can now things like:
Awesome work! You're one of the good ones.
Just a quick question: I've noticed that the while the images interpolate, the colors don't. For example, if I start from a black & white sketch to a color picture, it will maintain the black & white composition all throughout the process and arrive at the 2nd picture without introducing color. Do you know why?
1
u/AsDaim Oct 26 '22
Thank you, this is great!
I have a question though... why does it seem impossible--in contrast with say ArtBreeder's portrait mode--to get genuinely smooth transitions that do not have sudden jumps?
Is it technologically impossible due to the way StableDiffusion works and/or was trained? Or it's just not how your script does things, but theoretically it could be done?
1
u/Razunter Oct 30 '22
Optimal samplers, steps, denoising? Inpainting model or normal?
1
u/pinthead Nov 09 '22
this looks awesome, I need to test this.. any thoughts on how to interpolate between x amount of images ?
1
u/diditforthevideocard Jan 27 '23
Is it possible to choose the seed for the 2nd image?
3
u/Daralima Oct 24 '22
This seems really neat, bet you can have a lot of fun messing around with this.
2
u/Striking-Long-2960 Oct 24 '22 edited Oct 24 '22
Thanks. I want to try the interpolation between 2 input images,, it sounds interesting.
I think that the animation guys are going to find this script really useful.
1
u/BackgroundFeeling707 Oct 25 '22
Can you make it make videos traveling between the images?
1
u/BackyardAnarchist Mar 15 '23
Hey just found this. I was working on an idea and found this thread while researching, do you interpolate in picle space or latent space? Do you thinkbit would be posible to extrapolate between two images? Such as a base image then the base image with an art style added to it. Then extrapolating along the vector that you would make durring interpolation. To get a image with even more style applied?
1
u/mr-asa Jun 21 '23
Very useful stuff, thanks a lot! It turned out to make the slideshow more interesting than just switching frames =)
0
u/[deleted] Oct 24 '22
[deleted] — view deleted comment