Spaces:
Running
on
Zero
Running
on
Zero
asigalov61
commited on
Commit
•
6c6632f
1
Parent(s):
f004a93
Update app.py
Browse files
app.py
CHANGED
@@ -39,18 +39,18 @@ def GenerateMIDI():
|
|
39 |
for i in progress.tqdm(range(seq_len)):
|
40 |
|
41 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
probs = F.softmax(logits / temperature, dim=-1)
|
50 |
-
|
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)
|
@@ -155,7 +155,7 @@ if __name__ == "__main__":
|
|
155 |
opt = parser.parse_args()
|
156 |
|
157 |
print('Loading model...')
|
158 |
-
session = rt.InferenceSession('Allegro_Music_Transformer_Small_Trained_Model_56000_steps_0.9399_loss_0.7374_acc.onnx', providers=['CUDAExecutionProvider'])
|
159 |
print('Done!')
|
160 |
|
161 |
app = gr.Blocks()
|
|
|
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]
|
46 |
+
|
47 |
+
logits = torch.FloatTensor(session.run(None, {'input': [torch_in]})[0])[:, -1]
|
48 |
|
49 |
+
probs = F.softmax(logits / temperature, dim=-1)
|
50 |
+
|
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)
|
|
|
155 |
opt = parser.parse_args()
|
156 |
|
157 |
print('Loading model...')
|
158 |
+
session = rt.InferenceSession('Allegro_Music_Transformer_Small_Trained_Model_56000_steps_0.9399_loss_0.7374_acc.onnx', providers=['CPUExecutionProvider', 'CUDAExecutionProvider'])
|
159 |
print('Done!')
|
160 |
|
161 |
app = gr.Blocks()
|