def load_data(mode, train=True): if mode == 's2m': return get_mnist(train), get_usps(train) elif mode == 'u2m': return get_mnist(train), get_usps(train) elif mode == 'm2u': return get_mnist(train), get_usps(train)
def get_data_loader(name, path, train=True): """Get data loader by name.""" if name == "MNIST": return get_mnist(path, train) elif name == "USPS": return get_usps(path, train) elif name == "SVHN": return get_svhn(path, train)
def get_loader(name, split, batch_size=50): if name == "mnist": return get_mnist(split,batch_size) if name == "usps": return get_usps(split,batch_size) if name == "mnistBig": return mnistBig.get_mnist(split,batch_size) if name == "uspsBig": return uspsBig.get_usps(split,batch_size)
def get_data_loader(name, dataset_root, batch_size, train=True): """Get data loader by name.""" if name == "mnist": return get_mnist(dataset_root, batch_size, train) elif name == "mnistm": return get_mnistm(dataset_root, batch_size, train) elif name == "usps": return get_usps(dataset_root, batch_size, train) elif name == "svhn": return get_svhn(dataset_root, batch_size, train) elif name == "amazon31": return get_office(dataset_root, batch_size, 'amazon') elif name == "webcam31": return get_office(dataset_root, batch_size, 'webcam') elif name == "webcam10": return get_officecaltech(dataset_root, batch_size, 'webcam')
def get_loader(name, split, batch_size=50): if name == "mnist": return get_mnist(split, batch_size) elif name == "usps": return get_usps(split, batch_size) elif name == "mnistBig": return mnistBig.get_mnist(split, batch_size) elif name == "uspsBig": return uspsBig.get_usps(split, batch_size) elif name == "coxs2v": return coxs2v.get_coxs2v(split, batch_size) else: raise Exception("Dataset name {} not supported".format(name))
def get_data_loader(name, train=True): """Get data loader by name.""" if name == "MNIST": return get_mnist(train) elif name == "USPS": return get_usps(train)
def get_data_iter(name, train): if name == 'MNIST': return get_inf_iterator(mnist.get_mnist(train=True)) else: return get_inf_iterator(usps.get_usps(train=True))
if __name__ == '__main__': data_itr_tgt = get_data_iter("USPS", train=True) image_tgt, label_tgt = next(data_itr_tgt) image_tgt = image_tgt[0:2] print(image_tgt.shape) print(image_tgt) new_tgt = make_larger_size(image_tgt) print(new_tgt.shape) print(new_tgt) plt.imshow(new_tgt[0].numpy().reshape(36, 36), cmap="gray") plt.show() print(label_tgt[0]) exit(0) #options = { 'dir' : 'data' , 'name' : 'MNIST' , 'batch_size' : 64 , 'dataset_mean' : (0.5,0.5,0.5) , 'dataset_std' : (0.5,0.5,0.5)} mnist_loader = mnist.get_mnist(train=True) usps_loader = usps.get_usps(train=True) im = Image.open("snapshots/Figure_2.png") im = im.convert("L") #im = im.resize((image_width, image_height)) # im.show() data = im.getdata() data = np.matrix(data) print(data.shape) for tgt_img, tgt_label in usps_loader: #print(type(tgt_img)) #print(tgt_img[0]) plt.imshow(tgt_img[0].numpy().reshape(28, 28), cmap="gray") plt.show() print(tgt_img[0].numpy()) new_data = tgt_img[0].numpy().reshape(28, 28) * 255