Open dagongji10 opened 2 years ago
@dagongji10 Now I seem met the same problem with you : https://github.com/Tencent/ncnn/issues/3682. Do you have any progress afterwards ?
@dagongji10 Now I seem met the same problem with you : #3682. Do you have any progress afterwards ?
I have solved this problem by changing the way extract data from output mat. Because I found I mistake the format for storing data of ncnn::mat.
for (int i = 0; i < out.h; i++) {
for (int j = 0; j < out.w; j++) {
float t = out.channel(0).row(i)[j];
}
}
针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn
pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]
详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx
具体问题
tf2onnx
工具转换为 db-sim.onnx.txt 文件,进行推理测试结果是正确的;onnx2ncnn
工具将xxx.onnx
转换为 db-sim.param.txt,xxx.bin
;使用ncnn2mem
去除可见字符,得到 db-sim.id.h.txt;// ncnn
include "ncnn/arm64-v8a/include/ncnn/net.h"
include "ncnn/arm64-v8a/include/ncnn/benchmark.h"
include "db-sim.id.h"
static ncnn::Net db; static ncnn::UnlockedPoolAllocator g_blob_pool_allocator; static ncnn::PoolAllocator g_workspace_pool_allocator;
extern "C" JNIEXPORT jboolean JNICALL Java_com_example_db_1ncnn_1demo_DbNcnn_Init(JNIEnv *env, jobject thiz, jobject asset_manager) { // TODO: implement Init() ncnn::Option opt; opt.lightmode = true; opt.num_threads = 1; opt.blob_allocator = &g_blob_pool_allocator; opt.workspace_allocator = &g_workspace_pool_allocator;
}
extern "C" JNIEXPORT jboolean JNICALL Java_com_example_db_1ncnn_1demo_DbNcnn_Detect(JNIEnv *env, jobject thiz, jobject bitmap, jboolean use_gpu) { // TODO: implement Detect() AndroidBitmapInfo info; AndroidBitmap_getInfo(env, bitmap, &info); int width = info.width; int height = info.height;
}