Created
July 19, 2020 08:30
-
-
Save neelriyer/fe661783ff3c8c222bd085ef03a2bb5e to your computer and use it in GitHub Desktop.
detectron2 web app low memory image transforms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import PIL | |
| from PIL import Image | |
| # adapted from: https://github.com/jantic/DeOldify/blob/master/deoldify/filters.py | |
| def _scale_to_square(orig, targ): | |
| targ_sz = (targ, targ) | |
| return orig.resize(targ_sz, resample=PIL.Image.BILINEAR) | |
| def _unsquare(image, orig): | |
| targ_sz = orig.size | |
| image = image.resize(targ_sz, resample=PIL.Image.BILINEAR) | |
| return images |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment