-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_resizer.py
32 lines (24 loc) · 977 Bytes
/
image_resizer.py
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
32
## image_resizer.py
# Importing required libraries
import os
import numpy as np
from PIL import Image
# Defining an image size and image channel
# We are going to resize all our images to 128X128 size and since our images are colored images
# We are setting our image channels to 3 (RGB)
IMAGE_SIZE = 256
IMAGE_CHANNELS = 3
IMAGE_DIR = 'DATA/Images_Coupees_V2/'
# Defining image dir path. Change this if you have different directory
images_path = IMAGE_DIR
training_data = []
# Iterating over the images inside the directory and resizing them using
# Pillow's resize method.
for filename in os.listdir(images_path):
path = os.path.join(images_path, filename)
image = Image.open(path)
training_data.append(np.asarray(image))
#training_data = np.reshape(training_data, (-1, IMAGE_SIZE, IMAGE_SIZE, IMAGE_CHANNELS))
#training_data = training_data / 255.5 - 1
print('saving file...')
np.save('sillureV3_data.npy', training_data)