Comments (8)
I'm afraid I'm no expert on OpenCV but I think CV_32FC is NHWC, i.e. in memory the data for an RGB image is RGB,RGB,RGB,etc..,
Caffe convolution needs NCHW, in the Caffe documentation this is described as "n * c_i * h_i * w_i" here: http://caffe.berkeleyvision.org/tutorial/layers/convolution.html. I.e. it's a plane of all the R, followed by all the G, then all the B.
So before passing the image data to your model, as well as converting the pixels to 32-bit floating point, you also have to rearrange it into NCHW layout.
For ExecuteNetwork this is done in InferenceTestImage.cpp.
Hope that helps,
Matthew
from armnn.
Hi @MatthewARM ,
actually you are right. I changed the organization of input data, but the issue still remains. With further investigation I found that the problem is related to the caffe model. Let you consider the following caffe models, that represent a convolutional net with 3 output classes.
- model 1: caffe model generated by default Python training
- model 2: following the suggestion of @TelmoARM in my old thread (#7) is generated in Python as
import caffe
net = caffe.Net('model1.prototxt', 'model1.caffemodel', caffe.TEST)
net.save('model2.caffemodel')
The following are the results for using both the models with a) standard Caffe c++ library and b) armnnCaffeParser with the same input image
a) standard Caffe c++
- model 1: output probabilities : [1 4.49625e-12 2.43979e-18] -> correct
- model 2: Armnn Error: Unsupported layer type 'Data' (as reported in old issue 7)
b) armnnCaffeParser
- model 1: output probabilities : [0.471663 0.248880 0.279457] -> wrong
- model 2: Armnn Error: [0.471663 0.248880 0.279457] -> wrong
So actually it seems that caffe library and armnn work in the same way but there is still something related to the model. If needed I can provide both the models
from armnn.
I'm pretty sure the problem must still be in the processing of the input data. Are you able to run your model through ExecuteNetwork?
from armnn.
Hi @MatthewARM ,
I don't think the problem is in the input data since I'm running in the same program the code for Caffe library C++ and for ArmnnCaffeParser. This is what I do:
- First I build the model for Caffe c++, load the data and run it. I definetly sure that in the Caffe c++ model input data are correctly loaded since I'm succesfully working with it from a while
- Than I take the vector of input data from Caffe model and I put it as input to Armnn model, I just need to convert from float* to vector
Sorry I've just see that my last msg was wrong. This is the right situation for the results:
a) standard Caffe c++
- model 1: output probabilities : [1 4.49625e-12 2.43979e-18] -> correct
- model 2: output probabilities : [0.471663 0.248880 0.279457] -> wrong
b) armnnCaffeParser
- model 1: Armnn Error: Unsupported layer type 'Data' (as reported in old issue 7)
- model 2: output probabilities: [0.471663 0.248880 0.279457] -> wrong
As you can see for model2 Caffe c++ and Armnn give the same wrong results
from armnn.
If you are getting the same results from Caffe and Armnn, then the problem must be in the input data. Presumably the old 'data' layer was doing some stuff automatically that is not done by the new 'input' layer.
from armnn.
Ok @MatthewARM ,
I tried to open an issue on Caffe official repository since I don't have an idea on what has to be modified.
Nevertheless I think that more documentation and example data have to be provided on Armnn repository, since at the moment it is not easy to understand how to correctly use the library
from armnn.
Hi @liviolima80,
I agree and we're working on new documentation just as much as we're working on new functionality and performance.
On the subject of examples, in this case the ArmNN runtime is performing as intended as a drop-in replacement for the Caffe runtime, so you should be able to follow a Caffe example. There is also code at https://github.com/ARM-software/ML-examples which has an example use of ArmNN in an MNIST application.
from armnn.
HI @liviolima80 I'm closing this issue as it seems the original problem (data layout) has been resolved. if you figure out what the remaining problem is then please do let us know.
from armnn.
Related Issues (20)
- Gather(ND) dim error HOT 1
- Link error on older Android devices HOT 8
- BUG: using delegate with transformer | AttributeError: 'NoneType' object has no attribute 'c_void_p' HOT 22
- About the configuration setting of externalMemoryManagementEnabled HOT 1
- The mali gpu computation capability is only used no more than 15% when inference resnet50 with ArmNN HOT 1
- onnx deployment fail HOT 7
- Another error on another model and by now it's two out of three :( HOT 22
- Unsupported Operation "Transpose" in armNN::OnnxParser while loading the onnx model file (in the goal to run inference) HOT 8
- Build Issues -Werrors on armbian 24 HOT 1
- nvalid attempt to construct ConstTensor from non-constant TensorInfo HOT 1
- Profiler service warnings seen in ArmNN v24.02 HOT 4
- Does ExecuteNetwork support "GpuAcc" runtime ? HOT 13
- Running YOLOv5 ONNX model with onnx parser of armnn fails with unsupported operation HOT 2
- Crash when support ArmNN AIDL backend based on a shim over the NNAPI Support Library
- Crash when support ArmNN AIDL backend based on a shim over the NNAPI Support Library HOT 2
- Unitests failed HOT 3
- understanding the onnx parser HOT 2
- Whisper tflite doesn't work HOT 4
- Error compiling `OnnxMnist-Armnn.cpp` HOT 2
- How to set priority of the application running on GPU? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from armnn.