-
Notifications
You must be signed in to change notification settings - Fork 129
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
Fix bugs in mvtec exporter #835
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @djdameln,
Thanks for your contribution!
Is it ok if MvtecTask.detection
has {0,1}
mask? I think your correction should apply to this too.
datumaro/datumaro/plugins/data_formats/mvtec/exporter.py
Lines 88 to 95 in 064a314
mask = np.zeros((*item.media.size,), dtype=np.uint8) | |
for bbox in bboxes: | |
x, y, h, w = bbox.get_bbox() | |
mask = cv2.rectangle(mask, (x, y), (x + w, y + h), (1), -1) | |
if not osp.exists(osp.join(self._save_dir, osp.dirname(mask_path))): | |
os.mkdir(osp.join(self._save_dir, osp.dirname(mask_path))) | |
cv2.imwrite(osp.join(self._save_dir, mask_path), mask) |
If MVTec should mandatorily have {0, 255} binary mask rather than {0, 1} one, I think it would be good to add a unit test for this.
@vinnamkim Thanks for the suggestion. I added the correction for the detection task type. I also added some unit tests to test this behaviour |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #835 +/- ##
=========================================
Coverage 78.47% 78.48%
=========================================
Files 191 196 +5
Lines 23911 24304 +393
Branches 4912 4946 +34
=========================================
+ Hits 18765 19075 +310
- Misses 4044 4127 +83
Partials 1102 1102
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Summary
This PR fixes two small bugs in the MVTec exporter:
_make_item_filename
as part of the item id. So the final path contained the defect type twice (bottle/test/broken_large/broken_large/000.png
instead ofbottle/test/broken_large/000.png
). This was fixed by not appending the defect type to the subdirectory.How to test
Checklist
develop
branchLicense
Feel free to contact the maintainers if that's a concern.