mxsurui / NNIE-lite

⚡️ Using NNIE as simple as using ncnn ⚡️
MIT License
183 stars 49 forks source link

yolov4 需要修改parseYolov3Feature这个函数吗? #9

Open jcyhcs opened 3 years ago

jcyhcs commented 3 years ago

大佬你好,我将yolov4模型转化成了nnie wk文件,利用nnie-lite进行推理的时候,我修改了anchors部分,修改如下: image 请问 image这个函数还修改吗?如果需要,怎么修改呢?

mxsurui commented 3 years ago

大佬你好,我将yolov4模型转化成了nnie wk文件,利用nnie-lite进行推理的时候,我修改了anchors部分,修改如下: image 请问 image这个函数还修改吗?如果需要,怎么修改呢?

你给的图片我看不到,yolov4和yolov3的框架是相同的,不过是对v3的子结构进行了改进,anchor部分的解析是一样的

jcyhcs commented 3 years ago
**parseYolov3Feature**(img_width,
                   img_height,
                   num_classes,
                   kBoxPerCell,
                   feature_index0,
                   conf_threshold,
                   anchors[0],
                   output0,
                   ids,
                   boxes,
                   confidences);

就是这个函数,您的意思这个函数是用来解析anchors的,对吗?故在yolov4下也不用做任何修改, 但是yolov4的anchors和v3的不同,这个需要根据cfg文件修改吧,我修改如下: const std::vector<std::vector> anchors = { {{142, 110}, {192, 243}, {459, 401}}, {{36, 75}, {76, 55}, {72, 146}}, {{12, 16}, {19, 36}, {40, 28}}};

mxsurui commented 3 years ago
**parseYolov3Feature**(img_width,
                   img_height,
                   num_classes,
                   kBoxPerCell,
                   feature_index0,
                   conf_threshold,
                   anchors[0],
                   output0,
                   ids,
                   boxes,
                   confidences);

就是这个函数,您的意思这个函数是用来解析anchors的,对吗?故在yolov4下也不用做任何修改, 但是yolov4的anchors和v3的不同,这个需要根据cfg文件修改吧,我修改如下: const std::vector anchors = { {{142, 110}, {192, 243}, {459, 401}}, {{36, 75}, {76, 55}, {72, 146}}, {{12, 16}, {19, 36}, {40, 28}}};

不同的数据,根据目标大小预设的anchor框,肯定是需要改的,这样改可以。那个函数就是根据模型计算出的anchor的偏移量,结合anchor计算出实际box的函数。