-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.py
32 lines (25 loc) · 943 Bytes
/
loader.py
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
31
32
from __future__ import print_function, division
from torch.utils.data import Dataset
import pandas as pd
from skimage import io, transform
import os
class SawyerSimDataset(Dataset):
"""Face Landmarks dataset."""
def __init__(self, csv_file, root_dir, transform=None):
self.labels = pd.read_csv(csv_file)
print(csv_file)
print(self.labels)
self.root_dir = root_dir
self.transform = transform
def __len__(self):
return len(self.labels)
def __getitem__(self, idx):
img_name = os.path.join(self.root_dir,
self.labels.iloc[idx, 0])
image = io.imread(img_name)
label = self.labels.iloc[idx, 1:].as_matrix()
label = label.astype('float')
sample = {'image': image, 'landmarks': label}
if self.transform:
sample = self.transform(sample)
return sample