Beispiel #1
0
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 vgg16_dev(data_param = dict(shape=dict(dim=[2, 3, 224, 224])), label_param = dict(shape=dict(dim=[2]))):
  # setup the python data layer 
  net = caffe.NetSpec()
  net['data']   = L.Input(input_param = data_param)
  net['label']  = L.Input(input_param = label_param)
  net, final    = vgg16_body(net,   'data',   '', False)
  net['score']     = fc_relu(net[final],       nout=751, is_train=False, 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=False, has_relu=False)
  return str(net.to_proto())