Stable Diffusion Loopback Wave Script
The loopback wave script is an img2img script which modulates the denoising strength in a sinusoidal fasion, then produces a video from it. The effect this produces is a "stable" image, followed by a gradual then drastic change to another image which then also stabilizes.
Outputs can be found in outputs/img2img-images/loopback-wave
Requirements
ffmpeg
needs to be installed. If its not on your PATH, you may need to manually specify the executable location.- For VP9 webm, ffmpeg must be compiled with
libvpx-vp9
- For VP8 webm, ffmpeg must be compiled with
libvpx
- For H.265 mp4, ffmpeg must be compiled with
libh265
- For H.264 mp4, ffmpeg must be compiled with
libh264
Installation and usage
- Get stable diffusion webui working
- Copy the script
- Save the script in stable-diffusion-ui/scripts
- Go to img2img with a good img.
- Select loopback wave from the scripts list
Parameters
Important Non-script params:
- Denoising Strength: Sets the lowest possible denoising strength used in the loopback
Script Params:
- Frames: 100
- Frames Per Wave: How many frames for a full cycle of stable/unstable.
- Max Additional Denoise: Maximum denoising strength to add to the base denoising strength
- Wave Offset: The offset from 0, in degrees, on the cos wave. Normally leave this at 0
- List of prompt changes: A line-separated list of prompts.
- Initial Image Number: The number of the first file produced
- Frames per second: 10
- Video Quality (crf): Quality setting to pass to ffmpeg. For VP9 webms, 30 is pretty good, 40 is still good but much smaller.
- Video Encoding: What encoding to use. VP9 is best, but the others are there for compatibility sake. Optimal CRF is different with different encodings.
For encoding, I fucked something up and 4chan hates my mp4 outputs. Stick to webms for now.
Prompt Changes
The Prompt Changes
text box can be used to change the prompt at a given frame. Simply type the frame number when you want the transition to occur, followed by ::
and then your prompt.
For example:
Would alter the prompt at frames 100 and 500 with the respective prompts.
Setting the seed
As of V1.3, it is possible to explicitly set the seed at a given frame.
For example:
At frame 100, we set the seed to 123 and keep it constant. Then at frame 500, the seed is changed to 654, but the seed is incremented every iteration. So the next image would be seed 655, then 656, 657, and so on.
Dynamic Weights
Weights can be set proportional to the current progress through a wave.
(foo:@wave_completed(0.5,1))
would modulate the weight of foo
from 0.5
to 1
with respect to the completed percent of the current waveform
(foo:@wave_remaining(0.5,1))
would modulate the weight of foo
from 1
to 0.5
with respect to the remaining percent of the current waveform
Example
The webm below was generated using the parameters beneath.
Docker Installation
- Edit stable-diffusion-webui-docker-master\services\AUTOMATIC1111\Dockerfile and add the following under the "RUN pip install opencv-python-headless..." command:
- Drop the script into stable-diffusion-webui-docker-master\data\config\auto\scripts\loopback_wave.py
- Restart the docker container and wait for ffmpeg to download, it will be cached on subsequent boots.
Changelog
V1.4.1
- Fixed wave weight functions
V1.4
- Added functions which allow weighting prompts dynamically according to wave transition
- Added @wave_remaining(min, max)
- Added @wave_completed(min, max)
V1.3
- Added explicit seed settings
- Added more params to the text file output.
V1.2
- Fixed FPS Bug
- Added
Initial Image Number
parameter
V1.1
- Added windows support
- Simplified some parameters