• Stars
    star
    262
  • Rank 156,136 (Top 4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 1 year ago
  • Updated 22 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a CLI utility/library for AnimateDiff stable diffusion generation

animatediff

pre-commit.ci status

animatediff refactor, because I can. with significantly lower VRAM usage.

Also, infinite generation length support! yay!

LoRA loading is ABSOLUTELY NOT IMPLEMENTED YET!

PRs welcome! πŸ˜†πŸ˜…

This can theoretically run on CPU, but it's not recommended. Should work fine on a GPU, nVidia or otherwise, but I haven't tested on non-CUDA hardware. Uses PyTorch 2.0 Scaled-Dot-Product Attention (aka builtin xformers) by default, but you can pass --xformers to force using xformers if you really want.

How to use

I should write some more detailed steps, but here's the gist of it:

git clone https://github.com/neggles/animatediff-cli
cd animatediff-cli
python3.10 -m venv .venv
source .venv/bin/activate
# install Torch. Use whatever your favourite torch version >= 2.0.0 is, but, good luck on non-nVidia...
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# install the rest of all the things (probably! I may have missed some deps.)
python -m pip install -e '.[dev]'
# you should now be able to
animatediff --help
# There's a nice pretty help screen with a bunch of info that'll print here.

From here you'll need to put whatever checkpoint you want to use into data/models/sd, copy one of the prompt configs in config/prompts, edit it with your choices of prompt and model (model paths in prompt .json files are relative to data/, e.g. models/sd/vanilla.safetensors), and off you go.

Then it's something like (for an 8GB card):

animatediff generate -c 'config/prompts/waifu.json' -W 576 -H 576 -L 128 -C 16

You may have to drop -C down to 8 on cards with less than 8GB VRAM, and you can raise it to 20-24 on cards with more. 24 is max.

N.B. generating 128 frames is slow...

RiFE!

I have added experimental support for rife-ncnn-vulkan using the animatediff rife interpolate command. It has fairly self-explanatory help, and it has been tested on Linux, but I've no idea if it'll work on Windows.

Either way, you'll need ffmpeg installed on your system and present in PATH, and you'll need to download the rife-ncnn-vulkan release for your OS of choice from the GitHub repo (above). Unzip it, and place the extracted folder at data/rife/. You should have a data/rife/rife-ncnn-vulkan executable, or data\rife\rife-ncnn-vulkan.exe on Windows.

You'll also need to reinstall the repo/package with:

python -m pip install -e '.[rife]'

or just install ffmpeg-python manually yourself.

Default is to multiply each frame by 8, turning an 8fps animation into a 64fps one, then encode that to a 60fps WebM. (If you pick GIF mode, it'll be 50fps, because GIFs are cursed and encode frame durations as 1/100ths of a second).

Seems to work pretty well...

TODO:

In no particular order:

  • Infinite generation length support
  • RIFE support for motion interpolation (rife-ncnn-vulkan isn't the greatest implementation)
  • Export RIFE interpolated frames to a video file (webm, mp4, animated webp, hevc mp4, gif, etc.)
  • Generate infinite length animations on a 6-8GB card (at 512x512 with 8-frame context, but hey it'll do)
  • Torch SDP Attention (makes xformers optional)
  • Support for clip_skip in prompt config
  • Experimental support for torch.compile() (upstream Diffusers bugs slow this down a little but it's still zippy)
  • Batch your generations with --repeat! (e.g. --repeat 10 will repeat all your prompts 10 times)
  • Call the animatediff.cli.generate() function from another Python program without reloading the model every time
  • Drag remaining old Diffusers code up to latest (mostly)
  • Add a webUI (maybe, there are people wrapping this already so maybe not?)
  • img2img support (start from an existing image and continue)
  • Stop using custom modules where possible (should be able to use Diffusers for almost all of it)
  • Automatic generate-then-interpolate-with-RIFE mode

Credits:

see guoyww/AnimateDiff (very little of this is my work)

n.b. the copyright notice in COPYING is missing the original authors' names, solely because the original repo (as of this writing) has no name attached to the license. I have, however, used the same license they did (Apache 2.0).

More Repositories

1

cm4io-fan

CM4 IO board PWM fan controller driver
C
65
star
2

cfxsx

CFexpress to M.2 NVMe drive adapter. Intended for Xbox Series X and S, but untested.
Makefile
57
star
3

sd-webui-docker

Dockerfile
38
star
4

wdv3-timm

Python
22
star
5

linux-quartz64

Development kernel for QuartzPro64
C
17
star
6

neurosis

a neural network trainer for weebs
Python
11
star
7

sd-webui-stealth-pnginfo

the prompt is coming from INSIDE THE PIXELS
Python
8
star
8

sd-webui-tag-separator

Python
7
star
9

disco-snake

a discord ai chatbot thing
Python
6
star
10

sd-webui-arc

temporary Intel Arc-enabled (maybe) version of @AUTOMATIC1111/stable-diffusion-webui
Python
6
star
11

esp32-cantroller

ESP32-S2-WROVER/WROOM based CANBUS controller thingy.
KiCad Layout
5
star
12

flatpack2-adapter

my take on the Eltek Flatpack2 PSU adapter board
KiCad Layout
5
star
13

middleflare

Traefik middleware to force-overwrite X-Forwarded-For and X-Real-IP with CF-Connecting-IP
Go
4
star
14

twrp_device_htc_rtx

twrp device tree for HTC 5G Hub (rtx)
Makefile
3
star
15

flatpack2s2

C
3
star
16

attiny85-blinky

Blinky shenanigans for ATtiny85/Gemma/Trinket and WS2812B LEDs
Eagle
2
star
17

octeon-sdk-51

Octeon SDK v5.1. Please do not fork this repo, GitHub LFS will charge me for clones of your fork.
C
2
star
18

u-boot-quartz64

C
2
star
19

linux-openwrt

kernel trees with openwrt patches applied don't @ me
C
2
star
20

ota-extract

Python
2
star
21

sd-webui-pngcrypto

Python
2
star
22

masquerade

Python
2
star
23

mpcie-gnss

Makefile
2
star
24

musicgen-web

Python
2
star
25

otg-gadget-setup

Shell
2
star
26

kicad-project-templates

my kicad project templates
HTML
2
star
27

invisible-watermark

Python
1
star
28

pjled

pijuice led script
Python
1
star
29

pdfunlock

Python
1
star
30

poky-zynq

my yocto repo for zynq-7000 board shenanigans
Python
1
star
31

zynq_boards

C
1
star
32

sbci

Shell
1
star
33

mpcie-lea-m8t

Makefile
1
star
34

linux-manjaro

C
1
star
35

dph151-binwalk

AT&T DPH-151 femtocell firmware partitions/files extracted via binwalk
Tcl
1
star
36

rk35xx-dumper

C
1
star
37

esphome-components

my esphome custom components
C++
1
star
38

dph154-gpl

C
1
star
39

ixgbe-dkms

ixgbe as a dkms module (for Pis, mostly)
C
1
star
40

mu_oem_moof

C
1
star
41

android_device_htc_rtx

Shell
1
star
42

flashpi

Makefile
1
star
43

u-boot-rockchip

my fork of https://gitlab.com/pgwipeout/u-boot-rockchip.git
C
1
star
44

libssh

mirror of libssh for some minor esp32 tweaks
C
1
star
45

fiodiskmark

Shell
1
star
46

mist-ap41

Shell
1
star
47

wireviz-templates

my wireviz template outputs
HTML
1
star
48

unifibrowser

PHP
1
star
49

PSHyperTools

PowerShell
1
star
50

er-build

C
1
star
51

netconf-util

some netconf-y helper functions for some shenanigans
Python
1
star
52

nightshade

Python
1
star
53

u-boot-udr

ubiquiti UDR GPL source for u-boot
C
1
star
54

llamahat

Python
1
star
55

cros-flashrom

flashrom but for chromeos i guess
C
1
star
56

CrashForge

Flashforge 3d Printer Unlocker
Shell
1
star
57

EnviroNode

ESP8266/Losant environmental monitoring node
C++
1
star
58

neggles.github.io

root GitHub Page
SCSS
1
star
59

esp-pmsa

KiCad Layout
1
star
60

minipitft

DKMS package for adafruit minipitft modules
C
1
star
61

bme68x-idf-example

C
1
star
62

pocket-network-analyzer

Web GUI and custom scripts to turn a debian operating system into a network analyzing machine. Wireless and wired speed tests ookla and fast.com as sources, plus a custom implementation of iperf3 for self hosted results. Perfect for install techs.
JavaScript
1
star
63

jetson-multimedia-api

samples out of the l4t jetson multimedia api package
HTML
1
star
64

tensorpods

Dockerfile
1
star
65

linux-edgerouter

Ubiquiti EdgeRouter GPL kernel sources, primarily for devices I own. Open an issue if you'd like another tarball added :)
C
1
star
66

docker-smokeping

1
star