예제 #1
0
def load_test(data_file_names):
    # load test data
    masks_path = '/media/stim-scratch/berisha/00-annotations/hd/right/com-right/'

    classimages = sorted(glob.glob(masks_path +
                                   '*.png'))  # load the class file names
    C = classify.filenames2class(
        classimages)  # generate the class images for testing
    C = C.astype(np.uint32)

    bool_mask = np.sum(C.astype(np.uint32), 0)

    # get number of classes
    num_classes = C.shape[0]

    for i in range(1, num_classes):
        C[i, :, :] *= i + 1

    total_mask = np.sum(C.astype(np.uint32), 0)  # validation mask

    Etest = envi.envi(data_file_names[0], mask=total_mask)

    N = np.count_nonzero(total_mask)  # set the batch size
    Tv = []  # initialize the target array to empty
    x_test = Etest.loadbatch(N)
    y_test = total_mask.flat[np.flatnonzero(
        total_mask)]  # get the indices of valid pixels

    Etest.close()

    return x_test, y_test
예제 #2
0
def load_train(data_file_names):
    # load train data
    masks_path = '/media/stim-scratch/berisha/00-annotations/hd/left/com-left/'

    classimages = sorted(glob.glob(masks_path +
                                   '*.png'))  # load the class file names
    C = classify.filenames2class(
        classimages)  # generate the class images for training

    # open the ENVI file for reading, use the validation image for batch access
    Etrain = envi.envi(data_file_names[0])
    # x_train, y_train = Etrain.loadtrain(C)
    x_train, y_train = Etrain.loadtrain_balance(C, num_samples=100000)
    Etrain.close()

    return x_train, y_train
예제 #3
0
파일: svm-sd.py 프로젝트: seberisha/cnn-hsi
=====================
Optimal params comparison
=====================

A comparison of several classifiers using ('optimal' params) from scikit-learn on FTIR data.

Code source: Sebastian Berisha
"""

# load train data
data_path = '/media/stim-processed/berisha/breast-processing/lm/br1003/no-mnf/new-cnn/'
masks_path = '/media/stim-processed/berisha/breast-processing/lm/br1003/masks/no-mnf-bcemn/'

classimages = sorted(glob.glob(masks_path +
                               '*.png'))  # load the class file names
C = classify.filenames2class(
    classimages)  # generate the class images for training

# open the ENVI file for reading, use the validation image for batch access
Etrain = envi.envi(data_path + 'br1003-br2085b-bas-nor-fin-bip-pca16')
#x_train, y_train = Etrain.loadtrain(C)
x_train, y_train = Etrain.loadtrain_balance(C, num_samples=60000)
Etrain.close()

# load test data
data_path = '/media/stim-processed/berisha/breast-processing/lm/br1003/no-mnf/brc961-proj/brc961-proj/new-cnn/'
masks_path = '/media/stim-processed/berisha/breast-processing/lm/brc961/masks/no-mnf-bcemn/'

classimages = sorted(glob.glob(masks_path +
                               '*.png'))  # load the class file names
C = classify.filenames2class(
    classimages)  # generate the class images for testing