riffusion-hobby

Stable diffusion for real-time music generation

https://github.com/riffusion/riffusion-hobby

Science Score: 31.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (18.2%) to scientific vocabulary

Keywords

ai audio diffusers diffusion music stable-diffusion
Last synced: 6 months ago · JSON representation ·

Repository

Stable diffusion for real-time music generation

Basic Info
  • Host: GitHub
  • Owner: riffusion
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 8.06 MB
Statistics
  • Stars: 3,778
  • Watchers: 43
  • Forks: 458
  • Open Issues: 69
  • Releases: 1
Topics
ai audio diffusers diffusion music stable-diffusion
Created about 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

:guitar: Riffusion (hobby)

:no_entry: This project is no longer actively maintained.

CI status Python 3.9 | 3.10 MIT License

Riffusion is a library for real-time music and audio generation with stable diffusion.

Read about it at https://www.riffusion.com/about and try it at https://www.riffusion.com/.

This is the core repository for riffusion image and audio processing code.

  • Diffusion pipeline that performs prompt interpolation combined with image conditioning
  • Conversions between spectrogram images and audio clips
  • Command-line interface for common tasks
  • Interactive app using streamlit
  • Flask server to provide model inference via API
  • Various third party integrations

Related repositories: * Web app: https://github.com/riffusion/riffusion-app * Model checkpoint: https://huggingface.co/riffusion/riffusion-model-v1

Citation

If you build on this work, please cite it as follows:

@article{Forsgren_Martiros_2022, author = {Forsgren, Seth* and Martiros, Hayk*}, title = {{Riffusion - Stable diffusion for real-time music generation}}, url = {https://riffusion.com/about}, year = {2022} }

Install

Tested in CI with Python 3.9 and 3.10.

It's highly recommended to set up a virtual Python environment with conda or virtualenv: conda create --name riffusion python=3.9 conda activate riffusion

Install Python dependencies: python -m pip install -r requirements.txt

In order to use audio formats other than WAV, ffmpeg is required. sudo apt-get install ffmpeg # linux brew install ffmpeg # mac conda install -c conda-forge ffmpeg # conda

If torchaudio has no backend, you may need to install libsndfile. See this issue.

If you have an issue, try upgrading diffusers. Tested with 0.9 - 0.11.

Guides: * Simple Install Guide for Windows

Backends

CPU

cpu is supported but is quite slow.

CUDA

cuda is the recommended and most performant backend.

To use with CUDA, make sure you have torch and torchaudio installed with CUDA support. See the install guide or stable wheels.

To generate audio in real-time, you need a GPU that can run stable diffusion with approximately 50 steps in under five seconds, such as a 3090 or A10G.

Test availability with:

python3 import torch torch.cuda.is_available()

MPS

The mps backend on Apple Silicon is supported for inference but some operations fall back to CPU, particularly for audio processing. You may need to set PYTORCH_ENABLE_MPS_FALLBACK=1.

In addition, this backend is not deterministic.

Test availability with:

python3 import torch torch.backends.mps.is_available()

Command-line interface

Riffusion comes with a command line interface for performing common tasks.

See available commands: python -m riffusion.cli -h

Get help for a specific command: python -m riffusion.cli image-to-audio -h

Execute: python -m riffusion.cli image-to-audio --image spectrogram_image.png --audio clip.wav

Riffusion Playground

Riffusion contains a streamlit app for interactive use and exploration.

Run with: python -m riffusion.streamlit.playground

And access at http://127.0.0.1:8501/

Riffusion Playground

Run the model server

Riffusion can be run as a flask server that provides inference via API. This server enables the web app to run locally.

Run with:

python -m riffusion.server --host 127.0.0.1 --port 3013

You can specify --checkpoint with your own directory or huggingface ID in diffusers format.

Use the --device argument to specify the torch device to use.

The model endpoint is now available at http://127.0.0.1:3013/run_inference via POST request.

Example input (see InferenceInput for the API): ``` { "alpha": 0.75, "numinferencesteps": 50, "seedimageid": "og_beat",

"start": { "prompt": "church bells on sunday", "seed": 42, "denoising": 0.75, "guidance": 7.0 },

"end": { "prompt": "jazz with piano", "seed": 123, "denoising": 0.75, "guidance": 7.0 } } ```

Example output (see InferenceOutput for the API): { "image": "< base64 encoded JPEG image >", "audio": "< base64 encoded MP3 clip >" }

Tests

Tests live in the test/ directory and are implemented with unittest.

To run all tests: python -m unittest test/*_test.py

To run a single test: python -m unittest test.audio_to_image_test

To preserve temporary outputs for debugging, set RIFFUSION_TEST_DEBUG: RIFFUSION_TEST_DEBUG=1 python -m unittest test.audio_to_image_test

To run a single test case within a test: python -m unittest test.audio_to_image_test -k AudioToImageTest.test_stereo

To run tests using a specific torch device, set RIFFUSION_TEST_DEVICE. Tests should pass with cpu, cuda, and mps backends.

Development Guide

Install additional packages for dev with python -m pip install -r requirements_dev.txt.

  • Linter: ruff
  • Formatter: black
  • Type checker: mypy

These are configured in pyproject.toml.

The results of mypy ., black ., and ruff . must be clean to accept a PR.

CI is run through GitHub Actions from .github/workflows/ci.yml.

Contributions are welcome through pull requests.

Owner

  • Name: Riffusion
  • Login: riffusion
  • Kind: organization

Stable diffusion for real-time music generation

Citation (CITATION)

@article{Forsgren_Martiros_2022,
  author = {Forsgren, Seth* and Martiros, Hayk*},
  title = {{Riffusion - Stable diffusion for real-time music generation}},
  url = {https://riffusion.com/about},
  year = {2022}
}

GitHub Events

Total
  • Issues event: 6
  • Watch event: 363
  • Issue comment event: 10
  • Pull request event: 2
  • Fork event: 71
Last Year
  • Issues event: 6
  • Watch event: 363
  • Issue comment event: 10
  • Pull request event: 2
  • Fork event: 71

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 117
  • Total Committers: 6
  • Avg Commits per committer: 19.5
  • Development Distribution Score (DDS): 0.128
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Hayk Martiros h****t@g****m 102
Seth Forsgren f****h@g****m 8
Jasper 3****y 3
Dan d****8@g****m 2
ilayluz i****z@g****m 1
Veeral Patel v****4@g****m 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 98
  • Total pull requests: 66
  • Average time to close issues: 15 days
  • Average time to close pull requests: 14 days
  • Total issue authors: 70
  • Total pull request authors: 20
  • Average comments per issue: 1.98
  • Average comments per pull request: 1.64
  • Merged pull requests: 45
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 5
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 5
  • Pull request authors: 2
  • Average comments per issue: 0.6
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • hmartiro (20)
  • gitihobo (3)
  • mepc36 (2)
  • tralala87 (2)
  • eran-sefirot (2)
  • wedgeewoo (2)
  • ukemamaster (2)
  • prescience-data (2)
  • cosmowind (2)
  • anoadragon453 (1)
  • wangjifly1 (1)
  • amiran-gorgazjan (1)
  • shiloh92 (1)
  • materialvision (1)
  • LiquidPlutonium (1)
Pull Request Authors
  • hmartiro (46)
  • daanelson (3)
  • Yuan-ManX (2)
  • gu-ma (2)
  • prescience-data (2)
  • deepfates (2)
  • ilayluz (1)
  • veeral-patel (1)
  • handsomepwy (1)
  • wesleygriffin (1)
  • mrsndmn (1)
  • christopherwoodall (1)
  • piiq (1)
  • kingcocomango (1)
  • J4BEZ (1)
Top Labels
Issue Labels
enhancement (5) bug (3) build (2) playground (2) install (1) test (1) integrations (1) question (1) model (1)
Pull Request Labels
playground (3) audio (1)

Dependencies

requirements.txt pypi
  • accelerate *
  • argh *
  • dacite *
  • diffusers *
  • flask *
  • flask_cors *
  • numpy *
  • pillow *
  • pydub *
  • scipy *
  • torch *
  • torchaudio *
  • transformers *
.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/black.yml actions
  • actions/checkout v2 composite
  • psf/black stable composite
.github/workflows/mypy.yml actions
  • actions/checkout v3 composite
  • jpetrucciani/mypy-check master composite
.github/workflows/pip.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/ruff.yml actions
  • actions/checkout v2 composite
  • jpetrucciani/ruff-check main composite
pyproject.toml pypi
requirements_all.txt pypi
requirements_dev.txt pypi
  • black * development
  • ipdb * development
  • mypy * development
  • ruff * development
  • types-Flask-Cors * development
  • types-Pillow * development
  • types-requests * development
  • types-setuptools * development
  • types-tqdm * development
setup.py pypi