예제 #1
0
파일: train.py 프로젝트: wkentaro/apc-od
 def dataset_to_xt_data(dataset, crop_roi):
     """Convert dataset to x_data and t_data"""
     x_data = []
     for raw_path in dataset.filenames:
         raw = im_preprocess(imread(raw_path))
         if crop_roi:
             mask_path = raw_to_mask_path(raw_path)
             roi = mask_to_roi(im_preprocess(imread(mask_path)))
             raw = raw[roi[0]:roi[2], roi[1]:roi[3]]
             raw = resize(raw, (128, 128), preserve_range=True)
         x_data.append(im_to_blob(raw))
     x_data = np.array(x_data, dtype=np.float32)
     t_data = dataset.target.astype(np.int32)
     return x_data, t_data
예제 #2
0
    def setUp(self):
        self.model = CAEPool()
        self.optimizer = O.Adam()
        self.optimizer.setup(self.model)

        img = doll()
        x_data = np.array([im_to_blob(im_preprocess(img))])
        self.x = Variable(x_data)
예제 #3
0
    def setUp(self):
        cae_ones_h5 = os.path.join(here, 'data/cae_ones.h5')
        vgg_h5 = os.path.join(here, 'data/vgg.h5')
        self.model = CAEOnesRoiVGG(
            initial_roi=[100, 100, 300, 300],
            cae_ones_h5=cae_ones_h5, vgg_h5=vgg_h5)
        self.optimizer = O.Adam()
        self.optimizer.setup(self.model)

        img = doll()
        x_data = np.array([im_to_blob(im_preprocess(img))])
        self.x = Variable(x_data)
        t_data = np.array([0], dtype=np.int32)
        self.t = Variable(t_data)