Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with yolov7 blob inference #26

Closed
Evzen-T opened this issue Dec 12, 2022 · 8 comments
Closed

Issues with yolov7 blob inference #26

Evzen-T opened this issue Dec 12, 2022 · 8 comments
Assignees

Comments

@Evzen-T
Copy link

Evzen-T commented Dec 12, 2022

A github repo on how to reproduce the issue - https://github.com/Evzen-T/yolov7_blob_issue

Issue

  • When inferencing with custom yolov7 trained pt weights, it works as intended with 1 bounding box per object with default IOU
  • While inferencing with converted custom yolov7 trained blob weights, it has multiple bounding boxes per object with default IOU
  • Meanwhile Official yolov7 weights for both pt & converted to blob weights, works as intended with 1 bounding box per object with default IOU

So this could be an issue with blob conversion for general purpose/specific purpose

@Evzen-T
Copy link
Author

Evzen-T commented Dec 13, 2022

The only solution to this is lowering the IOU to 0.1 in the json config files. Even coneslayer github repo which is a custom trained model requires a 0.1 & fintan-osullivan-pk on discord is also facing the same issue. Plus even if I use IOU of 0.1, although it does reduce the bounding boxes to 1 per object, it is not outline the objects i want the model to detect. fintan-osullivan-pk also faced the same issue as per the discord link below.

Blob inferencing issue - https://discord.com/channels/790680891252932659/924798614268682260/1050695358562435092
Coneslayer - https://github.com/mkrupczak3/Coneslayer
fintan-osullivan-pk - https://discord.com/channels/790680891252932659/924798614268682260/1051655638528307230

@tersekmatija
Copy link
Collaborator

@HonzaCuhel can you take a look if we don't correctly extract the anchors for V7 please?

@CJavier11
Copy link

I am facing the same issue upon conversion of a yolov7-tiny model from its Yolo to blob weights. This seems similar to an issue that could arise without the use of NMS in inference.
The yolov7 anchors appear to be identical to yolov5 anchors when training on the same data, however, the export method is different.
https://github.com/luxonis/tools/blob/master/yolo/export_yolov5.py
line 92: sides.append(m.anchor_grid[i].size()[3])
https://github.com/luxonis/tools/blob/master/yolov7/yolo/export_yolov7.py
line 90: sides.append(int(self.imgsz[0] // m.stride[i]))

@tersekmatija
Copy link
Collaborator

The anchors should be correct and the export is different to match the way the anchors are stored. I think the issue might be due to the additional fuse() call in export_yolov7.py method in L26. We will look into it and patch if this is what's causing the issue.

@tersekmatija
Copy link
Collaborator

Fixed in #e51a718. CC @Evzen-T @CJavier11

@Evzen-T
Copy link
Author

Evzen-T commented Dec 16, 2022

image
Seems to be working. Thanks for fixing this issue

@Evzen-T Evzen-T closed this as completed Dec 16, 2022
@mkrupczak3
Copy link

mkrupczak3 commented May 2, 2023

I've been noticing the same issue with Coneslayer regarding bounding boxes. I just re-converted the pytorch to a blob, will see if this bugfix improves our results

mkrupczak3/Coneslayer@9c40bb8

@mkrupczak3
Copy link

This fix has significantly improved bounding boxes in our testing. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants