lauraibnz commited on
Commit
0291473
1 Parent(s): dd33e7a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import AudioLDMControlNetPipeline, ControlNetModel
3
+ from pretty_midi import PrettyMIDI
4
+ import torch
5
+
6
+ if torch.cuda.is_available():
7
+ device = "cuda"
8
+ torch_dtype = torch.float16
9
+ else:
10
+ device = "cpu"
11
+ torch_dtype = torch.float32
12
+
13
+ midi = PrettyMIDI("test.mid")
14
+
15
+ controlnet = ControlNetModel.from_pretrained("lauraibnz/midi-audioldm", torch_dtype=torch_dtype)
16
+ pipe = AudioLDMControlNetPipeline.from_pretrained("cvssp/audioldm-m-full", controlnet=controlnet, torch_dtype=torch_dtype)
17
+ pipe = pipe.to(device)
18
+
19
+ audio = pipe("techno", audio_length_in_s=10, num_inference_steps=20, midi=midi, controlnet_conditioning_scale=1.0)