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

YOLOv5 segmentation now is possible! #46

Closed
wants to merge 15 commits into from

Conversation

hdnh2006
Copy link
Contributor

@hdnh2006 hdnh2006 commented Apr 21, 2023

In this PR you will be able to use YOLOv5 segmentation from Ultralytics to create masks and accelerate the process in labeling data.

All the segmentation models can be downloaded from here: https://github.com/hdnh2006/anylabeling-assets/releases/tag/v0.0.0

They have been exported with --opset 12 as option as following:
python export.py --weights yolov5x-seg.pt --include onnx --opset 12

An important change has been done in the blob preprocessing of all yolo models, since the image is already in BGR format, so swapRB=False has been set in order to avoid changes in the channels.

Again, if there is any change you need, please let me know.

Copy link
Owner

@vietanhdev vietanhdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.
I think you have skipped all pre-commit when committing your code. Please do following:

image

anylabeling/services/auto_labeling/yolov5_seg.py Outdated Show resolved Hide resolved
anylabeling/services/auto_labeling/yolov5_seg.py Outdated Show resolved Hide resolved
anylabeling/services/auto_labeling/yolov5_seg.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@hdnh2006 hdnh2006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes requested have been done

if area > avg_area * 0.2
]
contours = filtered_approx_contours

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the first point again as the last element to close the contour.
Like the line 271 of this file: https://github.com/vietanhdev/anylabeling/blob/master/anylabeling/services/auto_labeling/segment_anything.py

points.append(points[0])

The contours will not be closed if you don't do it.

image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vietanhdev
Copy link
Owner

vietanhdev commented Apr 24, 2023

There are some differences between your YOLOv5 segmentation result with the result from this repo (using the same model).

For YOLOv5n Segmentation

n_segment

  • Result from your implementation:

n_segment_anylabeling

Note: Missing chairs and not good segmentation result in the man's leg.

For YOLOv5x Segmentation

x_segment

  • Result from your implementation:

x_segment_anylabeling

Could you please check the implementation for the reason?
Thank you!

@hdnh2006
Copy link
Contributor Author

hdnh2006 commented May 1, 2023

Thanks @vietanhdev,

Please, could you share the image you are using? so both, can work on the same source.

@vietanhdev
Copy link
Owner

Please check this image.
photo-1595950009887-e9842bcbc1ae.png.zip

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

Successfully merging this pull request may close these issues.

2 participants