-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_pred.py
More file actions
31 lines (21 loc) · 786 Bytes
/
load_pred.py
File metadata and controls
31 lines (21 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2
import os
import numpy as np
def load_img(fileName):
path = os.getcwd()
path = os.path.join(path, fileName)
im_collection = []
with open(path) as f:
for im_path in f:
im_path = im_path.strip()
image = cv2.imread(im_path)
#
im_collection.append(image)
return np.array(im_collection)
def resize_im(im_collection, input_shape=(300, 300, 3)):
result = np.empty(shape=(0, input_shape[0], input_shape[1], input_shape[2]))
for im in im_collection:
image = cv2.resize(im, dsize=(input_shape[0],input_shape[1]))
image = np.expand_dims(image, axis=0)
result = np.append(result, image, axis=0)
return result