Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrading from scipy image functions (deprecated) to scikit-learn #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import subprocess

import numpy as np
from scipy.misc import imresize
from scipy.misc import imrotate
from scipy.ndimage import imread
from skimage.transform import resize
from skimage.transform import rotate
from skimage.color import rgb2gray
from imageio import imread
import tensorflow as tf


Expand Down Expand Up @@ -34,12 +35,12 @@ def crawl_directory(directory, augment_with_rotations=False, first_label=0):

for file_name in files:
full_file_name = os.path.join(root, file_name)
img = imread(full_file_name, flatten=True)
img = rgb2gray(imread(full_file_name))
for idx, angle in enumerate([0, 90, 180, 270]):
if not augment_with_rotations and idx > 0:
break

images.append(imrotate(img, angle))
images.append(rotate(img, angle))
labels.append(label_idx + idx)
info.append(full_file_name)

Expand All @@ -53,9 +54,8 @@ def resize_images(images, new_width, new_height):
resized_images = np.zeros([images.shape[0], new_width, new_height], dtype=np.float32)

for idx in range(images.shape[0]):
resized_images[idx, :, :] = imresize(images[idx, :, :],
resized_images[idx, :, :] = resize(images[idx, :, :],
[new_width, new_height],
interp='bilinear',
mode=None)
return resized_images

Expand Down