-
Notifications
You must be signed in to change notification settings - Fork 92
/
loaddata_demo.py
45 lines (31 loc) · 1.2 KB
/
loaddata_demo.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
33
34
35
36
37
38
39
40
41
42
43
44
45
import pandas as pd
import numpy as np
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms, utils
from PIL import Image
import random
from demo_transform import *
class depthDataset(Dataset):
def __init__(self, filename, transform=None):
self.frame = filename
self.transform = transform
def __getitem__(self,idx):
image = Image.open(self.frame)
if self.transform:
image = self.transform(image)
return image
def __len__(self):
return int(1)
def readNyu2(filename):
__imagenet_stats = {'mean': [0.485, 0.456, 0.406],
'std': [0.229, 0.224, 0.225]}
image_trans = depthDataset(filename,
transform=transforms.Compose([
Scale([320, 240]),
CenterCrop([304, 228]),
ToTensor(),
Normalize(__imagenet_stats['mean'],
__imagenet_stats['std'])
]))
image = DataLoader(image_trans, batch_size=1, shuffle=False, num_workers=0, pin_memory=False)
return image