Beispiel #1
0
    # plt.savefig('../results/wrong_kitchen.png')
    # plt.show()

    # util.save_wordmap(wordmap, filename)
    # visual_recog.build_recognition_system(num_workers=6)

    # conf, accuracy = visual_recog.evaluate_recognition_system(num_workers=6)
    # print(conf)
    # print(accuracy)
    # wrong = np.load("../results/wrong_prediction.npy")
    # for item in wrong:
    #     file_path, actual, predict = item
    #     print(file_path, actual, predict)
    # if actual == 1 and predict == 7:
    #     print(file_path)

    # vgg16 = torchvision.models.vgg16(pretrained=True).double()
    # vgg16.eval()
    # print(list(vgg16.children()))
    vgg16_weights = util.get_VGG16_weights()
    # deep_recog.build_recognition_system(vgg16_weights, num_workers=6)
    # deep = np.load("../results/trained_system_deep.npz", allow_pickle=True)
    # print(deep['features'].shape)
    # print(deep['labels'].shape)
    conf, accuracy = deep_recog.evaluate_recognition_system(vgg16_weights,
                                                            num_workers=4)
    # conf = np.load("../results/conf_deep.npy")
    print(conf)
    print(accuracy)
    # print(np.trace(conf)/conf.sum())
if __name__ == '__main__':
    num_cores = util.get_num_CPU()

    path_img = "../data/kitchen/sun_aasmevtpkslccptd.jpg"
    image = skimage.io.imread(path_img)

    image = image.astype('float') / 255
    filter_responses = visual_words.extract_filter_responses(image)
    util.display_filter_responses(filter_responses)

    visual_words.compute_dictionary(num_workers=num_cores)

    dictionary = np.load('dictionary.npy')
    img = visual_words.get_visual_words(image, dictionary)
    #util.save_wordmap(wordmap, filename)
    visual_recog.build_recognition_system(num_workers=num_cores)

    conf, accuracy = visual_recog.evaluate_recognition_system(
        num_workers=num_cores)
    print(conf)
    print(np.diag(conf).sum() / conf.sum())

    vgg16 = torchvision.models.vgg16(pretrained=True).double()
    vgg16.eval()
    deep_recog.build_recognition_system(vgg16, num_workers=num_cores // 2)
    conf = deep_recog.evaluate_recognition_system(vgg16,
                                                  num_workers=num_cores // 2)
    print(conf)
    print(np.diag(conf).sum() / conf.sum())
#
Beispiel #3
0
if __name__ == '__main__':
    num_cores = util.get_num_CPU()

    path_img = "../data/kitchen/sun_aasmevtpkslccptd.jpg"
    image = skimage.io.imread(path_img)

    image = image.astype('float') / 255
    filter_responses = visual_words.extract_filter_responses(image)
    util.display_filter_responses(filter_responses)

    visual_words.compute_dictionary(num_workers=num_cores)

    dictionary = np.load('dictionary.npy')
    filename = "test.jpg"
    img = visual_words.get_visual_words(image, dictionary)
    util.save_wordmap(img, filename)
    visual_recog.build_recognition_system(num_workers=num_cores)

    conf, accuracy = visual_recog.evaluate_recognition_system(
        num_workers=num_cores)
    print(conf)
    print(np.diag(conf).sum() / conf.sum())

    vgg16 = torchvision.models.vgg16(pretrained=True).double()
    vgg16.eval()
    deep_recog.build_recognition_system(vgg16, num_workers=num_cores)
    conf, accuracy = deep_recog.evaluate_recognition_system(
        vgg16, num_workers=num_cores)
    print(conf)
    print(np.diag(conf).sum() / conf.sum())