First of all, thank you for your tips on the creation of TensorCUDA from opencv GpuMat.
I'm facing a problem with the submission of such a tensor to a pretrained neural network. My code follows, with 'image' an opencv GpuMat.
auto ptr = tensor.mutable_data<float>();
size_t width = image.cols * image.rows;
std::vector<cv::gpu::GpuMat> input_channels {
cv::gpu::GpuMat(image.rows, image.cols, CV_32F, &ptr[0]),
cv::gpu::GpuMat(image.rows, image.cols, CV_32F, &ptr[width]),
cv::gpu::GpuMat(image.rows, image.cols, CV_32F, &ptr[width * 2])
};
cv::gpu::split(image, input_channels);
CAFFE_ENFORCE(this->workspace.RunNetOnce(this->init_net));
auto input = this->workspace.CreateBlob("1")->GetMutable<caffe2::TensorCUDA>(); /
input->CopyFrom(tensor);
CAFFE_ENFORCE(workspace.RunNetOnce(this->predict_net));
auto output = this->workspace.GetBlob("34")->Get<caffe2::TensorCUDA>();
caffe2::TensorCPU tensor_cpu(output);
const float* proba = tensor_cpu.mutable_data<float>();
The output I get in 'proba' seems to be random and does not change with the submitted image. Either (1) the image in not passed to the network (2) the output of the network is not passed to tensor_cpu.
How do you proceed to pass the pointer to the image in the 'input' tensor?
Thanks.