Spaces:
Runtime error
Runtime error
pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+189828c.d20221207-cp38-cp38-linu | |
!wget https://raw.githubusercontent.com/hmartiro/riffusion-inference/main/riffusion/audio.py | |
import gradio as gr | |
import torch | |
from diffusers import StableDiffusionPipeline | |
from audio import wav_bytes_from_spectrogram_image | |
model_id = "riffusion/riffusion-model-v1" | |
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) | |
pipe = pipe.to("cuda") | |
#pipe.enable_xformers_memory_efficient_attention() | |
import random | |
COLORS = [ | |
["#ff0000", "#00ff00"], | |
["#00ff00", "#0000ff"], | |
["#0000ff", "#ff0000"], | |
] | |
from diffusers import StableDiffusionPipeline | |
import torch | |
img_model_id = "runwayml/stable-diffusion-v1-5" | |
img_pipe = StableDiffusionPipeline.from_pretrained(img_model_id, torch_dtype=torch.float16, revision="fp16") | |
img_pipe = img_pipe.to("cuda") | |
#img_pipe.enable_xformers_memory_efficient_attention() | |
prompt = 'morning sunshine' | |
spectogram = pipe(prompt).images[0] | |
wav = wav_bytes_from_spectrogram_image(spectogram) | |
with open("output.wav", "wb") as f: | |
f.write(wav[0].getbuffer()) | |
def audio_gen(prompt): | |
spectogram = pipe(prompt).images[0] | |
wav = wav_bytes_from_spectrogram_image(spectogram) | |
with open("output.wav", "wb") as f: | |
f.write(wav[0].getbuffer()) | |
print("audio saved") | |
return ('output.wav',) | |
audio_gen("lazy nights") | |
gr.Interface( | |
audio_gen, | |
inputs=[gr.Textbox(label="prompt")], | |
outputs=[ | |
gr.Audio(type='filepath') | |
], | |
title = 'Music Generator' | |
).launch(debug = True) | |