#include <glog/logging.h>
...
#include "caffe/caffe.hpp"
using namespace caffe;
int main(int argc, char** argv) {
Net<float> caffe_test_net(argv[1]); caffe_test_net.CopyTrainedLayersFrom(argv[2]); float loss; const vector<Blob<float>*>& result = caffe_test_net.ForwardPrefilled(&loss);
const float* argmaxs = result[0]->cpu_data(); for (int i = 0; i < result[0]->num(); ++i) { LOG(INFO) << " Image: "<< i << " class:" << argmaxs[i]; }return 0;
}
/tmp/ccxqR1yE.o: In function `main':prediction.cpp:(.text+0x64): undefined reference to `caffe::Net<float>::Net(std::string const&)'prediction.cpp:(.text+0xd1): undefined reference to `caffe::Net<float>::CopyTrainedLayersFrom(std::string)'prediction.cpp:(.text+0x108): undefined reference to `caffe::Net<float>::ForwardPrefilled(float*)'prediction.cpp:(.text+0x12e): undefined reference to `caffe::Blob<float>::cpu_data() const'prediction.cpp:(.text+0x179): undefined reference to `google::LogMessage::LogMessage(char const*, int)'prediction.cpp:(.text+0x188): undefined reference to `google::LogMessage::stream()'prediction.cpp:(.text+0x1d7): undefined reference to `google::LogMessage::~LogMessage()'prediction.cpp:(.text+0x2a8): undefined reference to `google::LogMessage::~LogMessage()'collect2: error: ld returned 1 exit status
CXX=g++CFLAGS=-c -Wall -std=c++0x -g3 -Ofast -msse2 -I. -I/usr/local/cuda/include -I/home/blcv/LIB/caffe_bn/include/ -I/home/blcv/LIB/caffe_bn/src/LDFLAGS= -L/usr/local/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -lcudart -lcublas -lcurand -lglog -lgflags -lprotobuf -lleveldb -lsnappy -llmdb -lboost_system -lhdf5_hl -lhdf5 -lm -lopencv_core -lopencv_highgui -lopencv_imgproc -lboost_thread -lstdc++ -lcudnn -lcblas -latlas -L/home/blcv/LIB/caffe_bn/build/lib/ -lcaffe -lprotoSOURCES=${wildcard *.cpp }OBJECTS=$(SOURCES:.cpp=.o)EXECUTABLE=predict
all: $(SOURCES) $(EXECUTABLE)
clean: rm -f *.o rm -f $(EXECUTABLE) find ./ -name \*.o -delete
$(EXECUTABLE): $(OBJECTS) $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
.cpp.o: $(CXX) $(CFLAGS) $< -o $@
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:27: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:27: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:32: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::NeuronLayer<Dtype>::NeuronLayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:28: error: ‘param’ was not declared in this scope
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:52: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:52: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:57: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::AbsValLayer<Dtype>::AbsValLayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:53: error: ‘param’ was not declared in this scope
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:113: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:113: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:116: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::BNLLLayer<Dtype>::BNLLLayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:114: error: ‘param’ was not declared in this scope
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:169: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:169: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:176: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::DropoutLayer<Dtype>::DropoutLayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:170: error: ‘param’ was not declared in this scope
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:230: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:230: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:235: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::PowerLayer<Dtype>::PowerLayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:231: error: ‘param’ was not declared in this scope
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:303: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:303: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:306: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::ReLULayer<Dtype>::ReLULayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:304: error: ‘param’ was not declared in this scope
In file included from ../caffe/include/caffe/loss_layers.hpp:11,
from ../caffe/include/caffe/common_layers.hpp:12,
from ../caffe/include/caffe/vision_layers.hpp:10,
from ../caffe/include/caffe/caffe.hpp:16,
from prediction_example.cpp:8:
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:399: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:399: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:402: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::SigmoidLayer<Dtype>::SigmoidLayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:400: error: ‘param’ was not declared in this scope
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:483: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:483: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:486: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::TanHLayer<Dtype>::TanHLayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:484: error: ‘param’ was not declared in this scope
../caffe/include/caffe/neuron_layers.hpp: At global scope:
../caffe/include/caffe/neuron_layers.hpp:571: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/neuron_layers.hpp:571: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/neuron_layers.hpp:576: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/neuron_layers.hpp: In constructor ‘caffe::ThresholdLayer<Dtype>::ThresholdLayer(int)’:
../caffe/include/caffe/neuron_layers.hpp:572: error: ‘param’ was not declared in this scope
In file included from ../caffe/include/caffe/common_layers.hpp:12,
from ../caffe/include/caffe/vision_layers.hpp:10,
from ../caffe/include/caffe/caffe.hpp:16,
from prediction_example.cpp:8:
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:33: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:33: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp:40: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::AccuracyLayer<Dtype>::AccuracyLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:34: error: ‘param’ was not declared in this scope
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:98: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:98: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::LossLayer<Dtype>::LossLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:99: error: ‘param’ was not declared in this scope
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:151: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:151: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp:157: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::ContrastiveLossLayer<Dtype>::ContrastiveLossLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:152: error: ‘param’ was not declared in this scope
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:240: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:240: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp:245: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::EuclideanLossLayer<Dtype>::EuclideanLossLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:241: error: ‘param’ was not declared in this scope
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:351: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:351: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp:354: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::HingeLossLayer<Dtype>::HingeLossLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:352: error: ‘param’ was not declared in this scope
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:429: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:429: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp:443: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::InfogainLossLayer<Dtype>::InfogainLossLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:430: error: ‘param’ was not declared in this scope
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:522: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:522: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp:527: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::MultinomialLogisticLossLayer<Dtype>::MultinomialLogisticLossLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:523: error: ‘param’ was not declared in this scope
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:600: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:600: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp:609: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::SigmoidCrossEntropyLossLayer<Dtype>::SigmoidCrossEntropyLossLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:601: error: ‘param’ was not declared in this scope
../caffe/include/caffe/loss_layers.hpp: At global scope:
../caffe/include/caffe/loss_layers.hpp:699: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/loss_layers.hpp:699: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/loss_layers.hpp:707: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/loss_layers.hpp: In constructor ‘caffe::SoftmaxWithLossLayer<Dtype>::SoftmaxWithLossLayer(int)’:
../caffe/include/caffe/loss_layers.hpp:700: error: ‘param’ was not declared in this scope
In file included from ../caffe/include/caffe/vision_layers.hpp:10,
from ../caffe/include/caffe/caffe.hpp:16,
from prediction_example.cpp:8:
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:39: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:39: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:46: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::ArgMaxLayer<Dtype>::ArgMaxLayer(int)’:
../caffe/include/caffe/common_layers.hpp:40: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:82: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:82: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:89: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::ConcatLayer<Dtype>::ConcatLayer(int)’:
../caffe/include/caffe/common_layers.hpp:83: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:162: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:162: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:169: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp:185: error: ‘EltwiseParameter_EltwiseOp’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::EltwiseLayer<Dtype>::EltwiseLayer(int)’:
../caffe/include/caffe/common_layers.hpp:163: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:205: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:205: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:210: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::FlattenLayer<Dtype>::FlattenLayer(int)’:
../caffe/include/caffe/common_layers.hpp:206: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:256: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:256: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:263: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::InnerProductLayer<Dtype>::InnerProductLayer(int)’:
../caffe/include/caffe/common_layers.hpp:257: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:294: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:294: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:299: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::MVNLayer<Dtype>::MVNLayer(int)’:
../caffe/include/caffe/common_layers.hpp:295: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:328: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:328: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:333: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::SilenceLayer<Dtype>::SilenceLayer(int)’:
../caffe/include/caffe/common_layers.hpp:329: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:360: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:360: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:365: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::SoftmaxLayer<Dtype>::SoftmaxLayer(int)’:
../caffe/include/caffe/common_layers.hpp:361: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:424: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:424: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:429: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::SplitLayer<Dtype>::SplitLayer(int)’:
../caffe/include/caffe/common_layers.hpp:425: error: ‘param’ was not declared in this scope
../caffe/include/caffe/common_layers.hpp: At global scope:
../caffe/include/caffe/common_layers.hpp:457: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/common_layers.hpp:457: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/common_layers.hpp:464: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/common_layers.hpp: In constructor ‘caffe::SliceLayer<Dtype>::SliceLayer(int)’:
../caffe/include/caffe/common_layers.hpp:458: error: ‘param’ was not declared in this scope
In file included from ../caffe/include/caffe/caffe.hpp:16,
from prediction_example.cpp:8:
../caffe/include/caffe/vision_layers.hpp: At global scope:
../caffe/include/caffe/vision_layers.hpp:66: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/vision_layers.hpp:66: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/vision_layers.hpp:73: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/vision_layers.hpp: In constructor ‘caffe::ConvolutionLayer<Dtype>::ConvolutionLayer(int)’:
../caffe/include/caffe/vision_layers.hpp:67: error: ‘param’ was not declared in this scope
../caffe/include/caffe/vision_layers.hpp: At global scope:
../caffe/include/caffe/vision_layers.hpp:166: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/vision_layers.hpp:166: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/vision_layers.hpp:173: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/vision_layers.hpp: In constructor ‘caffe::Im2colLayer<Dtype>::Im2colLayer(int)’:
../caffe/include/caffe/vision_layers.hpp:167: error: ‘param’ was not declared in this scope
../caffe/include/caffe/vision_layers.hpp: At global scope:
../caffe/include/caffe/vision_layers.hpp:208: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/vision_layers.hpp:208: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/vision_layers.hpp:215: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/vision_layers.hpp: In constructor ‘caffe::LRNLayer<Dtype>::LRNLayer(int)’:
../caffe/include/caffe/vision_layers.hpp:209: error: ‘param’ was not declared in this scope
../caffe/include/caffe/vision_layers.hpp: At global scope:
../caffe/include/caffe/vision_layers.hpp:285: error: ISO C++ forbids declaration of ‘LayerParameter’ with no type
../caffe/include/caffe/vision_layers.hpp:285: error: expected ‘,’ or ‘...’ before ‘&’ token
../caffe/include/caffe/vision_layers.hpp:292: error: ‘LayerParameter_LayerType’ does not name a type
../caffe/include/caffe/vision_layers.hpp: In constructor ‘caffe::PoolingLayer<Dtype>::PoolingLayer(int)’:
../caffe/include/caffe/vision_layers.hpp:286: error: ‘param’ was not declared in this scope
../caffe/include/caffe/vision_layers.hpp: In member function ‘virtual int caffe::PoolingLayer<Dtype>::MaxTopBlobs() const’:
../caffe/include/caffe/vision_layers.hpp:301: error: ‘PoolingParameter_PoolMethod_MAX’ was not declared in this scope
CXX=g++
CFLAGS=-c -Wall -std=c++0x -g3 -msse2 -I. -I/usr/local/cuda/include -I../caffe/include/ -I../caffe/src/
LDFLAGS= -L/usr/local/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -lcudart -lcublas -lcurand -lglog -lgflags -lprotobuf -lleveldb -lsnappy -llmdb -lboost_system -lhdf$
// Libary#include <cuda_runtime.h>#include <stdio.h>#include <stdlib.h> #include <cstdlib>#include <string>#include <fstream>#include <sstream>#include <cstring>#include <cstdlib>#include <vector>#include <iostream>#include <algorithm>#include <ctime>#include <time.h>#include "/home/dkkim930122/caffe-cudnn/include/caffe/caffe.hpp"#include "/home/dkkim930122/caffe-cudnn/include/caffe/util/io.hpp"#include "/home/dkkim930122/caffe-cudnn/include/caffe/blob.hpp"#include "/usr/include/opencv2/core/core.hpp"#include "/usr/include/opencv2/highgui/highgui.hpp"#include "/usr/include/python2.7/Python.h"
using namespace caffe;using namespace std;
int main(int argc, char** argv) {
// Set GPU Caffe::set_mode(Caffe::GPU); int device_id = 0; Caffe::SetDevice(device_id); LOG(INFO) << "Using GPU"; // Load net Net<float> net("/home/dkkim930122/caffe-cudnn/include/exercise.prototxt", caffe::TEST);//<-- depends on caffe version
// Load pre-trained net net.CopyTrainedLayersFrom("/home/dkkim930122/caffe-cudnn/examples/imagenet/caffe_reference_imagenet_model");
// Load image cv::Mat image = cv::imread("/home/dkkim930122/caffe-dev/examples/images/1.jpg"); // or cat.jpg
// Set vector for image vector<cv::Mat> imageVector; imageVector.push_back(image); // image is a cv::Mat, as I'm using #1416 //push_back()
// Set vector for label vector<int> labelVector; labelVector.push_back(0);//push_back 0 for initialize purpose
// Net initialization float loss = 0.0;
shared_ptr<MemoryDataLayer<float> > memory_data_layer;
memory_data_layer = boost::static_pointer_cast<MemoryDataLayer<float> >(net.layer_by_name("data"));
memory_data_layer->AddMatVector(imageVector,labelVector);
// Run ForwardPrefilled vector<Blob<float>*> results = net.ForwardPrefilled(&loss);
// Display result const shared_ptr<Blob<float> >& probs = net.blob_by_name("prob"); const float* probs_out = probs->cpu_data();
for (int i = 0 ; i < 3 ; i++) { LOG(INFO) << "Prob" << i << ": " << probs_out[i]; }
LOG(INFO) << "Max element is: " << *max_element(probs_out,probs_out+3);
// Display result2 const float* argmaxs = results[1]->cpu_data(); for (int i = 0; i < results[1]->num(); i++) { for (int j = 0; j < results[1]->height(); j++) { LOG(INFO) << "Image: "<< i << " class:" << argmaxs[i*results[1]->height() + j]; } }
//printf("%d\n",(int)*argmaxs);
return 0;}
CC=g++
CXXFLAGS = -O2 -Wall -D__STDC_CONSTANT_MACROS
INCLUDE = -I/home/dkkim930122/caffe-cudnn/include \ -I/home/dkkim930122/caffe-cudnn/src \ -I/home/dkkim930122/caffe-cudnn \ -I/usr/local/cuda/include \ -I/home/dkkim930122/opencv-2.4.9/include \ -I/usr/include/python2.7
LIBRARY = -L/usr/local/x86_64-linux-gnu/ -lprotobuf \ -L/usr/lib/x86_64-linux-gnu/ -lglog \ -L/usr/local/cuda/lib64/ -lcudart -lcublas -lcurand \ -L/usr/local/lib/ -lm -lpthread -lavutil -lavformat -lavcodec -lswscale -lopencv_core -lopencv_imgproc -lopencv_highgui \ -L/usr/lib/python2.7/config-x86_64-linux-gnu/ -lpython2.7 \ -L/sur/lib32/ -lrt \ -L../build/lib/ -lcaffe
all: $(CC) $(INCLUDE) $(OBJS) exercise.cpp -o exercise $(LIBRARY)
memory_data_layer->AddMatVector(imageVector,labelVector);'. The error msg I get is :
For the statement net.CopyTrainedLayersFrom("/home/dkkim930122/caffe-cudnn/examples/imagenet/caffe_reference_imagenet_model");
in your program, I instead used net.CopyTrainedLayersFrom("caffeMasterDir/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel"); . I think there could be many answers to this, but I personally use gimp program or use my personal program written in Python to re-size images to 256x256 BEFORE using Caffe. AFTER resizing input image to 256x256, I use Caffe.Hope this helps!
--
You received this message because you are subscribed to a topic in the Google Groups "Caffe Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caffe-users/tMwpaf3s8GQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/ac722ba8-6c57-45b7-a858-e354896a2058%40googlegroups.com.
Dear Dong Ki Kim,
Hello. I'm the new in caffe, and I see your code and rewrite it. As follows.
But I got an error .
error: 'class caffe::MemoryDataLayer<float>' has no member named 'AddMatVector'
memory_data_layer->AddMatVector(imageVector,labelVector);
^
I confirmed the function(AddMatVector) in the file , memory_data_layer.hpp.
could you help me?
If my description is not clear enough, I will make it clearly. Thank you.
envirnment: Ubuntu 14.04
Development Platform:Qt Creator
#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>
#include <ctime>
#include <time.h>
#include "/home/server/桌面/caffe-master/include/caffe/caffe.hpp"
#include "/home/server/桌面/caffe-master/include/caffe/util/io.hpp"
#include "/home/server/桌面/caffe-master/include/caffe/blob.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv/cv.h"
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
//#include "/home/server/桌面/opencv-2.4.10/include/opencv/cv.h"
//#include "/home/server/桌面/opencv-2.4.10/include/opencv/cxcore.h"
//#include "/home/server/桌面/opencv-2.4.10/include/opencv/highgui.h"
#include "/usr/include/glog/logging.h"
#include "/usr/include/gflags/gflags.h"
#include "/usr/include/boost/smart_ptr/shared_ptr.hpp"
// MemoryDataLayer 宣告所需要的條件
#include "/home/server/桌面/caffe-master/include/caffe/layers/memory_data_layer.hpp"
using namespace cv;
using namespace caffe;
using namespace std;
using namespace boost;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// ::google::InitGoogleLogging(argv[0]);
// ::google::SetLogDestination(0, "/home/server/桌面/caffe-master/temp");
// Set GPU
Caffe::set_mode(Caffe::GPU);
int device_id = 0;
Caffe::SetDevice(device_id);
LOG(INFO) << "Using GPU";
// Load net
Net<float> net("/home/server/桌面/caffe-master/examples/myself/lenet_train_test.prototxt", caffe::TEST);
//<-- depends on caffe version
// Load pre-trained net
net.CopyTrainedLayersFrom("/home/server/桌面/caffe-master/examples/myself/lenet_iter_10000.caffemodel");
// Load image
cv::Mat image = cv::imread("/home/server/桌面/caffe-master/data/myself/val/camera.jpg"); // or cat.jpg
// Set vector for image
vector<cv::Mat> imageVector;
imageVector.push_back(image); // image is a cv::Mat, as I'm using #1416 //push_back()
// Set vector for label
vector<int> labelVector;
labelVector.push_back(0);//push_back 0 for initialize purpose
// Net initialization
float loss = 0.0;
shared_ptr<MemoryDataLayer<float> > memory_data_layer;
memory_data_layer = boost::static_pointer_cast < MemoryDataLayer < float > >(net.layer_by_name("data"));
memory_data_layer->AddMatVector(imageVector,labelVector);
// Run ForwardPrefilled
vector<Blob<float>*> results = net.ForwardPrefilled(&loss);
// Display result
const shared_ptr<Blob<float> >& probs = net.blob_by_name("prob");
const float* probs_out = probs->cpu_data();
for (int i = 0 ; i < 2 ; i++)
{
LOG(INFO) << "Prob" << i << ": " << probs_out[i];
}
// LOG(INFO) << "Max element is: " << *max_element(probs_out,probs_out+3);
/*
// Display result2
const float* argmaxs = results[1]->cpu_data();
for (int i = 0; i < results[1]->num(); i++)
{
for (int j = 0; j < results[1]->height(); j++)
{
LOG(INFO) << "Image: "<< i << " class:" << argmaxs[i*results[1]->height() + j];
}
}
*/
//printf("%d\n",(int)*argmaxs);
}