Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
b9dc011
1
Parent(s):
8cdeec1
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,26 +36,24 @@ def GenerateMIDI():
|
|
| 36 |
|
| 37 |
progress(0, desc="Starting...")
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
torch_in = x.tolist()[0]
|
| 47 |
-
|
| 48 |
-
logits = torch.FloatTensor(session.run(None, {'input': [torch_in]})[0])[:, -1]
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
sample = torch.multinomial(probs, 1)
|
| 53 |
-
|
| 54 |
-
out = torch.cat((out, sample), dim=-1)
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
|
| 60 |
if return_prime:
|
| 61 |
melody_chords_f = out[:, :]
|
|
|
|
| 36 |
|
| 37 |
progress(0, desc="Starting...")
|
| 38 |
|
| 39 |
+
for i in progress.tqdm(range(seq_len)):
|
| 40 |
+
|
| 41 |
+
try:
|
| 42 |
+
x = out[:, -max_seq_len:]
|
| 43 |
|
| 44 |
+
torch_in = x.tolist()[0]
|
| 45 |
|
| 46 |
+
logits = torch.FloatTensor(session.run(None, {'input': [torch_in]})[0])[:, -1]
|
| 47 |
+
|
| 48 |
+
probs = F.softmax(logits / temperature, dim=-1)
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
sample = torch.multinomial(probs, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
out = torch.cat((out, sample), dim=-1)
|
| 53 |
+
|
| 54 |
+
except Exception as e:
|
| 55 |
+
print('Error', e)
|
| 56 |
+
break
|
| 57 |
|
| 58 |
if return_prime:
|
| 59 |
melody_chords_f = out[:, :]
|