Пример #1
0
def loadSvmModel(modelParams, dataType, setID, repeat, size, X_train, y_train):
    modelFn = modelParams['modelFn']
    if modelFn is not None:
        model = pickle.load(open(modelFn, "rb"))
    else:
        model = train_SVM(X_train, y_train)
        fn = iconicImagesFileFormat().format("model{}_svm_{}_{}_{}.pkl".format(
            dataType, setID, repeat, size))
        pickle.dump(model, open(fn, "wb"))
        print(" saved model to {}".format(fn))

    print("\n\n-=- model loaded -=-\n\n")
    return model
Пример #2
0
                           transform=None)

    print('this is the annocount', annoCount)

    l_feat,l_idx,y = extract_pyroidb_features(pyroidb, 'hog', clsToSet, calc_feat = False, \
                                              spatial_size=(32, 32),hist_bins=32, \
                                              orient=9, pix_per_cell=8, cell_per_block=2, \
                                              hog_channel=0)

    X_train, X_test, y_train, y_test, X_idx = split_data(train_size, test_size, \
                                                         l_feat,l_idx, y,\
                                                         clsToSet)
    print(X_train.shape)
    print(y_train.shape)
    X_train, X_test = scale_data(X_train, X_test)
    model = train_SVM(X_train, y_train)
    print("accuracy on test data {}".format(model.score(X_test, y_test)))

    path_to_save = osp.join(cfg.PATH_TO_NTD_OUTPUT,
                            'Mat1_' + setID + '_' + repeat + '_' + str(size))

    cm_cropped = make_confusion_matrix(model, X_test, y_test, clsToSet,
                                       path_to_save)

    #raw image input

    pyroidb = RoidbDataset(roidb, [0, 1, 2, 3, 4, 5, 6, 7],
                           loader=roidbSampleImage,
                           transform=None)

    print('this is the annocount', annoCount)