forked from hhsecond/HandsOnDeepLearningWithPytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
23 lines (18 loc) · 719 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Utils has the utilites I have used outside the models
import os
from scipy import misc
import numpy as np
def balckandwhite_pedestrians(img_path):
img = misc.imread(img_path)
pedestrian_rgb = np.array([64, 64, 0]).reshape(1, 1, 3)
out = np.all(img == pedestrian_rgb, 2)
print(out.shape)
misc.imsave(img_path, out)
if __name__ == '__main__':
counter = 0
path = '/home/hhsecond/mypro/ThePyTorchBook/HandsOnDeepLearningWithPytorch/camvid/'
for folder in os.listdir(path):
for image in os.listdir(os.path.join(path, folder, 'labels')):
counter += 1
img_path = os.path.join(path, folder, 'labels', image)
balckandwhite_pedestrians(img_path)