Last active
October 14, 2020 08:45
-
-
Save sharkdeng/d3bb488a3d224f0788f66b961a33c9c1 to your computer and use it in GitHub Desktop.
use multiprocessing to speed up
This file contains 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
# you have run this code in .py file (cannot be in .ipynb) | |
# you have to add the head `if __name__ == '__main__':` | |
if __name__ == '__main__': | |
start = time.time() | |
img_ids = df.image_id.values # a list | |
pool = Pool(processes=multiprocessing.cpu_count()) | |
pool.map(crop_all_img, img_ids) # (function, list) | |
delta = time.time() - start | |
print(f'Used time: {delta}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment