-
Notifications
You must be signed in to change notification settings - Fork 152
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 the consistency of pre-processing with yolov5 #293
Conversation
Codecov Report
@@ Coverage Diff @@
## main #293 +/- ##
==========================================
+ Coverage 94.01% 94.92% +0.91%
==========================================
Files 11 11
Lines 718 729 +11
==========================================
+ Hits 675 692 +17
+ Misses 43 37 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
147afb2
to
c557fec
Compare
fe436f1
to
79a6e61
Compare
aug2 = out2[0].astype(np.float32) # uint8 to float32 | ||
aug2 = np.transpose(aug2 / 255.0, [2, 0, 1]) | ||
assert aug1.shape == aug2.shape | ||
np.testing.assert_allclose(aug1, aug2, rtol=1e-4, atol=1e-2) |
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.
PyTorch's interpolate operator now only aligns with OpenCV for the float type, and the letterbox
implemented by yolov5 operates on uint8
, so the precision we set here is relatively low.
Check pytorch/pytorch#5580 (comment) for more details.
Aligning the
YOLOTransform
with theletterbox
in yolov5.Fortunately, the interpolation operator of PyTorch is aligned with that of OpenCV for the float type, however, PyTorch's
interpolate
does not currently support integers type: pytorch/pytorch#5580 , a little loss of precision will occur here.https://github.com/zhiqwang/yolov5-rt-stack/blob/cd1a6ec7cda09de0dc92962a37ecb4f723a8dfeb/test/test_models_transform.py#L31-L53
Close #274 .