Python caffe.proto.caffe_pb2.TEST Examples
The following are 16
code examples of caffe.proto.caffe_pb2.TEST().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
caffe.proto.caffe_pb2
, or try the search function
.
Example #1
Source File: net_generator.py From resnet-cifar10-caffe with MIT License | 6 votes |
def transform_param(self, mean_value=128, batch_size=128, scale=1., #.0078125, mirror=1, crop_size=None, mean_file_size=None, phase=None): new_transform_param = self.this.transform_param if scale != 1.: new_transform_param.scale = scale new_transform_param.mean_value.extend([mean_value]) if phase is not None and phase == 'TEST': return new_transform_param.mirror = mirror if crop_size is not None: new_transform_param.crop_size = crop_size
Example #2
Source File: builder.py From channel-pruning with MIT License | 6 votes |
def resnet(n=3, num_output = 16): """6n+2, n=3 9 18 coresponds to 20 56 110 layers""" net_name = "resnet-" pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2)) name = net_name+str(6*n+2)+'-cifar10' if n > 18: # warm up solver = Solver(solver_name="solver_warm.prototxt", folder=pt_folder, lr_policy=Solver.policy.fixed) solver.p.base_lr = 0.01 solver.set_max_iter(500) solver.write() del solver solver = Solver(folder=pt_folder) solver.write() del solver builder = Net(name) builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32) builder.Data('cifar-10-batches-py/test', phase='TEST') builder.resnet_cifar(n, num_output=num_output) builder.write(folder=pt_folder)
Example #3
Source File: builder.py From channel-pruning with MIT License | 6 votes |
def resnet_orth(n=3): """6n+2, n=3 9 18 coresponds to 20 56 110 layers""" net_name = "resnet-orth-" pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2)) name = net_name+str(6*n+2)+'-cifar10' if n > 18: # warm up solver = Solver(solver_name="solver_warm.prototxt", folder=pt_folder, lr_policy=Solver.policy.fixed) solver.p.base_lr = 0.01 solver.set_max_iter(500) solver.write() del solver solver = Solver(folder=pt_folder) solver.write() del solver builder = Net(name) builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32) builder.Data('cifar-10-batches-py/test', phase='TEST') builder.resnet_cifar(n, orth=True) builder.write(folder=pt_folder)
Example #4
Source File: gen_model.py From MobileNetv2-SSDLite with MIT License | 6 votes |
def data_test_ssd(self): layer = self.net.layer.add() layer.name = "data" layer.type = "AnnotatedData" layer.top.append("data") layer.top.append("label") layer.include.add().phase = caffe_pb2.TEST layer.transform_param.scale = 0.007843 layer.transform_param.mirror = True layer.transform_param.mean_value.append(127.5) layer.transform_param.mean_value.append(127.5) layer.transform_param.mean_value.append(127.5) layer.transform_param.resize_param.prob = 1.0 layer.transform_param.resize_param.resize_mode = caffe_pb2.ResizeParameter.WARP layer.transform_param.resize_param.height = self.input_size layer.transform_param.resize_param.width = self.input_size layer.transform_param.resize_param.interp_mode.append(caffe_pb2.ResizeParameter.LINEAR) layer.data_param.source = "" layer.data_param.batch_size = 8 layer.data_param.backend = caffe_pb2.DataParameter.LMDB layer.annotated_data_param.label_map_file = self.label_map
Example #5
Source File: net_generator.py From resnet-cifar10-caffe with MIT License | 5 votes |
def include(self, phase='TRAIN'): if phase is not None: includes = self.this.include.add() if phase == 'TRAIN': includes.phase = caffe_pb2.TRAIN elif phase == 'TEST': includes.phase = caffe_pb2.TEST else: NotImplementedError #************************** inplace **************************
Example #6
Source File: builder.py From channel-pruning with MIT License | 5 votes |
def transform_param(self, mean_value=128, batch_size=128, scale=.0078125, mirror=1, crop_size=None, mean_file_size=None, phase=None): new_transform_param = self.this.transform_param if scale != 1: new_transform_param.scale = scale if isinstance(mean_value, list): new_transform_param.mean_value.extend(mean_value) else: new_transform_param.mean_value.extend([mean_value]) if phase is not None and phase == 'TEST': return new_transform_param.mirror = mirror if crop_size is not None: new_transform_param.crop_size = crop_size
Example #7
Source File: builder.py From channel-pruning with MIT License | 5 votes |
def include(self, phase='TRAIN'): if phase is not None: includes = self.this.include.add() if phase == 'TRAIN': includes.phase = caffe_pb2.TRAIN elif phase == 'TEST': includes.phase = caffe_pb2.TEST else: NotImplementedError #************************** inplace **************************
Example #8
Source File: builder.py From channel-pruning with MIT License | 5 votes |
def BatchNorm(self, name=None, inplace=True,eps=1e-5): moving_average_fraction = 0 if not inplace: bottom = self.this.name # train bn_name = self.suffix('bn', name) self.setup(bn_name, 'BatchNorm', inplace=inplace) # self.include() self.param(lr_mult=0, decay_mult=0) self.param(lr_mult=0, decay_mult=0) self.param(lr_mult=0, decay_mult=0) batch_norm_param = self.this.batch_norm_param if eps != 1e-5: batch_norm_param.eps = eps return bn_name # batch_norm_param.use_global_stats = False #batch_norm_param.moving_average_fraction = moving_average_fraction # test # if not inplace: # self.setup(bn_name, 'BatchNorm', inplace=inplace, bottom=[bottom]) # else: # self.setup(bn_name, 'BatchNorm', inplace=inplace) # self.include(phase='TEST') # self.param(lr_mult=0, decay_mult=0) # self.param(lr_mult=0, decay_mult=0) # self.param(lr_mult=0, decay_mult=0) # batch_norm_param = self.this.batch_norm_param # batch_norm_param.use_global_stats = True # batch_norm_param.moving_average_fraction = moving_average_fraction
Example #9
Source File: builder.py From channel-pruning with MIT License | 5 votes |
def plain(n=3): """6n+2, n=3 9 18 coresponds to 20 56 110 layers""" net_name = "plain" pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2)) name = net_name+str(6*n+2)+'-cifar10' solver = Solver(folder=pt_folder) solver.write() del solver builder = Net(name) builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32) builder.Data('cifar-10-batches-py/test', phase='TEST') builder.plain_cifar(n, num_output = 16) builder.write(folder=pt_folder)
Example #10
Source File: builder.py From channel-pruning with MIT License | 5 votes |
def plain_orth(n=3): """6n+2, n=3 5 7 9 18 coresponds to 20 56 110 layers""" net_name = "plain-orth" pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2)) name = net_name+str(6*n+2)+'-cifar10' solver = Solver(folder=pt_folder) solver.write() del solver builder = Net(name) builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32) builder.Data('cifar-10-batches-py/test', phase='TEST') builder.plain_cifar(n, orth=True) builder.write(folder=pt_folder)
Example #11
Source File: builder.py From channel-pruning with MIT License | 5 votes |
def plain_orth_v1(n=3): """6n+2, n=3 5 7 9 18 coresponds to 20 32 44 56 110 layers""" net_name = "plain-orth-v1-" pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2)) name = net_name+str(6*n+2)+'-cifar10' solver = Solver(folder=pt_folder) solver.write() del solver builder = Net(name) builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32) builder.Data('cifar-10-batches-py/test', phase='TEST') builder.plain_cifar(n, orth=True, inplace=False, num_output = 16) builder.write(folder=pt_folder)
Example #12
Source File: builder.py From channel-pruning with MIT License | 5 votes |
def acc(n=3): """6n+2, n=3 9 18 coresponds to 20 56 110 layers""" net_name = "plain" pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2)) name = net_name+str(6*n+2)+'-cifar10' solver = Solver(folder=pt_folder) solver.write() del solver builder = Net(name) builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32) builder.Data('cifar-10-batches-py/test', phase='TEST') builder.plain_cifar(n, num_output = 16, inplace=False) builder.write(folder=pt_folder)
Example #13
Source File: net_generator.py From ThiNet_Code with MIT License | 5 votes |
def include(self, phase='TRAIN'): if phase is not None: includes = self.this.include.add() if phase == 'TRAIN': includes.phase = caffe_pb2.TRAIN elif phase == 'TEST': includes.phase = caffe_pb2.TEST else: NotImplementedError #************************** inplace **************************
Example #14
Source File: net_generator.py From ThiNet_Code with MIT License | 5 votes |
def solver_and_prototxt(compress_layer, compress_rate, compress_block): layers = ['2a', '2b', '2c', '3a', '3b', '3c', '3d', '4a', '4b', '4c', '4d', '4e', '4f', '5a', '5b', '5c'] pt_folder = layers[compress_layer] + '_' + str(compress_block) if not os.path.exists(pt_folder): os.mkdir(pt_folder) name = 'resnet-' + layers[compress_layer] + str(compress_block) +'-ImageNet' solver = Solver(folder=pt_folder, b=compress_layer, compress_block=compress_block) solver.write() builder = Net(name) builder.Data('/opt/luojh/Dataset/ImageNet/lmdb/ilsvrc12_train_lmdb', backend='LMDB', phase='TRAIN', mirror=True, crop_size=224, batch_size=32) builder.Data('/opt/luojh/Dataset/ImageNet/lmdb/ilsvrc12_val_lmdb', backend='LMDB', phase='TEST', mirror=False, crop_size=224, batch_size=10) builder.resnet_50(layers, compress_layer, compress_rate, compress_block) builder.write(name='trainval.prototxt', folder=pt_folder) if compress_block == 0: compress_block = 1 compress_layer -= 1 else: compress_block =0 builder = Net(name + '-old') builder.setup('data', 'Data', top=['data']) builder.resnet_50(layers, compress_layer, compress_rate, compress_block, deploy=True) builder.write(name='deploy.prototxt', folder=pt_folder, deploy=True) print "Finished net prototxt generation!"
Example #15
Source File: gen_model.py From MobileNetv2-SSDLite with MIT License | 5 votes |
def ssd_predict(self): layer = self.net.layer.add() layer.name = "mbox_conf_reshape" layer.type = "Reshape" layer.bottom.append("mbox_conf") layer.top.append("mbox_conf_reshape") layer.reshape_param.shape.dim.append(0) layer.reshape_param.shape.dim.append(-1) layer.reshape_param.shape.dim.append(self.class_num) layer = self.net.layer.add() layer.name = "mbox_conf_sigmoid" layer.type = "Sigmoid" layer.bottom.append("mbox_conf_reshape") layer.top.append("mbox_conf_sigmoid") layer = self.net.layer.add() layer.name = "mbox_conf_flatten" layer.type = "Flatten" layer.bottom.append("mbox_conf_sigmoid") layer.top.append("mbox_conf_flatten") layer.flatten_param.axis = 1 layer = self.net.layer.add() layer.name = "detection_out" layer.type = "DetectionOutput" layer.bottom.append("mbox_loc") layer.bottom.append("mbox_conf_flatten") layer.bottom.append("mbox_priorbox") layer.top.append("detection_out") layer.include.add().phase = caffe_pb2.TEST layer.detection_output_param.num_classes = self.class_num layer.detection_output_param.share_location = True layer.detection_output_param.background_label_id = 0 layer.detection_output_param.nms_param.nms_threshold = 0.45 layer.detection_output_param.nms_param.top_k = 100 layer.detection_output_param.code_type = caffe_pb2.PriorBoxParameter.CENTER_SIZE layer.detection_output_param.keep_top_k = 100 layer.detection_output_param.confidence_threshold = 0.35
Example #16
Source File: gen_model.py From MobileNetv2-SSDLite with MIT License | 5 votes |
def ssd_test(self): self.ssd_predict() layer = self.net.layer.add() layer.name = "detection_eval" layer.type = "DetectionEvaluate" layer.bottom.append("detection_out") layer.bottom.append("label") layer.top.append("detection_eval") layer.include.add().phase = caffe_pb2.TEST layer.detection_evaluate_param.num_classes = self.class_num layer.detection_evaluate_param.background_label_id = 0 layer.detection_evaluate_param.overlap_threshold = 0.5 layer.detection_evaluate_param.evaluate_difficult_gt = False