Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,11 +8,12 @@ from diffusers import StableDiffusionImg2ImgPipeline
|
|
| 8 |
|
| 9 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 10 |
|
|
|
|
| 11 |
MODEL_ID = "riffusion/riffusion-model-v1"
|
| 12 |
pipe = StableDiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.float16)
|
| 13 |
-
pipe = pipe.to(
|
| 14 |
pipe2 = StableDiffusionImg2ImgPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.float16)
|
| 15 |
-
pipe2 = pipe2.to(
|
| 16 |
|
| 17 |
spectro_from_wav = gr.Interface.load("spaces/fffiloni/audio-to-spectrogram")
|
| 18 |
|
|
@@ -36,7 +37,7 @@ def classic(prompt, negative_prompt, duration):
|
|
| 36 |
|
| 37 |
def style_transfer(prompt, negative_prompt, audio_input):
|
| 38 |
spec = spectro_from_wav(audio_input)
|
| 39 |
-
new_spectro = pipe2(prompt=prompt,
|
| 40 |
wav = wav_bytes_from_spectrogram_image(new_spectro[0])
|
| 41 |
with open("output.wav", "wb") as f:
|
| 42 |
f.write(wav[0].getbuffer())
|
|
|
|
| 8 |
|
| 9 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 10 |
|
| 11 |
+
device = "cuda"
|
| 12 |
MODEL_ID = "riffusion/riffusion-model-v1"
|
| 13 |
pipe = StableDiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.float16)
|
| 14 |
+
pipe = pipe.to(device)
|
| 15 |
pipe2 = StableDiffusionImg2ImgPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.float16)
|
| 16 |
+
pipe2 = pipe2.to(device)
|
| 17 |
|
| 18 |
spectro_from_wav = gr.Interface.load("spaces/fffiloni/audio-to-spectrogram")
|
| 19 |
|
|
|
|
| 37 |
|
| 38 |
def style_transfer(prompt, negative_prompt, audio_input):
|
| 39 |
spec = spectro_from_wav(audio_input)
|
| 40 |
+
new_spectro = pipe2(prompt=prompt, init_image=spec, strength=0.5, guidance_scale=7).images
|
| 41 |
wav = wav_bytes_from_spectrogram_image(new_spectro[0])
|
| 42 |
with open("output.wav", "wb") as f:
|
| 43 |
f.write(wav[0].getbuffer())
|