- E Traceback (most recent call last):
- E File "rknn/api/rknn_base.py", line 737, in rknn.api.rknn_base.RKNNBase.build
- E File "rknn/api/rknn_base.py", line 1644, in rknn.api.rknn_base.RKNNBase._quantize2
- E File "rknn/base/RKNNlib/app/medusa/quantization.py", line 105, in rknn.base.RKNNlib.app.medusa.quantization.Quantization.run
- E File "rknn/base/RKNNlib/app/medusa/quantization.py", line 41, in rknn.base.RKNNlib.app.medusa.quantization.Quantization._run_quantization
- E File "rknn/base/RKNNlib/range/analyze_range.py", line 390, in rknn.base.RKNNlib.range.analyze_range.sparse_network
- E File "rknn/base/RKNNlib/range/analyze_range.py", line 288, in rknn.base.RKNNlib.range.analyze_range.analyze_operation
- E File "rknn/base/RKNNlib/range/analyze_range.py", line 187, in rknn.base.RKNNlib.range.analyze_range._a_bn
- E File "rknn/base/RKNNlib/range/analyze_range.py", line 30, in rknn.base.RKNNlib.range.analyze_range._bn_channel_range
- E TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'
- Build pre-compile shufflenet_v2 failed!
- Process finished with exit code 255
复制代码
kyo055 发表于 2020-6-5 11:48
补充,当选择optimization_level=0 时候,模型居然build出错
###
leok 发表于 2020-6-5 14:47
把信息帖全一些;
rknn toolkit版本、其它toolkit版本、原始模型推理是否正确、原始模型如果推理正确的情 ...
kyo055 发表于 2020-6-5 15:37
rknn toolkit v1.3.0 版本, 模型build都正确,原始模型也推理正确,在Caffe也测试过; 就是转出来后, r ...
leok 发表于 2020-6-5 16:06
先参照下这个文档看看能否解决:
https://github.com/rockchip-linux/rknn-toolkit/blob/master/doc/Rock ...
kyo055 发表于 2020-6-5 16:31
这里面都是RKNN转换,没有这个trouble的解决方法; 而且这个是我在Ubuntu环境下,在PC端进行simulator时 ...
leok 发表于 2020-6-8 08:50
1.3.2版本:https://github.com/rockchip-linux/rknn-toolkit/
同时可以试试在板子上看看 ...
kyo055 发表于 2020-6-8 10:09
我先试一下,你们那些Python的转换工具和模拟工具能开源?
leok 发表于 2020-6-10 08:48
上层python toolkit是开源的。
底层实现和芯片相关。
leok 发表于 2020-6-10 08:48
上层python toolkit是开源的。
底层实现和芯片相关。
- --> Export RKNN model
- done
- --> Init runtime environment
- W [set_chip_platform_env:187]evaluate model on RK1808
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- W [op_optimize:333]Split copy 0 tensor.
- done
- --> Running model
- ASSERT in NeuralNet.cpp.decompressKernel(1889): readBias == 0
- terminate called after throwing an instance of 'bool'
- Aborted (core dumped)
复制代码
leok 发表于 2020-6-10 08:48
上层python toolkit是开源的。
底层实现和芯片相关。
kyo055 发表于 2020-6-10 12:30
你好像只发布了 wheel文件, 但是在里面的转换规则 看不到哦,所以能不能给个转换规则或者C++的仿真库, ...
leok 发表于 2020-6-12 14:50
转换规则只是从一个格式转到另一个格式,对使用者来说意义不大。
leok 发表于 2020-6-10 08:48
上层python toolkit是开源的。
底层实现和芯片相关。
leok 发表于 2020-6-12 14:50
转换规则只是从一个格式转到另一个格式,对使用者来说意义不大。
- 2017-08-05 23:04:05.362 20048-20233/com.rockchip.gpadc.ssddemo E/rkssd4j: 查找的设备[0]: type=USB_DEVICE, id=0123456789ABCDEF
- 2017-08-05 23:04:09.608 20048-20233/com.rockchip.gpadc.ssddemo E/rkssd4j: model input num: 1, output num: 1
- 2017-08-05 23:04:26.675 20048-20233/com.rockchip.gpadc.ssddemo E/rkssd4j: model input[0] : , dim: 4, fmt: 0, type: 3, qnt_type: 2
- # 测试代码
- std::string lands_model_path = "/data/user/0/com.rockchip.gpadc.ssddemo/cache/shuffle-stage.rknn";
- FILE *fp_lands = fopen(lands_model_path.c_str(), "rb");
- if(fp_lands == NULL) {
- LOGE("fopen %s fail!\n", lands_model_path.c_str());
- return;
- }
- fseek(fp_lands, 0, SEEK_END);
- int lands_model_len = ftell(fp_lands);
- void *lands_model = malloc(lands_model_len);
- fseek(fp_lands, 0, SEEK_SET);
- if(lands_model_len != fread(lands_model, 1, lands_model_len, fp_lands)) {
- LOGE("fread %s fail!\n", lands_model_path.c_str());
- free(lands_model);
- fclose(fp_lands);
- return;
- }
- fclose(fp_lands);
- // RKNN_FLAG_ASYNC_MASK: enable async mode to use NPU efficiently.
- rknn_context lands_ctx = 0;
- int lands_ret = rknn_init(&lands_ctx, lands_model, lands_model_len, RKNN_FLAG_PRIOR_HIGH);
- free(lands_model);
- if(lands_ret < 0) {
- LOGE("rknn_init shuffle_stage landmarks fail! ret=%d\n", ret);
- return;
- }
- // 查询sdk版本信息
- rknn_sdk_version version;
- lands_ret = rknn_query(lands_ctx, RKNN_QUERY_SDK_VERSION, &version,
- sizeof(rknn_sdk_version));
- LOGE("api version: %s\n", version.api_version);
- LOGE("driver version: %s\n", version.drv_version);
- // 查找设备
- rknn_devices_id devids;
- ret = rknn_find_devices (&devids);
- LOGE("查找设备: n_devices = %d\n", devids.n_devices);
- for(int i=0; i<devids.n_devices; i++) {
- LOGE("查找的设备[%d]: type=%s, id=%s\n", i, devids.types[i], devids.ids[i]);
- }
- // 查询输入Tensor的属性
- rknn_input_output_num io_num;
- ret = rknn_query(lands_ctx, RKNN_QUERY_IN_OUT_NUM, &io_num, sizeof(io_num));
- if(ret < 0) {
- LOGE("rknn_query fail! ret=%d\n", ret);
- }
- LOGE("model input num: %d, output num: %d\n", io_num.n_input, io_num.n_output);
- // 查询Input的Tensor属性
- rknn_tensor_attr input_attrs[io_num.n_input];
- memset(input_attrs, 0, sizeof(input_attrs));
- for (int i = 0; i < io_num.n_input; i++) {
- input_attrs[i].index = i;
- ret = rknn_query(lands_ctx, RKNN_QUERY_INPUT_ATTR, &(input_attrs[i]),
- sizeof(rknn_tensor_attr));
- LOGE("model input[%d] : %s, dim: %d, fmt: %d, type: %d, qnt_type: %d \n", i, \
- input_attrs[i].name, input_attrs[i].n_dims, input_attrs[i].fmt, input_attrs[i].type,\
- input_attrs[i].qnt_type);
- // 打印各维度值就是shape
- }
- // 查询Ouput的Tensor属性
- rknn_tensor_attr output_attrs[io_num.n_output];
- memset(output_attrs, 0, sizeof(output_attrs));
- for (int i = 0; i < io_num.n_output; i++) {
- output_attrs[i].index = i;
- ret = rknn_query(lands_ctx, RKNN_QUERY_OUTPUT_ATTR, &(output_attrs[i]),
- sizeof(rknn_tensor_attr));
- LOGE("model output[%d] : %s, dim: %d, fmt: %d, type: %d, qnt_type: %d \n", i, \
- output_attrs[i].name, output_attrs[i].n_dims, output_attrs[i].fmt, output_attrs[i].type,\
- output_attrs[i].qnt_type);
- }
- // 设置输入
- /// 1. 读取图像作为BGR输入 112x112x3 NHWC格式
- std::string lands_img_path = "/data/user/0/com.rockchip.gpadc.ssddemo/cache/npu_test_lands.png";
- cv::Mat img = cv::imread(lands_img_path.c_str());
- /// 2. 将图像传入RKNN_INPUT_TENSOR
- rknn_input inputs[io_num.n_input];
- memset(inputs, 0, sizeof(inputs));
- for (uint32_t i = 0; i < io_num.n_input; i++){
- inputs[i].index = i;
- inputs[i].type = RKNN_TENSOR_UINT8;
- inputs[i].size = (uint32_t)img.cols*img.rows*img.channels();
- inputs[i].pass_through = (uint8_t)false; // 非直通模式,将当前数据类型传递到模型中,并在模型内部转换;
- inputs[i].fmt = RKNN_TENSOR_NHWC;
- inputs[i].buf = img.data;
- }
- ret = rknn_inputs_set(lands_ctx, io_num.n_input, inputs);
- // 运行rknn模型
- ret = rknn_run(lands_ctx, NULL);
- if(ret != RKNN_SUCC){
- LOGE("rknn_run fail! ret=%d\n", ret);
- }
- // 获取rknn结果信息
- rknn_output outputs[io_num.n_output];
- memset(outputs, 0, sizeof(outputs));
- for (int i = 0; i < io_num.n_output; i++) {
- outputs[i].want_float = (uint8_t)true;
- outputs[i].is_prealloc = (uint8_t)false;
- }
- ret = rknn_outputs_get(lands_ctx, io_num.n_output, outputs, NULL);
- // 绘制人脸图像并保存人脸结果
- float *pf_src = (float *)outputs[0].buf;
- for (int i = 0; i < output_attrs[0].dims[2]; ++i) {
- float x = pf_src[2*i];
- float y = pf_src[2*i + 1];
- float x_w = x * img.cols;
- float y_h = y * img.rows;
- cv::circle(img,cv::Point(x_w, y_h),2, cv::Scalar(0,0,255),1, 8);
- }
- std::string lands_img_out = "/data/user/0/com.rockchip.gpadc.ssddemo/cache/npu_res_lands.png";
- cv::imwrite(lands_img_out.c_str(), img);
- // 释放输出结果的内存
- ret = rknn_outputs_release(lands_ctx, io_num.n_output, outputs);
- // 释放模型
- rknn_destroy(lands_ctx);
- 2017-08-05 23:04:26.675 20048-20233/com.rockchip.gpadc.ssddemo E/rkssd4j: model output[0] : , dim: 4, fmt: 0, type: 3, qnt_type: 2
复制代码
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |