After train and convert model in yolov7 there is and multiple detection on output

Which Khadas SBC do you use?

khadas vim3

Which system do you use? Android, Ubuntu, OOWOW or others?

ubuntu

Which version of system do you use? Khadas official images, self built images, or others?

after model convert in interface i got multiple detection in yolov7`

Post a console log of your issue below:

OUTPUT2

Hello @upeya

@Louis-Cheng-Liu will help you then.

Hello @upeya ,

Do you use our YOLOv7 demo?

It is the mistake in post-process. But from the two images, i am not sure where the problem lies in the post-process.

yes i have used but i want to use custom dataset so i have try.
this is my onnx converted model.


Hello @upeya ,

Your model is different from our YOLOv7 demo model. Our model only has three outputs and outputs shape are different, too. You need to modify post-process which is fixed your model output.

And I am curious about the last four outputs. Is the normal outputs in your model? What result do they export?

i also dont know about this output but i have also test another model and in that also same thing happen.



Hello @upeya ,

You forget to do this step.

Our demo model.

Another method. You can modify demo to change the dimensions after getting outputs.

-    input0_data = input0_data.reshape(SPAN, LISTSIZE, GRID0, GRID0)
-    input1_data = input1_data.reshape(SPAN, LISTSIZE, GRID1, GRID1)
-    input2_data = input2_data.reshape(SPAN, LISTSIZE, GRID2, GRID2)
+    input0_data = input0_data.reshape(SPAN, GRID0, GRID0,  LISTSIZE)
+    input1_data = input1_data.reshape(SPAN, GRID1, GRID1,  LISTSIZE)
+    input2_data = input2_data.reshape(SPAN, GRID2, GRID2,  LISTSIZE)

-    input_data.append(np.transpose(input0_data, (2, 3, 0, 1)))
-    input_data.append(np.transpose(input1_data, (2, 3, 0, 1)))
-    input_data.append(np.transpose(input2_data, (2, 3, 0, 1)))
+    input_data.append(np.transpose(input0_data, (1, 2, 0, 3)))
+    input_data.append(np.transpose(input1_data, (1, 2, 0, 3)))
+    input_data.append(np.transpose(input2_data, (1, 2, 0, 3)))

And remember modify LISTSIZE in demo.

i have try so many time to convert best.pt to onnx with this steps but always i get this Output.
Screenshot from 2024-05-30 12-12-05

Hello @upeya ,

Emmm… Are you sure that you modify it in right place?


The place is in function named IDetect. And suggest that you can add some print to make sure it can affect when convert model.

yes i am sure, i have verified it.
After that i run python export.py --weights runs/train/exp/weights/best.pt

Hello @upeya ,

Sorry, i describe wrong. In class IDetect function fuseforward.


image

Hello @upeya ,

Emmm… I am confused too… I suggest that you can add some print to make sure when export model it use which forward.

Or you can try another method to change output on demo codes.

After doing this class IDetect function fuseforward .

Hello @upeya ,

These outputs are right. Could it infer right result?

yes , thanks a lot :slight_smile:

hey bro, is there any model for face recognition work with npu (vim3) ?

Hello @upeya ,

Sorry, VIM3 does not have face recognition now. Only has RetinaFace by C++ which detects faces and the key-points each face. Do not have KSNN version.
Application Source Code [Khadas Docs]

If you want to do it, you can try to refer VIM4 Face Recognition model and realize Face Recognition by yourself on VIM3.
Face Recognition VIM4 Demo - 7 [Khadas Docs]