예제 #1
0
    createSegments = False
    if len(sys.argv) == 2:
        createSegments = True

    ### Directories
    segmentDir = 'tmp/segments/'
    featureDir = 'tmp/features/'
    trainDir = featureDir + 'train/'

    ### First segment the training images
    if createSegments:
        logging.info("Creating segments of the images")
        create_segments.create_seg()

    ### Run hog over the segmented images
    ### Third argument for type of hog ("xeryus" or "other"), default = "xeryus"
    logging.info("Doing the HOG")
    doHog(segmentDir, featureDir)

    ### Create random train and test sets from the hog features
    # logging.info("Creating train and test set")
    create_sets(featureDir)

    ### Receive trained kNN (it also tests it on characters)
    logging.info("Running kNN")
    k = 10
    kNN = runKNN(trainDir, k)
    with open('tmp/knn.pickle', 'w') as f:
        pickle.dump(kNN, f)
예제 #2
0
import create_segments
import sys
import logging

### Own modules
from general.hog import doHog
from general.pca import runPCA
from general.create_sets import create_sets
from train.svm import runSVM
from train.knn import runKNN

segmentDir = 'tmp/segments/'
featureDir = 'tmp/features/'
trainDir = featureDir + 'train/'
testDir = featureDir + 'test/'

for k in range(19):
    k += 1
    avgAcc = 0.0
    for i in range(10):
        print "hog"
        doHog(segmentDir, featureDir, "xeryus")
        print "create sets"
        create_sets(featureDir)
        print "knn"
        kNN, accuracy = runKNN(trainDir, testDir, k, "hog")

        avgAcc += accuracy
    print "Average accuracy for k =", k, ":\t", avgAcc/10
    avgAcc = 0
예제 #3
0
import create_segments
import sys
import logging

### Own modules
from general.hog import doHog
from general.pca import runPCA
from general.create_sets import create_sets
from train.svm import runSVM
from train.knn import runKNN

segmentDir = 'tmp/segments/'
featureDir = 'tmp/features/'
trainDir = featureDir + 'train/'
testDir = featureDir + 'test/'

for k in range(19):
    k += 1
    avgAcc = 0.0
    for i in range(10):
        print "hog"
        doHog(segmentDir, featureDir, "xeryus")
        print "create sets"
        create_sets(featureDir)
        print "knn"
        kNN, accuracy = runKNN(trainDir, testDir, k, "hog")

        avgAcc += accuracy
    print "Average accuracy for k =", k, ":\t", avgAcc / 10
    avgAcc = 0