Exemple #1
0
def create_labels(count, hog_list, total_data, batch_size):

    #labels are one-hot vectors. But 0 is replaced with -1
    point = count
    path = hog_list[count][0]
    lab = hog_list[count][1]
    y = np.zeros([1, num_classes])
    y[0][lab] = 1

    x = hog.read_hog_file(path)
    x = np.expand_dims(x, axis=0)

    count += 1
    extra = np.min([batch_size, total_data - point])

    while count < point + extra and count < total_data:
        path = hog_list[count][0]
        lab = hog_list[count][1]

        y_new = np.zeros([1, num_classes])
        y_new[0][lab] = 1
        y = np.concatenate((y, y_new), axis=0)

        x_new = hog.read_hog_file(path)
        x_new = np.expand_dims(x_new, axis=0)
        x = np.concatenate((x, x_new), axis=0)

        count += 1

    return x, y
Exemple #2
0
def create_svm_labels(count, hog_list, total_data, batch_size, class_num, key):
    point = count
    path = hog_list[count][0]
    lab = hog_list[count][1]

    y = np.array([[key]])
    if lab == class_num:
        y[0][0] = 1

    x = hog.read_hog_file(path)
    x = np.expand_dims(x, axis=0)

    count += 1
    extra = np.min([batch_size, total_data - point])

    while count < point + extra and count < total_data:
        path = hog_list[count][0]
        lab = hog_list[count][1]

        y_new = np.array([[key]])
        if lab == class_num:
            y_new[0][0] = 1

        y = np.concatenate((y, y_new), axis=0)

        x_new = hog.read_hog_file(path)
        x_new = np.expand_dims(x_new, axis=0)
        x = np.concatenate((x, x_new), axis=0)

        count += 1

    return x, y
def create_labels(count, hog_list, total_data, batch_size):

    point = count
    path = hog_list[count][0]
    lab = hog_list[count][1]
    y = np.zeros([1, num_classes])
    y[0][lab] = 1

    #print("Extracting HOG features from image...."+str(len(train_list)-count-1)+' more images left.....')
    x = hog.read_hog_file(path)
    x = np.expand_dims(x, axis=0)

    count += 1
    extra = np.min([batch_size, total_data - point])

    while count < point + extra and count < total_data:
        path = hog_list[count][0]
        lab = hog_list[count][1]

        y_new = np.zeros([1, num_classes])
        y_new[0][lab] = 1
        y = np.concatenate((y, y_new), axis=0)

        #print("Extracting HOG features from image...."+str(len(train_list)-count-1)+' more images left.....')
        x_new = hog.read_hog_file(path)
        x_new = np.expand_dims(x_new, axis=0)
        x = np.concatenate((x, x_new), axis=0)

        count += 1

    return x, y