Problems encountered in the use of Caffe

Source: Internet
Author: User

1:fatal error:caffe/proto/caffe.pb.h:no such file or directory
Workaround: Generate Caffe.pb.h and caffe.pb.cc from Caffe/src/caffe/proto/caffe.proto with Protoc
into the Caffe root directory, enter the command:

  Protoc Src/caffe/proto/caffe.proto--cpp_out=.
  mkdir include/caffe/proto
  MV Src/caffe/proto/caffe.pb.h Include/caffe/proto

It's no problem to call again.

2:error: ' Class Caffe::memorydatalayer ' has no member named ' Addmatvector '
Error: ' Cvmattodatum ' is not ' a ' caffe '
This error was reported when loading data into the network using Memorydata because the "USE_OPENCV" was not declared. Looking at memory_data_layer.hpp and io.hpp, you can see that it explicitly contains functions Addmatvector and cvmattodatum, but you need to declare USE_OPENCV before they are visible:

#ifdef USE_OPENCV
  virtual void addmatvector (const vector<cv::mat>& mat_vector,
      const VECTOR<INT >& labels);
#endif  //USE_OPENCV
#ifdef USE_OPENCV
cv::mat readimagetocvmat (const string& filename,
    const int height, const int width, const b Ool Is_color);

Cv::mat Readimagetocvmat (const string& filename,
    const int height, const int width);

Cv::mat Readimagetocvmat (const string& filename,
    const bool is_color);

Cv::mat Readimagetocvmat (const string& filename);

Cv::mat decodedatumtocvmatnative (const datum& Datum);
Cv::mat Decodedatumtocvmat (const datum& Datum, bool is_color);

void Cvmattodatum (const cv::mat& cv_img, datum* Datum);
#endif  //USE_OPENCV

Workaround: First of all, confirm that when compiling Caffe, the Makefile.config contains the OpenCV module, namely:

# Uncomment if you ' re using OpenCV 3
  opencv_version: = 3

and comment out Use_opencv: = 0:

# Use_opencv: = 0

Second, when you include file memory_data_layer.hpp or IO.HPP, you explicitly declare the macro definition USE_OPENCV above the caller, for example:

#ifndef USE_OPENCV
#define USE_OPENCV
#include <caffe/caffe.hpp>  
#include <caffe/layers/ memory_data_layer.hpp>
#include <caffe/util/io.hpp>
#endif

Compile again and solve the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.