MemoryDataLayer Usage Question

428 views
Skip to first unread message

Eric Martinson

unread,
Aug 4, 2015, 2:06:29 PM8/4/15
to Caffe Users
I am using the bvlc_alexnet model with an added MemoryDataLayer to classify images from a live camera stream in C++. I am using a modified version of the code posted previously at https://github.com/BVLC/caffe/issues/499 by joeupwu.

detection_caffe::detection_caffe(string prototxt_file, string caffe_model)
{
    caffe_net = new Net<float>(prototxt_file, caffe::TEST);
    caffe_net->CopyTrainedLayersFrom(caffe_model);
    
memory_data_layer
= boost::static_pointer_cast<MemoryDataLayer<float> >(caffe_net->layer_by_name("data"));
}

void detection_caffe::classifySingleImage(const cv::Mat &rgb, std::vector<float> &prob_out)
{
    std::vector<int> labels(1, 0);
    cv::resize(rgb,cv_img,sz,0,0,cv::INTER_CUBIC);
    std::vector<cv::Mat> images(1, cv_img);
    memory_data_layer->AddMatVector(images, labels);
    float loss;
    caffe_net->ForwardPrefilled(&loss);
    boost::shared_ptr<Blob<float> > prob = caffe_net->blob_by_name("prob");
prob_out.resize(prob->count());
    for (int i = 0; i < prob->count(); i++)
    {
        prob_out[i] = prob->cpu_data()[i];
   
}
}



However, when I run this code, I get a steady list of warnings:

W0804 10:53:22.870311 9671 memory_data_layer.cpp:87] MemoryData does not transform array data on Reset()

W0804 10:53:22.878911 9671 memory_data_layer.cpp:87] MemoryData does not transform array data on Reset()

W0804 10:53:22.887466 9671 memory_data_layer.cpp:87] MemoryData does not transform array data on Reset()

W0804 10:53:22.896996 9671 memory_data_layer.cpp:87] MemoryData does not transform array data on Reset()


What does this mean? Is there an operation I am supposed to be performing that I am not currently running? I can, of course, comment out the line in memory_data_layer.cpp and recompile, but I don't know why it is there in the first place, and whether or not I am supposed to be using it differently.

Coert van Gemeren

unread,
Sep 8, 2015, 8:17:12 PM9/8/15
to Caffe Users
Looking at the function AddMatVector(...) in memory_data_layer.cpp (line 57) you can see that first:
this->data_transformer_->Transform(mat_vector, &added_data_);
is called, after that
Reset(...)
is called

Reset generates the warning, though Transform should already have applied all transformations (mirror, scale, crop...). The warning seems irrelevant in this case.


Op dinsdag 4 augustus 2015 20:06:29 UTC+2 schreef Eric Martinson:
Reply all
Reply to author
Forward
0 new messages