from lmdbWriter import open_csv import numpy as np labels_dict = open_csv('../data/trainLabels.csv') keys = [] for key in labels_dict.keys(): s = key.split('_') keys.append(s[0]) keys = list(set(keys)) for key in keys: if labels_dict[ key + '_right'] > labels_dict[ key + '_left']: labels_dict[key + '_left'] = labels_dict[key + '_right'] elif labels_dict[key + '_left'] > labels_dict[ key + '_right']: labels_dict[key + '_right'] = labels_dict[key + '_left'] trainY = np.zeros((len(labels_dict.keys()), 1)) for i, key in enumerate(labels_dict.keys()): trainY[i, 0] = labels_dict[key] np.save('trainY_corrected.npy', trainY)
import sys from caffe.io import load_image from skimage.util import view_as_windows import os import numpy as np from kMeansFeatureExtractor import * from lmdbWriter import open_csv imageDim = (512, 512, 3) rfSize = 16 numPatches = 50 images = os.listdir('../data/resized/trainOriginal') labels_dict = open_csv('../data/trainLabels.csv') values = labels_dict.values() total_numPatches = values.count(0) * 40 + (values.count(1) + values.count(2) + values.count(3) + values.count(4)) * 140 patches = np.zeros((total_numPatches, rfSize * rfSize * 3)) whitening = True maxIter = 50 batchSize = 1000 j = 0 values = labels_dict.values() for each in images: if labels_dict[each.split('.')[0]] > 0: numPatches = 140 else:
import numpy as np from lmdbWriter import open_csv import matplotlib.image as mpimg import os labels = open_csv('../data/trainLabels.csv') values = np.array(labels.values()) data = [] for i in range(0,5): data.append(np.zeros((values[values == i].shape[0], 512*512))) print len(data) class_counters = [0]*5 i = 0 for each in os.listdir('../data/resized/trainOriginal/'): if each.split('.jpeg')[0] in labels.keys(): if values[i] > 0: class_counters[values[i]] += 1 i += 1 print class_counters continue data[values[i]][class_counters[values[i]], :] = mpimg.imread('../data/resized/train512/' + each)[:,:,2].flatten() class_counters[values[i]] += 1 i += 1 print class_counters np.save('separated_data/class_0.npy', data[0])