Got it

Yolov3-tiny Inference

Created: Sep 3, 2021 07:29:22Latest reply: Sep 13, 2021 22:49:39 619 8 0 0 0
  HiCoins as reward: 0 (problem unresolved)

Hi,


I have some issues converting darknet yolov3-tiny to Huawei Compatible(*.om) format.


What has been done so far is briefly described below:

1) According to darknet2caffe github repo (https://github.com/ChenYingpeng/darknet2caffe), model was successfully converted to caffe model,

2) According to CANN/Modifying YOLOv3 Prototxt (https://support.huaweicloud.com/intl/en-us/atctool-cann502alphaXinfer/atlasatc_16_0104.html), yolov3-tiny.prototxt file was modified. But the steps in this link are not directly applied due to yolov3 model whic have 3 yolo layer and 9 anchor boxes.

3) According to CANN Caffe Operator Specification List (https://support.huawei.com/enterprise/en/doc/EDOC1100191926?idPath=23710424|251366513|22892968|251168373), yolov3-tiny.prototxt file was modified. Because yolov3-tiny have 2 yolo layer and 6 anchor boxes.


That's why I added the yolo layer information to the end of our prototxt file as shown below;

layer {
	bottom: "layer16-conv"
	top: "yolo1_coords"
	top: "yolo1_obj"
	top: "yolo1_classes"
	name: "yolo1"
	type: "Yolo"
	yolo_param {
		boxes: 3
		coords: 4
		classes: 1  
		yolo_version: "V3"
		softmax: true
		background: false
    }
}
layer {
	bottom: "layer23-conv"
	top: "yolo2_coords"
	top: "yolo2_obj"
	top: "yolo2_classes"
	name: "yolo2"
	type: "Yolo"
	yolo_param {
		boxes: 3
		coords: 4
		classes: 1  
		yolo_version: "V3"
		softmax: true
		background: false
	}
}
layer {
       name: "detection_out3"
       type: "YoloV3DetectionOutput"
       bottom: "yolo1_coords" 
       bottom: "yolo2_coords"
       bottom: "yolo1_obj"
       bottom: "yolo2_obj" 
       bottom: "yolo1_classes"
       bottom: "yolo2_classes"
       bottom: "img_info"
       top: "box_out"
       top: "box_out_num"
       yolov3_detection_output_param {
                           boxes: 3
                           classes: 1
                           relative: true
                           obj_threshold: 0.5
                           score_threshold: 0.5
                           iou_threshold: 0.45
                           pre_nms_topn: 256
                           post_nms_topn: 512
						   biases_high: 10
                           biases_high: 14
                           biases_high: 23
                           biases_high: 27
                           biases_high: 37
                           biases_high: 58 
						   biases_low: 81
                           biases_low: 82  
                           biases_low: 135
                           biases_low: 169
                           biases_low: 344
                           biases_low: 319
       }
}


4) Acording to pyacl_samples/acl_yolov3_caffe gitee repo (https://gitee.com/tianyu__zhou/pyacl_samples/tree/a800/acl_yolov3_caffe), The model was successfully converted from caffe to .om format using ATC tool,

5) Finally, Acording to pyacl_samples/acl_yolov3_caffe gitee repo, inferenc was done and everything looked so good but after the converting process, detection performance of the model decreased a lot. So, The model that provides 9/10 image detection on darknet, provides 4/10 image detection on .om format.


So, what can I do at this stage? Can you help me for this issue?

If you have any idea to figure it out this problem, I would be happy to hear. 


Have a nice day.

Best,


Kubilay

Featured Answers

Recommended answer

stephen.xu
Admin Created Sep 8, 2021 01:58:06

Hello, from your description, you can successfully transform and reason the model, but there are problems with the accuracy of reasoning.
You can add precision_mode= allow_FP32_to_FP16 to the ATC conversion, as shown in the link below
https://support.huaweicloud.com/intl/en-us/atctool-cann502alphaXinfer/atlasatc_16_0081.html
View more
  • x
  • convention:

kunthea
kunthea Created Sep 8, 2021 02:51:36 (0) (0)
 
All Answers
Hello,
Kindly wait for a second, our engineers will feedback to you ASAP.
View more
  • x
  • convention:

Yolov3-tiny Inference-4118317-1
View more
  • x
  • convention:

@chenhui

Hi,

Is there any progress on this issue? I'm looking forward to your suggestion.

Have a nice day.

Best,

Kubilay
View more
  • x
  • convention:

Hello, from your description, you can successfully transform and reason the model, but there are problems with the accuracy of reasoning.
You can add precision_mode= allow_FP32_to_FP16 to the ATC conversion, as shown in the link below
https://support.huaweicloud.com/intl/en-us/atctool-cann502alphaXinfer/atlasatc_16_0081.html
View more
  • x
  • convention:

kunthea
kunthea Created Sep 8, 2021 02:51:36 (0) (0)
 
Good
View more
  • x
  • convention:

@stephen.xu

Hi,

First of all, thank you very much for your answer. I did what you said but it didn't work for me. The real problem here is post-processing. I have no such problem for yolov3 model trained with same dataset.

Also, I am an Atlas engineer from Huawei and According to a headquarters expert I know, Caffe yolov3 was designed for the post-processing operator yolov3/v4. That's why he said using the yolov3 post-processing opreation on tiny-yolov3 is very likely to be problematic.

As can be seen in the image below, there is only an example for yolov3.

YOLOv3 Prototxt

Related Link : https://support.huaweicloud.com/intl/en-us/atctool-cann502alphaXinfer/atlasatc_16_0104.html


If you have any good idea, I would be happy hear.


Have a nice day.

Best,


Kubilay

View more
  • x
  • convention:

stephen.xu
stephen.xu Created Sep 14, 2021 00:47:20 (0) (0)
 

Comment

You need to log in to comment to the post Login | Register

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.