Created
August 10, 2018 06:59
-
-
Save snk4tr/c499f1a0052deb6e6eb7990196067e4b to your computer and use it in GitHub Desktop.
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 functools | |
| import cv2 | |
| from skimage import io | |
| from PIL import Image | |
| def time_logger(func): | |
| @functools.wraps(func) | |
| def wrapped(*args, **kwargs): | |
| start = time.time() | |
| result = func(*args, **kwargs) | |
| finish = time.time() | |
| stage_time = time.strftime('%d.%m.%Y - %H:%M ') + "*** METHOD {} TOOK {} SECONDS! ***\n"\ | |
| .format(func.__qualname__, (finish - start)) | |
| print(stage_time) | |
| return result | |
| return wrapped | |
| ############ OpenCV ############ | |
| @time_logger | |
| def opencv(): | |
| imgs = [] | |
| for fname in x_tr_fnames: | |
| imgs.append(cv2.cvtColor(cv2.imread(fname), cv2.COLOR_BGR2RGB)) | |
| ############ SciMage ############ | |
| @time_logger | |
| def scimage(): | |
| imgs = [] | |
| for fname in x_tr_fnames: | |
| imgs.append(io.imread(fname)) | |
| ############ Pillow ############ | |
| @time_logger | |
| def pillow(): | |
| imgs = [] | |
| for fname in x_tr_fnames: | |
| imgs.append(np.array(Image.open(fname))) | |
| opencv() | |
| scimage() | |
| pillow() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1000 images results: