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

Add return object when creating h5py dataset to check integrity #736

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: 11 additions & 3 deletions tflearn/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ class containing the images to classify.
assert mode in ['folder', 'file'], "`mode` arg must be 'folder' or 'file'"

if mode == 'folder':
images, labels = directory_to_samples(target_path,
flags=files_extension)
images, labels, classes = directory_to_samples(target_path,
flags=files_extension)
else:
with open(target_path, 'r') as f:
images, labels = [], []
Expand Down Expand Up @@ -416,6 +416,9 @@ class containing the images to classify.
else:
dataset['Y'][i] = labels[i]

return H5pyDataset(classes, image_shape, image_count)


def get_img_channel(image_path):
"""
Load a image and return the channel of the image
Expand Down Expand Up @@ -744,7 +747,7 @@ def directory_to_samples(directory, flags=None, filter_channel=False):
samples.append(os.path.join(c_dir, sample))
targets.append(label)
label += 1
return samples, targets
return samples, targets, classes


# ==================
Expand Down Expand Up @@ -843,6 +846,11 @@ def preload(self, label, n_class, categorical_label):
else:
return label

class H5pyDataset(object):
def __init__(self, classes, image_shape, image_count):
self.classes = classes
self.image_shape = image_shape
self.image_count = image_count

def get_max(X):
return np.max(X)
Expand Down