basic dataset
This commit is contained in:
@@ -160,4 +160,5 @@ cython_debug/
|
|||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
.vscode/
|
||||||
temp/
|
temp/
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import math
|
||||||
|
import torch
|
||||||
|
import torchvision as tv
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from torch.utils.data import Dataset
|
||||||
|
|
||||||
|
class Dataset(Dataset):
|
||||||
|
def __init__(self, folder):
|
||||||
|
self.folder = folder
|
||||||
|
self.transforms = tv.transforms.ToTensor()
|
||||||
|
self.frames = os.listdir(os.path.join(folder, 'mesh_posed'))
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.frames)
|
||||||
|
|
||||||
|
def __getitem__(self, idx):
|
||||||
|
img_path = os.path.join(self.folder, 'mesh_posed', self.frames[idx])
|
||||||
|
image = np.load(img_path)['mesh_posed']
|
||||||
|
# image = self.transforms(image)
|
||||||
|
return image
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
from torch.utils.data import DataLoader
|
||||||
|
|
||||||
|
dataset = Dataset('/home/workspace/local-data/train')
|
||||||
|
train_dataloader = DataLoader(dataset, batch_size=4, drop_last=True, num_workers=2)
|
||||||
|
|
||||||
|
for batch in train_dataloader:
|
||||||
|
batch
|
||||||
|
pass
|
||||||
|
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user