예제 #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('raw_path')
    parser.add_argument('model_path')
    args = parser.parse_args()

    raw_path = args.raw_path
    model_path = args.model_path

    mask_path = raw_to_mask_path(raw_path)
    raw = imread(raw_path)
    mask = imread(mask_path)
    y_min, x_min, y_max, x_max = mask_to_roi(mask)

    im = raw[y_min:y_max, x_min:x_max]

    model = VGG_mini_ABN()
    serializers.load_hdf5(model_path, model)

    im = resize(im, (128, 128), preserve_range=True)
    x_data = np.array([im_to_blob(im)], dtype=np.float32)
    x = Variable(x_data, volatile=True)
    model.train = False
    y = model(x)
    y_data = y.data
    print(OBJECT_CLASSES[np.argmax(y_data[0])])
예제 #2
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
예제 #3
0
def test_mask_to_roi():
    mask = doll_mask()
    roi = apc_od.mask_to_roi(mask)
    assert_tuple_equal(roi, (208, 216, 264, 392))