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

TF change antialias to true #1348

Merged
merged 4 commits into from
Nov 20, 2023
Merged

Conversation

felixT2K
Copy link
Contributor

@felixT2K felixT2K commented Oct 12, 2023

This PR:

  • changes antialias also for TF to True

NOTE tests:

  • super minimal difference (< 1e-6) in the expected output (e.g.: 5.00001 instead of 5.0 / 1.00002 instead of 1.0) -
    I don't think there's much we can do about that (the results are correct and close to PT see below)

@felixT2K felixT2K changed the title [DRAFT] change antialias to true [DRAFT] TF change antialias to true Oct 12, 2023
@felixT2K
Copy link
Contributor Author

felixT2K commented Oct 13, 2023

10 x abs
pattern: {loading}_{framework}_{loading}_{framework}_diff.jpg

both with antialiasing:

opencv_tf_pil_tf_diff:  108826.1
opencv_torch_pil_torch_diff:  1859450
opencv_tf_opencv_torch_diff:  6922.742
pil_torch_pil_tf_diff:  7202.461

opencv_tf_pil_tf_diff
opencv_torch_pil_torch_diff
opencv_tf_opencv_torch_diff
pil_torch_pil_tf_diff

only pt with antialiasing:

opencv_tf_pil_tf_diff:  428563.7
opencv_torch_pil_torch_diff:  1859450
opencv_tf_opencv_torch_diff:  470293.66
pil_torch_pil_tf_diff:  183107.75

opencv_tf_pil_tf_diff
opencv_torch_pil_torch_diff
opencv_tf_opencv_torch_diff
pil_torch_pil_tf_diff

@felixT2K
Copy link
Contributor Author

felixT2K commented Oct 13, 2023

observation over 30 images:

straight pages: no visible changes
rotated pages: narrow text is detected somewhat less well (should be fixed if we do the next run with rotated augmentation - TF #1364 )

@charlesmindee @odulcy-mindee wdyt ?

failing test will be fixed by #1336

@felixdittrich92 felixdittrich92 added this to the 0.7.1 milestone Oct 16, 2023
@felixdittrich92 felixdittrich92 self-assigned this Oct 16, 2023
@felixdittrich92 felixdittrich92 added type: enhancement Improvement module: models Related to doctr.models ext: tests Related to tests folder framework: tensorflow Related to TensorFlow backend topic: text detection Related to the task of text detection labels Oct 16, 2023
@odulcy-mindee
Copy link
Collaborator

@felixdittrich92 I'm not sure to understand the benchmark. Why do you compare tf and torch with PIL and OpenCV ? Is there also antialiasing enabled by default in these frameworks when you downsize an image ?

@felixT2K
Copy link
Contributor Author

felixT2K commented Nov 17, 2023

@felixdittrich92 I'm not sure to understand the benchmark. Why do you compare tf and torch with PIL and OpenCV ? Is there also antialiasing enabled by default in these frameworks when you downsize an image ?

I compare the way how we load the image and the framwork which performs the resizing with and without antialising
After this PR we use in TF and PT antialias so the images are now much more close also for training runs

For more information: #402

Copy link

codecov bot commented Nov 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e645ead) 95.76% compared to head (d02c4fb) 95.77%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1348   +/-   ##
=======================================
  Coverage   95.76%   95.77%           
=======================================
  Files         155      155           
  Lines        6950     6951    +1     
=======================================
+ Hits         6656     6657    +1     
  Misses        294      294           
Flag Coverage Δ
unittests 95.77% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@felixT2K felixT2K marked this pull request as ready for review November 17, 2023 11:14
@felixT2K
Copy link
Contributor Author

felixT2K commented Nov 17, 2023

Add the end what we want is to work on the same images in both frameworks in the whole pipe inference and training
and with antialias it's the closest we can get atm (in pytorch we use antialising already since 0.7.0)

i have compared the "loading" libs and processing frameworks to see the difference :)

The black images shows the smallest diff which are:

opencv_tf_opencv_torch_diff:  6922.742
pil_torch_pil_tf_diff:  7202.461

both with antialias=True

@felixT2K felixT2K changed the title [DRAFT] TF change antialias to true TF change antialias to true Nov 17, 2023
Copy link
Collaborator

@odulcy-mindee odulcy-mindee left a comment

Choose a reason for hiding this comment

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

Thanks !

@felixdittrich92 felixdittrich92 merged commit 419ea05 into mindee:main Nov 20, 2023
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext: tests Related to tests folder framework: tensorflow Related to TensorFlow backend module: models Related to doctr.models topic: text detection Related to the task of text detection type: enhancement Improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[interpolation] Investigate difference in resizing/rotation between cv2, TF & Pytorch
3 participants