forked from EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resizer.py
21 lines (16 loc) · 726 Bytes
/
resizer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
## Bulk image resizer
# This script simply resizes all the images in a folder to one-eigth their
# original size. It's useful for shrinking large cell phone pictures down
# to a size that's more manageable for model training.
# Usage: place this script in a folder of images you want to shrink,
# and then run it.
import numpy as np
import cv2
import os
dir_path = os.getcwd()
for filename in os.listdir(dir_path):
# If the images are not .JPG images, change the line below to match the image type.
if filename.endswith(".JPG"):
image = cv2.imread(filename)
resized = cv2.resize(image,None,fx=0.25, fy=0.25, interpolation=cv2.INTER_AREA)
cv2.imwrite(filename,resized)