def __init__(self, img_size, range01=False, rgb_order=False, dummy=False):
     images_dir = settings.get_data_dir('office_webcam')
     super(OfficeWebcamDataset, self).__init__(img_size,
                                               range01,
                                               rgb_order,
                                               images_dir,
                                               dummy=dummy)
Example #2
0
 def __init__(self, img_size, range01=False, rgb_order=False, dummy=False):
     images_dir = settings.get_data_dir('amazon_dslr')
     super(OfficeAmazon2DslrDataset, self).__init__(img_size,
                                                    range01,
                                                    rgb_order,
                                                    images_dir,
                                                    dummy=dummy)
Example #3
0
    def __init__(self,
                 img_size,
                 range01=False,
                 rgb_order=False,
                 dummy=False,
                 download=True):

        self.file_id = '0B4IapRTv9pJ1WGZVd1VDMmhwdlE'
        self.filename = "domain_adaptation_images.tar.gz"
        # download dataset.
        if download:
            download_file_from_google_drive(
                self.file_id, os.path.join('./dataset/', self.filename))
        if not _check_exists(os.path.join('./dataset/', self.filename)):
            raise RuntimeError("Dataset not found." +
                               " You can use download=True to download it")

        load_samples(os.path.join('./dataset/', self.filename))

        images_dir = settings.get_data_dir('office_amazon')
        super(OfficeAmazonDataset, self).__init__(img_size,
                                                  range01,
                                                  rgb_order,
                                                  images_dir,
                                                  dummy=dummy)
Example #4
0
 def __init__(self, img_size, range01=False, rgb_order=False, dummy=False):
     test_dir = settings.get_data_dir('visda17_clf_test')
     file_list_path = os.path.join(test_dir, 'image_list.txt')
     super(TestDataset, self).__init__(img_size,
                                       range01,
                                       rgb_order,
                                       file_list_path,
                                       test_dir,
                                       has_ground_truth=False,
                                       dummy=dummy)
Example #5
0
 def __init__(self, img_size, range01=False, rgb_order=False, dummy=False):
     val_dir = settings.get_data_dir('visda17_clf_validation')
     file_list_path = os.path.join(val_dir, 'image_list.txt')
     super(ValidationDataset, self).__init__(img_size,
                                             range01,
                                             rgb_order,
                                             file_list_path,
                                             val_dir,
                                             has_ground_truth=True,
                                             dummy=dummy)
Example #6
0
    def __init__(self, img_size, range01=False, rgb_order=False, dummy=False):
        train_dir = settings.get_data_dir('visda17_clf_train')
        file_list_path = os.path.join(train_dir, 'image_list.txt')
        super(TrainDataset, self).__init__(img_size,
                                           range01,
                                           rgb_order,
                                           file_list_path,
                                           train_dir,
                                           has_ground_truth=True,
                                           dummy=dummy)

        self.object_ids = []
        self.cam_yaw = []
        self.light_yaw = []
        self.cam_pitch = []

        self.obj_id_to_idx = {}
        self.cam_yaw_to_idx = {}
        self.light_yaw_to_idx = {}
        self.cam_pitch_to_idx = {}
        for sample_idx, name in enumerate(self.names):
            fn, _ = os.path.splitext(name)
            object_id, _, tail = fn.partition('__')
            c_yaw, l_yaw, c_pitch = tail.split('_')
            c_yaw = float(c_yaw)
            l_yaw = float(l_yaw)
            c_pitch = float(c_pitch)
            obj_id_idx = self.obj_id_to_idx.setdefault(object_id,
                                                       len(self.obj_id_to_idx))
            c_yaw_idx = self.cam_yaw_to_idx.setdefault(
                c_yaw, len(self.cam_yaw_to_idx))
            l_yaw_idx = self.light_yaw_to_idx.setdefault(
                l_yaw, len(self.light_yaw_to_idx))
            c_pitch_idx = self.cam_pitch_to_idx.setdefault(
                c_pitch, len(self.cam_pitch_to_idx))
            self.object_ids.append(obj_id_idx)
            self.cam_yaw.append(c_yaw_idx)
            self.light_yaw.append(l_yaw_idx)
            self.cam_pitch.append(c_pitch_idx)
        self.object_ids = np.array(self.object_ids, dtype=np.int32)
        self.cam_yaw = np.array(self.cam_yaw, dtype=np.int32)
        self.light_yaw = np.array(self.light_yaw, dtype=np.int32)
        self.cam_pitch = np.array(self.cam_pitch, dtype=np.int32)

        sample_ndxs = np.arange(len(self.object_ids))
        self.samples_by_obj_id = [
            sample_ndxs[self.object_ids == i]
            for i in range(len(self.obj_id_to_idx))
        ]
        self.samples_by_cam_yaw = [
            sample_ndxs[self.cam_yaw == i]
            for i in range(len(self.cam_yaw_to_idx))
        ]
        self.samples_by_light_yaw = [
            sample_ndxs[self.light_yaw == i]
            for i in range(len(self.light_yaw_to_idx))
        ]
        self.samples_by_cam_pitch = [
            sample_ndxs[self.cam_pitch == i]
            for i in range(len(self.cam_pitch_to_idx))
        ]

        self.obj_X = self.ObjectImageAccessor(self)