MCPcopy Index your code
hub / github.com/nateraw/stable-diffusion-videos

github.com/nateraw/stable-diffusion-videos @v0.9.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.9.2 ↗ · + Follow
65 symbols 314 edges 11 files 20 documented · 31% updated 6mo agov0.9.2 · 2025-12-16★ 4,69949 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

stable-diffusion-videos

Try it yourself in Colab: Open In Colab

Example - morphing between "blueberry spaghetti" and "strawberry spaghetti"

https://user-images.githubusercontent.com/32437151/188721341-6f28abf9-699b-46b0-a72e-fa2a624ba0bb.mp4

Installation

pip install stable_diffusion_videos

Usage

Check out the examples folder for example scripts 👀

Making Videos

Note: For Apple M1 architecture, use torch.float32 instead, as torch.float16 is not available on MPS.

from stable_diffusion_videos import StableDiffusionWalkPipeline
import torch

pipeline = StableDiffusionWalkPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    torch_dtype=torch.float16,
).to("cuda")

video_path = pipeline.walk(
    prompts=['a cat', 'a dog'],
    seeds=[42, 1337],
    num_interpolation_steps=3,
    height=512,  # use multiples of 64 if > 512. Multiples of 8 if < 512.
    width=512,   # use multiples of 64 if > 512. Multiples of 8 if < 512.
    output_dir='dreams',        # Where images/videos will be saved
    name='animals_test',        # Subdirectory of output_dir where images/videos will be saved
    guidance_scale=8.5,         # Higher adheres to prompt more, lower lets model take the wheel
    num_inference_steps=50,     # Number of diffusion steps per image generated. 50 is good default
)

Making Music Videos

New! Music can be added to the video by providing a path to an audio file. The audio will inform the rate of interpolation so the videos move to the beat 🎶

from stable_diffusion_videos import StableDiffusionWalkPipeline
import torch

pipeline = StableDiffusionWalkPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    torch_dtype=torch.float16,
).to("cuda")

# Seconds in the song.
audio_offsets = [146, 148]  # [Start, end]
fps = 30  # Use lower values for testing (5 or 10), higher values for better quality (30 or 60)

# Convert seconds to frames
num_interpolation_steps = [(b-a) * fps for a, b in zip(audio_offsets, audio_offsets[1:])]

video_path = pipeline.walk(
    prompts=['a cat', 'a dog'],
    seeds=[42, 1337],
    num_interpolation_steps=num_interpolation_steps,
    audio_filepath='audio.mp3',
    audio_start_sec=audio_offsets[0],
    fps=fps,
    height=512,  # use multiples of 64 if > 512. Multiples of 8 if < 512.
    width=512,   # use multiples of 64 if > 512. Multiples of 8 if < 512.
    output_dir='dreams',        # Where images/videos will be saved
    guidance_scale=7.5,         # Higher adheres to prompt more, lower lets model take the wheel
    num_inference_steps=50,     # Number of diffusion steps per image generated. 50 is good default
)

Using the UI

from stable_diffusion_videos import StableDiffusionWalkPipeline, Interface
import torch

pipeline = StableDiffusionWalkPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    torch_dtype=torch.float16,
).to("cuda")

interface = Interface(pipeline)
interface.launch()

Credits

This work built off of a script shared by @karpathy. The script was modified to this gist, which was then updated/modified to this repo.

Contributing

You can file any issues/feature requests here

Enjoy 🤗

Core symbols most depended-on inside this repo

from_pretrained
called by 10
stable_diffusion_videos/upsampling.py
walk
called by 6
stable_diffusion_videos/stable_diffusion_pipeline.py
get_timesteps_arr
called by 4
stable_diffusion_videos/utils.py
make_video_pyav
called by 4
stable_diffusion_videos/utils.py
slerp
called by 3
stable_diffusion_videos/utils.py
pad_along_axis
called by 3
stable_diffusion_videos/utils.py
embed_text
called by 3
stable_diffusion_videos/stable_diffusion_pipeline.py
prepare_inputs
called by 3
stable_diffusion_videos/flax_stable_diffusion_pipeline.py

Shape

Method 31
Function 29
Class 5

Languages

Python100%

Modules by API surface

stable_diffusion_videos/flax_stable_diffusion_pipeline.py16 symbols
stable_diffusion_videos/stable_diffusion_pipeline.py12 symbols
examples/run_music_video_app.py8 symbols
stable_diffusion_videos/image_generation.py6 symbols
tests/test_pipeline.py5 symbols
stable_diffusion_videos/upsampling.py5 symbols
stable_diffusion_videos/app.py5 symbols
stable_diffusion_videos/utils.py4 symbols
stable_diffusion_videos/__init__.py4 symbols

Dependencies from manifests, versioned

av
fire
fsspec2023.4.0 · 1×
realesrgan
transformers4.21.0 · 1×

For agents

$ claude mcp add stable-diffusion-videos \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact