OAID / FaceDetection

C++ project to implement MTCNN, a perfect face detect algorithm, on different DL frameworks. The most popular frameworks: caffe/mxnet/tensorflow, are all suppported now
Apache License 2.0
272 stars 108 forks source link

It seems that modifying the code doesn't work #4

Closed Aliang-SEU closed 6 years ago

Aliang-SEU commented 6 years ago
int caffe_mtcnn::load_model(const std::string &proto_model_dir)
{

    Caffe::set_mode(Caffe::GPU); //use GPU mode

    //load pre_trained model
    //first param is file path, second represent the net is used for test
    PNet_=new Net<float>(( "./models/det111.prototxt"), caffe::TEST);
    PNet_->CopyTrainedLayersFrom(proto_model_dir + "/det1.caffemodel");

    RNet_=new Net<float>((proto_model_dir + "/det2.prototxt"), caffe::TEST);
    RNet_->CopyTrainedLayersFrom(proto_model_dir + "/det2.caffemodel");

    ONet_=new Net<float>((proto_model_dir + "/det3.prototxt"), caffe::TEST);
    ONet_->CopyTrainedLayersFrom(proto_model_dir + "/det3.caffemodel");

    return 0;
}

I have modified the caffe_mtcnn::load_model() method like above, you can see i changed the mode but after recompiling the project, it still run in cpu mode. And i modified the model's file name to det111.prototxt , but the log info still shows that the Net load the model lwhich is called det1.prototxt.

I wish you can help me! Thank you!

Here are part of the console log info

mtcnn git:(master) ✗ ./test      
1
WARNING: Logging before InitGoogleLogging() is written to STDERR
I1123 20:26:12.290751 14968 upgrade_proto.cpp:67] Attempting to upgrade input file specified using deprecated input fields: ./models/det1.prototxt
I1123 20:26:12.290843 14968 upgrade_proto.cpp:70] Successfully upgraded file specified using deprecated input fields.
W1123 20:26:12.290848 14968 upgrade_proto.cpp:72] Note that future Caffe releases will only support input layers and not input fields.
I1123 20:26:12.290976 14968 net.cpp:51] Initializing net from parameters: 
name: "PNet"
state {
  phase: TEST
  level: 0
}
layer {
  name: "input"
  type: "Input"
  top: "data"
  input_param {
    shape {
      dim: 1
      dim: 3
      dim: 12
      dim: 12
    }