海思开发板——YOLOv3模型移植(4)

1.将*.wk文件和bgr文件准备好

2.修改sample文件

  • sample_svp_nnie_software.h
#define SAMPLE_SVP_NNIE_KERNEL_LOCAL_SIZE (1024)
#define SAMPLE_SVP_NNIE_COORDI_NUM  4      /*coordinate numbers*/
#define SAMPLE_SVP_NNIE_PROPOSAL_WIDTH  6  /*the number of proposal values*/
#define SAMPLE_SVP_NNIE_QUANT_BASE 4096    /*the base value*/
#define SAMPLE_SVP_NNIE_IFDT_END_FLAG 5000 /*the end flag*/
#define SAMPLE_SVP_NNIE_SCORE_NUM  2       /*the num of RPN scores*/
#define SAMPLE_SVP_NNIE_HALF 0.5f          /*the half value*/
#define SAMPLE_SVP_NNIE_PRINT_RESULT 1     /*the switch of result print*/
#define SAMPLE_SVP_NNIE_MAX_RATIO_ANCHORS_NUM 32
#define SAMPLE_SVP_NNIE_MAX_SCALE_ANCHORS_NUM 32
#define SAMPLE_SVP_NNIE_MAX_VLAUE_OF_MIN_ANCHOR_SIZE 100 /*The maximum value of minimum anchor size*/
#define SAMPLE_SVP_NNIE_MAX_VLAUE_OF_SPATIAL_SCALE 2*4096 /*The maximum value of minimum anchor size*/
#define SAMPLE_SVP_NNIE_MAX_VLAUE_OF_ANCHOR_RATIO  100*4096 /*The maximum value of minimum anchor size*/
#define SAMPLE_SVP_NNIE_MAX_VLAUE_OF_ANCHOR_SCALE  500*4096 /*The maximum value of minimum anchor size*/
#define SAMPLE_SVP_NNIE_USE_MUL_THREAD            1 /*Use multi thread*/
#define SAMPLE_SVP_NNIE_MAX_THREAD_NUM            4 /*Multi thread number*/
#define SAMPLE_SVP_NNIE_YOLOV3_REPORT_BLOB_NUM    3 /*yolov3 report blob num*/
#define SAMPLE_SVP_NNIE_YOLOV3_EACH_GRID_BIAS_NUM 6 /*yolov3 bias num of each grid*/
#define SAMPLE_SVP_NNIE_YOLOV3_EACH_BBOX_INFER_RESULT_NUM   8 /*yolov3 inference result num of each bbox*/
SAMPLE_SVP_NNIE_YOLOV3_EACH_BBOX_INFER_RESULT_NUM   5+classNum

  • sample_nnie.c
pstSoftWareParam->u32OriImHeight = pstNnieParam->astSegData[0].astSrc[0].unShape.stWhc.u32Height;
    pstSoftWareParam->u32OriImWidth = pstNnieParam->astSegData[0].astSrc[0].unShape.stWhc.u32Width;
    pstSoftWareParam->u32BboxNumEachGrid = 3;
    pstSoftWareParam->u32ClassNum = 3; //classNum
    pstSoftWareParam->au32GridNumHeight[0] = 13;//img/32
    pstSoftWareParam->au32GridNumHeight[1] = 26;//img/16
    pstSoftWareParam->au32GridNumHeight[2] = 52;//img/8
    pstSoftWareParam->au32GridNumWidth[0] = 13;
    pstSoftWareParam->au32GridNumWidth[1] = 26;
    pstSoftWareParam->au32GridNumWidth[2] = 52;
    pstSoftWareParam->u32NmsThresh = (HI_U32)(0.3f*SAMPLE_SVP_NNIE_QUANT_BASE);
    pstSoftWareParam->u32ConfThresh = (HI_U32)(0.5f*SAMPLE_SVP_NNIE_QUANT_BASE);
    pstSoftWareParam->u32MaxRoiNum = 10;   //每张图最多roi
    pstSoftWareParam->af32Bias[0][0] = 116; //原始文件中的anchor
    pstSoftWareParam->af32Bias[0][1] = 90;
    pstSoftWareParam->af32Bias[0][2] = 156;
    pstSoftWareParam->af32Bias[0][3] = 198;
    pstSoftWareParam->af32Bias[0][4] = 373;
    pstSoftWareParam->af32Bias[0][5] = 326;
    pstSoftWareParam->af32Bias[1][0] = 30;
    pstSoftWareParam->af32Bias[1][1] = 61;
    pstSoftWareParam->af32Bias[1][2] = 62;
    pstSoftWareParam->af32Bias[1][3] = 45;
    pstSoftWareParam->af32Bias[1][4] = 59;
    pstSoftWareParam->af32Bias[1][5] = 119;
    pstSoftWareParam->af32Bias[2][0] = 10;
    pstSoftWareParam->af32Bias[2][1] = 13;
    pstSoftWareParam->af32Bias[2][2] = 16;
    pstSoftWareParam->af32Bias[2][3] = 30;
    pstSoftWareParam->af32Bias[2][4] = 33;
    pstSoftWareParam->af32Bias[2][5] = 23;
HI_CHAR *pcSrcFile = "./data/nnie_image/rgb_planar/street_cars_416x416.bgr";
    HI_CHAR *pcModelName = "./data/nnie_model/detection/yolov3_inst.wk";

3.到板上运行

原文地址:https://www.cnblogs.com/thunder-wu/p/14156276.html