alexge233 / espresso-maker Goto Github PK
View Code? Open in Web Editor NEWA Caffe2 C++ wrapper/helper
License: GNU General Public License v3.0
A Caffe2 C++ wrapper/helper
License: GNU General Public License v3.0
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.
Just wanted to thank you for posting this code!
https://github.com/alexge233/espresso-maker/blob/master/espresso.cpp#L120-L127
That part saved me while trying to figure out how to convert a GpuMat to a tensor for Yolo v3. I know the projects are different but changing from HWC -> CHW threw me off for a while.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.