예제 #1
0
def create_param(device_id_, image_list_, image_pair_list_, model_infos_):

    model_param_config = []

    for elem in model_infos_:

        if (elem.has_key('mean_value')):
            each_param = caffe_pb_feature.ModelInitParameter(
                image_root_path=elem['image_root_path'],
                deploy_path=elem['deploy_path'],
                model_path=elem['model_path'],
                output_path=elem['output_path'],
                data_transform=caffe_pb_feature.TransformationParameter(
                    mean_value=elem['mean_value'], scale=elem['scale']))
        else:

            each_param = caffe_pb_feature.ModelInitParameter(
                image_root_path=elem['image_root_path'],
                deploy_path=elem['deploy_path'],
                model_path=elem['model_path'],
                output_path=elem['output_path'])
        model_param_config.append(each_param)

    feature = caffe_pb_feature.ExtractFeatureParameter(
        run_mode=caffe_pb_feature.ExtractFeatureParameter.RunMode.Value('GPU'),
        device_id=device_id_,
        image_list=image_list_,
        image_pair_list=image_pair_list_,
        model_config=model_param_config)
    return feature
예제 #2
0
    def createParamFile(self,
                        batch_model_info,
                        output_result_path,
                        mean_value=None,
                        scale=1.0):
        model_param_config = []
        for elem in batch_model_info:
            deploy_path = elem[0]
            model_lists = elem[1]
            for model_name_path in model_lists:
                model_name = model_name_path.split('/')[-1]
                patch_info = utility.crop_patch_info_model_name(model_name)

                if mean_value != None:
                    each_param = caffe_pb_feature.ModelInitParameter(
                        image_root_path='{}/{}'.format(
                            ConfigPath.test_data_set[self.test_set]
                            ['imgs_folder'], patch_info),
                        deploy_path=deploy_path,
                        model_path=model_name_path,
                        output_path=output_result_path,
                        data_transform=caffe_pb_feature.
                        TransformationParameter(mean_value=mean_value,
                                                scale=scale))
                else:
                    if model_name_path.find('Means') >= 0:
                        each_param = caffe_pb_feature.ModelInitParameter(
                            image_root_path='{}/{}'.format(
                                ConfigPath.test_data_set[self.test_set]
                                ['imgs_folder'], patch_info),
                            deploy_path=deploy_path,
                            model_path=model_name_path,
                            output_path=output_result_path,
                            data_transform=caffe_pb_feature.
                            TransformationParameter(
                                mean_value=[127.5, 127.5, 127.5],
                                scale=0.0078125))
                    else:
                        each_param = caffe_pb_feature.ModelInitParameter(
                            image_root_path='{}/{}'.format(
                                ConfigPath.test_data_set[self.test_set]
                                ['imgs_folder'], patch_info),
                            deploy_path=deploy_path,
                            model_path=model_name_path,
                            output_path=output_result_path,
                        )
                model_param_config.append(each_param)

        feature = caffe_pb_feature.ExtractFeatureParameter(
            run_mode=caffe_pb_feature.ExtractFeatureParameter.RunMode.Value(
                'GPU'),
            device_id=0,
            image_list=ConfigPath.test_data_set[self.test_set]['image_list'],
            image_pair_list=ConfigPath.test_data_set[
                self.test_set]['pairs_file'],
            model_config=model_param_config)
        return feature