GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — dcnet/dataset_utility.py at main · visiontao/dcnet Expand file tree/ Copy pathdataset_utility.pyMore file actions 46 lines (33 loc) · 1.44 KB / Copy pathdataset_utility.pyFile metadata and controls46 lines (33 loc) · 1.44 KB 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 46 import os import glob import numpy as np import cv2 import torch from torch.utils.data import Dataset, DataLoader from torchvision import transforms, utils class ToTensor(object): def __call__(self, sample): return torch.tensor(sample, dtype=torch.float32) class dataset(Dataset): def __init__(self, root, dataset_type, fig_type='*', img_size=160, transform=None): self.transform = transform self.img_size = img_size self.file_names = [f for f in glob.glob(os.path.join(root, fig_type, '*.npz')) if dataset_type in f] #self.file_names = [self.file_names[i] for i in idx[0:21000]] # for few-shot learning def __len__(self): return len(self.file_names) def __getitem__(self, idx): data = np.load(self.file_names[idx]) image = data['image'].reshape(16, 160, 160) target = data['target'] del data resize_image = image if self.img_size is not None: resize_image = [] for idx in range(0, 16): resize_image.append(cv2.resize(image[idx, :], (self.img_size, self.img_size), interpolation = cv2.INTER_NEAREST)) resize_image = np.stack(resize_image) if self.transform: resize_image = self.transform(resize_image) target = torch.tensor(target, dtype=torch.long) return resize_image, target |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |