Hugo Flores Garcia commited on
Commit
57047e5
1 Parent(s): 22a680a

coarse eval

Browse files
conf/interface.yml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Interface.coarse_ckpt: /runs/jazzpop-coarse-1m-steps.pth
2
+ Interface.coarse2fine_ckpt: /runs/jazzpop-c2f.pth
3
+ Interface.codec_ckpt: /runs/codec-ckpt/codec.pth
4
+ Interface.coarse_chunk_size_s: 5
5
+ Interface.coarse2fine_chunk_size_s: 3
scripts/utils/vamp_folder.py CHANGED
@@ -6,7 +6,7 @@ import torch
6
 
7
  from vampnet.interface import Interface
8
 
9
- Interface = argbind.bind(Interface, positional=True)
10
 
11
  def baseline(sig, interface):
12
  return sig
@@ -26,7 +26,9 @@ def coarse2fine(sig, interface):
26
  def one_codebook(sig, interface):
27
  z = interface.encode(sig)
28
 
29
- mask = torch.zeros_like(z)
 
 
30
  mask[:, 1:, :] = 1
31
 
32
  zv = interface.coarse_vamp_v2(
@@ -46,7 +48,9 @@ def four_codebooks_downsampled_4x(sig, interface):
46
  def two_codebooks_downsampled_4x(sig, interface):
47
  z = interface.encode(sig)
48
 
49
- mask = torch.zeros_like(z)
 
 
50
  mask[:, 2:, :] = 1
51
 
52
  zv = interface.coarse_vamp_v2(
@@ -64,9 +68,6 @@ def four_codebooks_downsampled_8x(sig, interface):
64
  return interface.to_signal(zv)
65
 
66
 
67
-
68
-
69
-
70
  SAMPLE_CONDS ={
71
  "baseline": baseline,
72
  "reconstructed": reconstructed,
@@ -105,15 +106,15 @@ def main(
105
  sig = dataset[i]["signal"]
106
 
107
  results = {
108
- name: cond(sig, interface)
109
  for name, cond in SAMPLE_CONDS.items()
110
  }
111
 
112
  for name, sig in results.items():
113
- output_dir = Path(output_dir) / name
114
- output_dir.mkdir(exist_ok=True, parents=True)
115
 
116
- sig.write(output_dir / f"{i}.wav")
117
 
118
  if __name__ == "__main__":
119
  args = argbind.parse_args()
 
6
 
7
  from vampnet.interface import Interface
8
 
9
+ Interface = argbind.bind(Interface)
10
 
11
  def baseline(sig, interface):
12
  return sig
 
26
  def one_codebook(sig, interface):
27
  z = interface.encode(sig)
28
 
29
+ nb, _, nt = z.shape
30
+ nc = interface.coarse.n_codebooks
31
+ mask = torch.zeros(nb, nc, nt).to(interface.device)
32
  mask[:, 1:, :] = 1
33
 
34
  zv = interface.coarse_vamp_v2(
 
48
  def two_codebooks_downsampled_4x(sig, interface):
49
  z = interface.encode(sig)
50
 
51
+ nb, _, nt = z.shape
52
+ nc = interface.coarse.n_codebooks
53
+ mask = torch.zeros(nb, nc, nt).to(interface.device)
54
  mask[:, 2:, :] = 1
55
 
56
  zv = interface.coarse_vamp_v2(
 
68
  return interface.to_signal(zv)
69
 
70
 
 
 
 
71
  SAMPLE_CONDS ={
72
  "baseline": baseline,
73
  "reconstructed": reconstructed,
 
106
  sig = dataset[i]["signal"]
107
 
108
  results = {
109
+ name: cond(sig, interface).cpu()
110
  for name, cond in SAMPLE_CONDS.items()
111
  }
112
 
113
  for name, sig in results.items():
114
+ o_dir = Path(output_dir) / name
115
+ o_dir.mkdir(exist_ok=True, parents=True)
116
 
117
+ sig.write(o_dir / f"{i}.wav")
118
 
119
  if __name__ == "__main__":
120
  args = argbind.parse_args()
vampnet/interface.py CHANGED
@@ -23,17 +23,19 @@ def signal_concat(
23
  class Interface:
24
  def __init__(
25
  self,
26
- coarse_ckpt: str,
27
- coarse2fine_ckpt: str,
28
- codec_ckpt: str,
29
  device: str = "cpu",
30
  coarse_chunk_size_s: int = 5,
31
  coarse2fine_chunk_size_s: int = 3,
32
  ):
 
33
  self.codec = LAC.load(Path(codec_ckpt))
34
  self.codec.eval()
35
  self.codec.to(device)
36
 
 
37
  self.coarse = VampNet.load(location=Path(coarse_ckpt), map_location="cpu")
38
  self.coarse.to(device)
39
  self.coarse.eval()
 
23
  class Interface:
24
  def __init__(
25
  self,
26
+ coarse_ckpt: str = None,
27
+ coarse2fine_ckpt: str = None,
28
+ codec_ckpt: str = None,
29
  device: str = "cpu",
30
  coarse_chunk_size_s: int = 5,
31
  coarse2fine_chunk_size_s: int = 3,
32
  ):
33
+ assert codec_ckpt is not None, "must provide a codec checkpoint"
34
  self.codec = LAC.load(Path(codec_ckpt))
35
  self.codec.eval()
36
  self.codec.to(device)
37
 
38
+ assert coarse_ckpt is not None, "must provide a coarse checkpoint"
39
  self.coarse = VampNet.load(location=Path(coarse_ckpt), map_location="cpu")
40
  self.coarse.to(device)
41
  self.coarse.eval()