Skip to content
Gopal Chand edited this page Dec 28, 2023 · 20 revisions

The RotoPy Wiki: A step-by-step guide using Stable Diffusion

rotopy

Starting point

Let's start with the following image: 1980s_computer_worker,_Centers_for_Disease_Control

Upload into Stable Diffusion

version: [v1.7.0]  •  python: 3.10.6  •  torch: 2.0.1+cu118  •  xformers: 0.0.20  •  gradio: 3.41.2

Options are

--xformers --opt-sdp-attention --no-half-vae

The model I have chosen is juggernaut_v7Randidiffusion

Save the file in the appropriate models folder.

Go to the img2img tab in Stable Diffusion, refresh the model list and select the juggernaut_v7Randidiffusion model.

Run Image2Image in a Loop

The prompt is:

woman working at a computer terminal

The negative prompt is:

lores, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, extra arms, extra legs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers

Main parameters:

  • Sampling steps = 20 (default)
  • Width = 640
  • Height = 512
  • Batch count = 1 (default)
  • Batch size = 1 (default)
  • CFG Scale = 7 (default)
  • Denoising strength = 0.5
  • Seed = 217832897234 (you can use your own or use -1 to generate a new one)

Main parameter settings

  • Script = Loopback
  • Loops = 20
  • Final denoising strength = 0.75
  • Denoising strength curve = Aggressive
  • Append interrogated prompt at each iteration = CLIP

Parameter settings for loopback script

Hit generate and find the results folder for Stable Diffusion for today's date: stable-diffusion-webui\outputs\img2img-images\YYYY-MM-DD\

Image_list

Process the resulting files

exiftool (https://exiftool.org/) and ffmpeg (https://ffmpeg.org/) must be installed. Ensure that the directories for the binaries are in the PATH: exiftool.exe and ffmpeg.exe (use this for assistance: https://www.computerhope.com/issues/ch000549.htm#windows10)

Check that exiftool.exe and ffmpeg.exe can be run from a command prompt.

pip install opencv-python
git clone https://github.com/gopalchand/rotopy
cd rotopy

Copy the relevant Stable Diffusion PNG files to the input folder under rotify

python rotopy.py --annotate

The resulting movie file can now be viewed as output.mkv in the output folder. Use the --framerate option to slow it down (be aware that the last frame may be display in the video player as a known issue with FFMPEG and non-default framerates):

python rotopy.py --annotate --framerate 2 --overwritemovie

--framerate 2 will create a movie with a framerate of 2 per second. --overwritemovie will overwrite the output.mkv file without prompting.

Files produced over multiple should be renamed to put them in the right order:

python rotopy.py --annotate --framerate 1 --overwritemovie

The resulting movie file at 1 frame per second can now be viewed as output.mkv in the output folder.

example_frame