-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to do transpose on input data, (hwc->chw) #815
Comments
you can change the order_type param to 5 Line 86 in 8ff831f
|
So just use: The original code: But in this link (https://github.com/Tencent/ncnn/wiki/low-level-operation-api) |
the order_type convention is the inner-dim-first |
got it, much appreciated. |
I used the given transpose function to do preprocessing on the input data. However, no matter what order_type I set, the output of the model is exactly the same. I've read #221, does ncnn::Mat automatically transform channel order hwc in cv::Mat to chw in ncnn:Mat? Or do I have to do the transpose on cv::Mat and then initialized the ncnn::Mat? My final goal is to feed a 3x112x112 rgb image to the model. Thanks! |
use Mat::from_pixels() to convert RGB packed data to Mat |
So this line of code can read cv::Mat, which is in BGR order, into RGB order in ncnn:Mat: But how to further transpose it into dimensionality of 3x112x112? What I've done is that I firstly use from_pixels() function to initialize ncnn::Mat, but when I use the transpose() function (mentioned earlier in this issue) to change the dimensionality from 112x112x3 to 3x112x112, the output of the network seems to be the same, so it seems that the transpose() function is not working. The overall question I have now is after caffe int 8 quantization, my face recognition network has lost too much performance, I'm trying to eliminate all the possible errors apart from the quantized model itself. So I want to be 100% sure that my input is correct, then I can determine what the problem is, the input or the model itself. Sorry to keep you busy in the recent days, I really appreciate your help. |
@nihui I am also attempting to transpose an image (following https://github.com/nihui/ncnn-webassembly-yolov5) and can't figure out a way to do so -
|
@lizozom As far as I can understand, from_pixels already converts your hwc data to chw layout:
|
Hi @nihui I am sorry this is maybe another dumb question, but how prevent Mat::from_pixels() from transposing my tensor I want to keep it hwc |
from_pixels()默认将HWC转为CHW,你只需要给它cv::Mat就可以。 |
Hi all,
I found this code in wiki to transpose chw to cwh:
Does anyone know how to transpose Mat, HWC to CHW?
I'm sorry this may be a dumb question, but I'm new to c++ and ncnn, any help is appreciated.
Thanks.
The text was updated successfully, but these errors were encountered: