def res50_train(mean_value, list_file, is_train=True): # setup the python data layer net = caffe.NetSpec() net.data, net.label \ = L.ReidData(transform_param=dict(mirror=True,crop_size=224,mean_value=mean_value), reid_data_param=dict(source=list_file,batch_size=16,new_height=256,new_width=256, pos_fraction=1,neg_fraction=1,pos_limit=1,neg_limit=4,pos_factor=1,neg_factor=1.01), ntop = 2) net, final = res50_body(net, 'data', '', is_train) net['score'] = fc_relu(net[final], nout=751, is_train=is_train, has_relu=False) net['euclidean'], net['label_dif'] = L.PairEuclidean(net[final], net['label'], ntop=2) net['score_dif'] = fc_relu(net['euclidean'], nout=2, is_train=is_train, has_relu=False) net['loss'] = L.SoftmaxWithLoss(net['score'], net['label'], propagate_down=[1, 0], loss_weight=0.5) net['loss_dif'] = L.SoftmaxWithLoss(net['score_dif'], net['label_dif'], propagate_down=[1, 0], loss_weight=1) return str(net.to_proto())
def get_reidDataLayer(net, batch_size=1): kwargs = { # 'include': dict(phase=caffe_pb2.Phase.Value('TRAIN')), 'reid_transform_param': get_reidTransParam(), } reid_data_kwargs = get_reidDataParam(batch_size=batch_size) net.data, net.label = L.ReidData(name="data", reid_data_param=reid_data_kwargs, \ ntop=2, **kwargs) return net
def res50_train(mean_value, list_file, is_train, batch_size): # setup the python data layer net = caffe.NetSpec() net.data, net.label \ = L.ReidData(transform_param=dict(mirror=True,crop_size=224,mean_value=mean_value), reid_data_param=dict(source=list_file,batch_size=batch_size, new_height=256, new_width=256, pos_fraction=1,neg_fraction=1,pos_limit=1,neg_limit=4,pos_factor=1, neg_factor=1.01), ntop = 2) net, final = res50_body(net, 'data', '', is_train) param = [dict(lr_mult=1, decay_mult=1), dict(lr_mult=2, decay_mult=0)] net['score'] = fc_relu(net[final], nout=751, is_train=is_train, has_relu=False, param=param) #net['euclidean'], net['label_dif'] = L.PairEuclidean(net[final], net['label'], ntop = 2) net['label_dif'] = L.PairReidLabel(net['label'], propagate_down=[0], ntop=1) net['feature_a'], net['feature_b'] = L.Slice(net[final], slice_param=dict( axis=0, slice_point=batch_size), ntop=2) net['euclidean'] = L.Eltwise(net['feature_a'], net['feature_b'], operation=P.Eltwise.PROD) net['score_dif'] = fc_relu(net['euclidean'], nout=2, is_train=is_train, has_relu=False, param=param) net['loss'] = L.SoftmaxWithLoss(net['score'], net['label'], propagate_down=[1, 0], loss_weight=0.5) net['loss_dif'] = L.SoftmaxWithLoss(net['score_dif'], net['label_dif'], propagate_down=[1, 0], loss_weight=1) return str(net.to_proto())
def CreateDataLayer_SV_IMG(source, batch_size=28, new_width=224, new_height=224, pos_fraction=1, neg_fraction=1, pos_limit=1.0, neg_limit=4.0, pos_factor=1.0, neg_factor=1.01, is_color=True, train=True, transform_param={}): if train: kwargs = { 'include': dict(phase=caffe_pb2.Phase.Value('TRAIN')), 'transform_param': transform_param, } else: kwargs = { 'include': dict(phase=caffe_pb2.Phase.Value('TEST')), 'transform_param': transform_param, } return L.ReidData(name="data", reid_data_param=dict(source=source, new_width=new_width, new_height=new_height, pos_fraction=1, neg_fraction=1, pos_limit=1.0, neg_limit=4.0, pos_factor=1.0, neg_factor=1.01, is_color=is_color, batch_size=batch_size), ntop=2, **kwargs)