-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrum_dataloader.py
More file actions
executable file
·30 lines (25 loc) · 942 Bytes
/
Copy pathdrum_dataloader.py
File metadata and controls
executable file
·30 lines (25 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import os.path as osp
import numpy as np
import torch
class drum_dataloader():
def __init__(self,
root,
):
print("Loading post_preccessed data....")
self.matrices_onsets = np.load(root)['onsets']
self.matrices_velos = np.load(root)['velocities']
self.matrices_offsets = np.load(root)['offsets']
self.matrices_genres = np.load(root)['genre_ids'].reshape(-1,1)
self.GENRES = np.load(root)['genres']
print("Loading successful")
print("X shape: ",self.matrices_velos.shape)
print("Label shape: ",self.matrices_genres.shape)
def __getitem__(self, index):
drum = self.matrices_velos[index, :, :]
label = self.matrices_genres[index,:]
drum = torch.FloatTensor(drum)
label = torch.LongTensor(label)
return(drum,label)
def __len__(self):
return len(self.matrices_velos)