asigalov61 commited on
Commit
ed77379
1 Parent(s): 6c6632f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -27,7 +27,7 @@ def GenerateMIDI():
27
  return_prime=False
28
  progress=gr.Progress()
29
 
30
- out = torch.LongTensor([start_tokens])
31
 
32
  st = len(start_tokens)
33
 
@@ -35,11 +35,12 @@ def GenerateMIDI():
35
  print("Generating sequence of max length:", seq_len)
36
 
37
  progress(0, desc="Starting...")
38
-
39
- for i in progress.tqdm(range(seq_len)):
40
 
41
- try:
42
- with torch.no_grad():
 
 
 
43
  x = out[:, -max_seq_len:]
44
 
45
  torch_in = x.tolist()[0]
@@ -51,10 +52,10 @@ def GenerateMIDI():
51
  sample = torch.multinomial(probs, 1)
52
 
53
  out = torch.cat((out, sample), dim=-1)
54
-
55
- except Exception as e:
56
- print('Error', e)
57
- break
58
 
59
  if return_prime:
60
  melody_chords_f = out[:, :]
 
27
  return_prime=False
28
  progress=gr.Progress()
29
 
30
+ out = torch.FloatTensor([start_tokens])
31
 
32
  st = len(start_tokens)
33
 
 
35
  print("Generating sequence of max length:", seq_len)
36
 
37
  progress(0, desc="Starting...")
 
 
38
 
39
+ with torch.no_grad():
40
+
41
+ for i in progress.tqdm(range(seq_len)):
42
+
43
+ try:
44
  x = out[:, -max_seq_len:]
45
 
46
  torch_in = x.tolist()[0]
 
52
  sample = torch.multinomial(probs, 1)
53
 
54
  out = torch.cat((out, sample), dim=-1)
55
+
56
+ except Exception as e:
57
+ print('Error', e)
58
+ break
59
 
60
  if return_prime:
61
  melody_chords_f = out[:, :]