Exemplo n.º 1
0
    def __getitem__(self, idx):
        #print("Get item: ",str(idx) +  self.image_paths[idx])
        #print("Label Length",len(self.label))
        #print("Test Length",len(self.test))
        self.printedItems = self.printedItems + 1
        if self.loadLink:
            image_name = self.image_paths[idx]
            image = imageio.imread(os.path.join(image_name))
            image = to_normalized_range(image)
            image = transform.resize(image, (self.IMAGE_SIZE, self.IMAGE_SIZE),
                                     mode='symmetric',
                                     preserve_range=True)
            #Uncomment and comment the reshape,
            #,if every picture should be done in color mode: Remember to change the dimension in the network from 1 to 3!
            #if len(image.shape) == 2:
            #    image = color.gray2rgb(image)
            #image = image.transpose((2, 0, 1))
            image = image.reshape((1, self.IMAGE_SIZE, self.IMAGE_SIZE))
            image = torch.tensor(image.astype(np.float32))
            if self.label:
                label_image = self.label[idx]
                label_image = torch.tensor(label_image, dtype=torch.float32)
                return image, label_image
            else:
                label_image = idx
                #label_image = torch.tensor(label_image, dtype=torch.float32)
                return image, label_image

        else:
            # Code for CIL Project
            if (self.category == 'query'):
                return dataset_img[idx]
            else:
                return dataset_img[idx], label[idx]
            """
Exemplo n.º 2
0
 def __getitem__(self, idx):
     image_name = self.image_names[idx]
     image = imageio.imread(os.path.join(self.dataset_path, image_name))
     image = image.transpose((2, 0, 1))
     image = torch.tensor(image.astype(np.float32))
     image = to_normalized_range(image)
     age = self.ages[idx]
     age = torch.tensor(age, dtype=torch.float32)
     return image, age
Exemplo n.º 3
0
 def __getitem__(self, index):
     image_name = self.image_names[index]
     image = np.load(
         os.path.join(self.dataset_path, image_name.replace('.jpg',
                                                            '.npy')))
     image = torch.tensor(image.astype(np.float32))
     image = to_normalized_range(image)
     angle = self.angles[index]
     angle = torch.tensor(angle, dtype=torch.float32)
     return image, angle