Stable Diffusion Exodia (sd-exodia) is a utility program for generating high quality animation spritesheets with relatively low effort. It does this by taking in a "turntable" and "source" images, and using those to "render" out a full animation, as declared by the poses fed in.
pip install the following packages:
pip install opencv-python
pip install numpy
pip install rembg
NOTE: rembg
is not being used directly in python, but being called by the cmd command. The rembg
package has not been updated past python 3.9. If you are using a later python, you will need to install rembg
from an earlier python version, but can use the later python version to run this software.
- Create a folder within the
workspaces
folder and name it what you like. - Go into
settings.py
and, in the first line, change theWORKSPACE
variable to point to your new folder. - Your workspace will need some pose information. Either copy all of the contents of
workspaces/template
into your new workpsace, or create your own poses from scratch.
In the root of your workspace, you should find a turntable-pose.png image (copied from workspaces/template
). You will need to make an image through stable diffusion with that pose. This will be used in all of the Stable Diffusion runs, not being modified itself, but to act as a reference for how the characters in your animation should look. It is important to spend some time making this look nice and exactly how you want your resulting character to look, as everything else will be based on this turntable image.
Once you have a turntable image that you are happy with, place it in the root of your workspace (next to turntable-pose.png
) and rename the new image to turntable-image.png
.
NOTE: This and the following steps will have to be done per animation folder (srun
, brun
, frun
, etc.)
- Call
python prep_source_run.py <anim_name>
where<anim_name>
is the animation you are doing next (e.g.python prep_source_run.py frun
) - You should see a
tmp
folder appear in your workspace. Navigate into that folder as well as the new folder created with your<anim_name>
from step (1). - Use
image.png
,pose.png
, andturntable-stripped.png
to create your source image. The source image should look likeimage.png
, but has your character in the right withpose.png
pose. - Once your source image has been made, throw it into
tmp/<anim_name>
next toimage.png
and rename the source image tosource.png
.
- Call
python split_source_run.py <anim_name>
, where<anim_name>
is the same name you used in the previous step. - Navigate to
comps/<anim_name>
and you should see newsource-image.png
andsource-stripped.png
images. - Open
source-stripped.png
in an image editing program (like Photoshop, I use Krita myself). - Extract each limb into a seperate layer and save these images. You should have 5 total - 2 arms, 2 legs, and a body. These have to be name
larm.png
,rarm.png
,lleg.png
,rleg.png
,body.png
. These go in thecomps/<anim_name>
folder next tosource-stripped.png
.
- Make sure your Automatic1111 webui is open and select the model you want to use (this program calls into the API).
- Open
render.py
and modify thechar_desc
,pos_prompt
, andneg_prompt
variables to contain your prompt information. Note that thechar_desc
gets put insidepos_prompt
by default. - Call
python render.py <anim_name>
and you should see images appearing inrenders/<anim_name>
. - If you want to change settings for how these are run, open
anims/<anim_name>/settings.py
. In here you can change what order images are spliced together and what stable diffusion settings are used (steps, denoising strength, etc.).
- This tooling also has an option to run these images again, but with more animations pulled into the context.
- To change settings, edit the top of
iterate.py
. TheIMGS_LEFT
andIMGS_RIGHT
variables will pull in more images, but not that this will require more VRAM. - Call
python iterate.py <anim_name>
to run an iteration. This can be done as many times as you like, always iterating on the previous iteration. - To "rerun" an iteration, delete the
.iterXXX
file inrenders/<anim_name>
. E.g. if you have runrender.py
and then raniterate.py
twice, you should see.iter000
,.iter001
, and.iter002
. If you delete the.iter002
file and runiterate.py
, it will rerun your latest run, overwriting the results.
Once the above steps have been done for all of the animations, you can generate a spritesheet from the results.
- Open
spritesheet.py
and make sure all of the settings are correct.ANIMS_TO_JOIN
should have all of your folders, andDO_ALL
should be False if you have not done anything else (like interpolation). - If you want to alter what and how the spritesheet is constructed, you need to extract all of the images you want in it into seperate folders in the
render
directory. These folders need to contain only the images you want in the spritesheet. SetDO_ALL
to True and setANIMS_TO_JOIN
to the folder inrender
containing the images. - Call
python spritesheet.py
and you should see the result in your workspace root namedsheet.png
.