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

Update resize() to be on par with torchvision speed #144

Closed
wants to merge 17 commits into from

Conversation

membriux
Copy link
Contributor

@membriux membriux commented Nov 17, 2021

Summary

  • I have read CONTRIBUTING.md to understand how to contribute to this repository :)

Summary: Refactored resize() from image/functional.py to be on par with torchvision. However, I just have one minor failure in my code. Please advise on where I should look :)

Test results
The following results were acquired from my machine

  • Augly original (without interpolation)= 0.04475s
  • Augly revised (with interpolation) = 0.02873s
  • torchvision (uses interpolation) = 0.02696s

Test codehttps://colab.research.google.com/drive/14-KZdSGaOaz73OgIS0DZZY4RsS3cJ0rg#scrollTo=xVI_h-1v49lC

Unit Tests

If your changes touch the audio module, please run all of the audio tests and paste the output here. Likewise for image, text, & video. If your changes could affect behavior in multiple modules, please run the tests for all potentially affected modules. If you are unsure of which modules might be affected by your changes, please just run all the unit tests.


### Image
```bash
python -m unittest discover -s augly/tests/image_tests/ -p "*_test.py"
# Or `python -m unittest discover -s augly/tests/image_tests/ -p "*.py"` to run pytorch test too (must install `torchvision` to run)

TEST OUTPUT

======================================================================
FAIL: test_Resize (transforms_unit_test.TransformsImageUnitTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/macbookpro/Desktop/Github/AugLy/augly/tests/image_tests/transforms_unit_test.py", line 187, in test_Resize
    self.evaluate_class(imaugs.Resize(), fname="resize")
  File "/Users/macbookpro/Desktop/Github/AugLy/augly/tests/image_tests/base_unit_test.py", line 111, in evaluate_class
    self.assertTrue(
AssertionError: False is not true

----------------------------------------------------------------------
Ran 82 tests in 52.735s

FAILED (failures=1, skipped=5)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 17, 2021
@membriux membriux changed the title Update functional.py Update resize() to be on par with torchvision speed Nov 17, 2021
Copy link
Contributor

@zpapakipos zpapakipos left a comment

Choose a reason for hiding this comment

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

Thanks for this PR & for adding the speed stats, @membriux! Please fix the nits I added in the file comments. Also, a few things:

  • Note that this augmentation isn't always faster with this change; when an interpolation method is not passed in, the default one used was bicubic resampling, which is slower but also results in a higher-quality image than bilinear resampling, which you made the new default. So now the default behavior of resize will be faster than before, but the resuting image will be lower quality and if the user chooses to pass in resample=Image.BICUBIC then the behavior & runtime will be the same as before.
  • Because as I mentioned the resampling method is different from before & results in a lower-quality image, you need to regenerate the output image test_resize.png by running the new resize code.

augly/image/functional.py Outdated Show resolved Hide resolved
membriux and others added 5 commits November 18, 2021 09:16
Co-authored-by: Zoe Papakipos <zpapakipos@users.noreply.github.com>
Doesn't detect it as updated
Didn't detect it as updated file
Copy link
Contributor

@zpapakipos zpapakipos left a comment

Choose a reason for hiding this comment

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

Just a few more things to fix, then we can land this! :)

augly/image/functional.py Outdated Show resolved Hide resolved
@membriux
Copy link
Contributor Author

Use this for updating images on the test cases→
aug_function(self.local_img_path, output_path=f"/tmp/{aug_function.__name__}.png", **kwargs)

Updated metadata, transform, and unit test
Copy link
Contributor Author

@membriux membriux left a comment

Choose a reason for hiding this comment

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

Added!

@membriux membriux closed this Nov 23, 2021
@membriux membriux reopened this Nov 23, 2021
@membriux
Copy link
Contributor Author

@zpapakipos ready to go! 🚀

Copy link
Contributor

@zpapakipos zpapakipos left a comment

Choose a reason for hiding this comment

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

One last nit, then this is good to know!

augly/image/functional.py Outdated Show resolved Hide resolved
augly/image/transforms.py Outdated Show resolved Hide resolved
membriux and others added 2 commits November 24, 2021 13:20
Co-authored-by: Zoe Papakipos <zpapakipos@users.noreply.github.com>
Co-authored-by: Zoe Papakipos <zpapakipos@users.noreply.github.com>
@facebook-github-bot
Copy link
Contributor

@zpapakipos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@membriux has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@zpapakipos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

augly/image/functional.py Outdated Show resolved Hide resolved
augly/image/functional.py Outdated Show resolved Hide resolved
augly/image/transforms.py Outdated Show resolved Hide resolved
augly/image/transforms.py Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@membriux has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@membriux has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@membriux has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@membriux has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@zpapakipos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@zpapakipos zpapakipos left a comment

Choose a reason for hiding this comment

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

Just waiting for @jbitton to accept this diff internally so we can land!

Adib234 added a commit to Adib234/AugLy that referenced this pull request Dec 7, 2021
…-merge-video-audio

* 'main' of https://github.com/Adib234/AugLy:
  Update resize() to be on par with torchvision speed (facebookresearch#144)
  Change local image paths to links (facebookresearch#162)
  Text Augmentation Optimizations (facebookresearch#147)
  chore(typo) (facebookresearch#154)
  Downloads badge (facebookresearch#158)
  Add error messages for easier debugging (facebookresearch#151)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants