Spaces:
Running
on
Zero
Running
on
Zero
Nithya
commited on
Commit
·
e6346a3
1
Parent(s):
e03a998
made small changes
Browse files
app.py
CHANGED
@@ -1,3 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
@@ -5,12 +21,8 @@ import torch
|
|
5 |
import librosa
|
6 |
import matplotlib.pyplot as plt
|
7 |
import pandas as pd
|
8 |
-
import os
|
9 |
from functools import partial
|
10 |
import gin
|
11 |
-
from gamadhani.utils.generate_utils import load_pitch_fns, load_audio_fns
|
12 |
-
import gamadhani.utils.pitch_to_audio_utils as p2a
|
13 |
-
from gamadhani.utils.utils import get_device
|
14 |
import torchaudio
|
15 |
from absl import app
|
16 |
from torch.nn.functional import interpolate
|
@@ -19,6 +31,11 @@ import crepe
|
|
19 |
from hmmlearn import hmm
|
20 |
import soundfile as sf
|
21 |
import pdb
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
pitch_path = 'models/diffusion_pitch/'
|
24 |
audio_path = 'models/pitch_to_audio/'
|
@@ -124,11 +141,13 @@ pitch_model, pitch_qt, pitch_task_fn, invert_pitch_fn, _ = load_pitch_fns(
|
|
124 |
model_type = 'diffusion', \
|
125 |
config_path = os.path.join(pitch_path, 'config.gin'), \
|
126 |
qt_path = os.path.join(pitch_path, 'qt.joblib'), \
|
|
|
127 |
)
|
128 |
audio_model, audio_qt, audio_seq_len, invert_audio_fn = load_audio_fns(
|
129 |
os.path.join(audio_path, 'last.ckpt'),
|
130 |
qt_path = os.path.join(audio_path, 'qt.joblib'),
|
131 |
-
config_path = os.path.join(audio_path, 'config.gin')
|
|
|
132 |
)
|
133 |
partial_generate = partial(generate, num_samples=1, num_steps=100, singers=[3], outfolder=None, pitch_qt=pitch_qt) # generate function with default arguments
|
134 |
|
@@ -187,4 +206,4 @@ def main(argv):
|
|
187 |
demo.launch(share=True)
|
188 |
|
189 |
if __name__ == '__main__':
|
190 |
-
|
|
|
1 |
+
import sys
|
2 |
+
import os
|
3 |
+
# Check if running in debug mode
|
4 |
+
debug_mode = '--debug' in sys.argv or os.environ.get('DEBUG') == 'True'
|
5 |
+
|
6 |
+
if debug_mode:
|
7 |
+
# Path to the local version of the package
|
8 |
+
local_package_path = "../../GaMaDHaNi"
|
9 |
+
|
10 |
+
# Add the local package path to sys.path
|
11 |
+
sys.path.insert(0, local_package_path)
|
12 |
+
|
13 |
+
print(f"Running in debug mode. Using package from: {local_package_path}")
|
14 |
+
else:
|
15 |
+
print("Running in normal mode. Using package from site-packages.")
|
16 |
+
|
17 |
import spaces
|
18 |
import gradio as gr
|
19 |
import numpy as np
|
|
|
21 |
import librosa
|
22 |
import matplotlib.pyplot as plt
|
23 |
import pandas as pd
|
|
|
24 |
from functools import partial
|
25 |
import gin
|
|
|
|
|
|
|
26 |
import torchaudio
|
27 |
from absl import app
|
28 |
from torch.nn.functional import interpolate
|
|
|
31 |
from hmmlearn import hmm
|
32 |
import soundfile as sf
|
33 |
import pdb
|
34 |
+
from gamadhani.utils.generate_utils import load_pitch_fns, load_audio_fns
|
35 |
+
import gamadhani.utils.pitch_to_audio_utils as p2a
|
36 |
+
from gamadhani.utils.utils import get_device
|
37 |
+
|
38 |
+
|
39 |
|
40 |
pitch_path = 'models/diffusion_pitch/'
|
41 |
audio_path = 'models/pitch_to_audio/'
|
|
|
141 |
model_type = 'diffusion', \
|
142 |
config_path = os.path.join(pitch_path, 'config.gin'), \
|
143 |
qt_path = os.path.join(pitch_path, 'qt.joblib'), \
|
144 |
+
device = device
|
145 |
)
|
146 |
audio_model, audio_qt, audio_seq_len, invert_audio_fn = load_audio_fns(
|
147 |
os.path.join(audio_path, 'last.ckpt'),
|
148 |
qt_path = os.path.join(audio_path, 'qt.joblib'),
|
149 |
+
config_path = os.path.join(audio_path, 'config.gin'),
|
150 |
+
device = device
|
151 |
)
|
152 |
partial_generate = partial(generate, num_samples=1, num_steps=100, singers=[3], outfolder=None, pitch_qt=pitch_qt) # generate function with default arguments
|
153 |
|
|
|
206 |
demo.launch(share=True)
|
207 |
|
208 |
if __name__ == '__main__':
|
209 |
+
main(sys.argv)
|