nateraw/stable-diffusion-videos

โ˜… 4,710โ‘‚ 443

Create ๐Ÿ”ฅ videos with Stable Diffusion by exploring the latent space and morphing between text prompts

About nateraw/stable-diffusion-videos

nateraw/stable-diffusion-videos is an open-source project on GitHub, mainly written in Python. Create ๐Ÿ”ฅ videos with Stable Diffusion by exploring the latent space and morphing between text prompts It currently holds 4,710 stars and 443 forks with 54 open issues, and was last pushed on 2025-12-16 (repository created 2022-09-06).

Project Overview

Git Homed tracks it on the Image Trending board and on the AI Image Trending list.

GitHub Repository Details

Repository nateraw/stable-diffusion-videos ยท default branch main ยท size 10213 KB ยท watchers 57 ยท source: GitHub REST API and repository README

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](https://gist.github.com/karpathy/00103b0037c5aaea32fe1da1af553355 ) 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 ๐Ÿค—

GitHub Stars & Activity

4,710Stars
443Forks
54Open issues
PythonLanguage

GitHub Popularity

GitHub stars4,710
Forks443
Open issues54
Primary languagePython
LicenseApache-2.0
Stars gained today0
Created2022-09-06
Last pushed2025-12-16

Trending History

Trending statusnot on today's boards

Related GitHub Projects

1

AUTOMATIC1111 / stable-diffusion-webui

Pythonโ˜… 165,040โ‘‚ 0
โ†’
2

Comfy-Org / ComfyUI

Pythonโ˜… 136,784โ‘‚ 0
โ†’
3

unslothai / unsloth

Pythonโ˜… 77,708โ‘‚ 0
โ†’
4

ultralytics / ultralytics

Pythonโ˜… 62,361โ‘‚ 0
โ†’
5

ultralytics / yolov5

Pythonโ˜… 58,135โ‘‚ 0
โ†’
6

roboflow / supervision

Pythonโ˜… 51,168โ‘‚ 0
โ†’
7

huggingface / diffusers

Pythonโ˜… 34,701โ‘‚ 0
โ†’
8

ATH-MaaS / Pixelle-Video

Pythonโ˜… 28,829โ‘‚ 0
โ†’

More Trending Repositories