예제 #1
0
    def __init__(self, isTrain = False, isTest = False, isClassify = False):
        
        ## Mode
        logic = isTrain + isTest + isClassify
        if logic == 0:
            isClassify = True # Default
        elif logic > 1:
            print 'Warning! Must select either training mode or classifying mode'
        
        if isTrain:
            print 'Training Mode'
        elif isTest:
            print 'Testing Mode'
        elif isClassify:
            print 'Classifying Mode'
            
        self.isTrain = isTrain
        self.isTest = isTest
        self.isClassify = isClassify
        self.validImageFormat = ['jpg', 'tif', 'bmp', 'png', 'tiff']
        
        #Threshold
        self.thresholds = {'splitThres': 0.999, 'varThres': 3, 'var2Thres': 100}

        ## Dismantler
        ##### Split #####
        self.isPreClassified = False
        
        ## SVM Classifier Parameter
        ##### Training #####
#         self.tuned_parameters = [{'kernel': ['rbf'], 'gamma': [0, 1e-3, 1e-4], 'C': [1, 10]},]
        self.tuned_parameters = [{'kernel': ['rbf'], 'gamma': [0, 1e-3, 1e-4], 'C': [1]},]
#         self.tuned_parameters = [{'kernel': ['rbf', 'linear', 'poly'], 'gamma': [1e-3, 1e-4], 'C': [1, 10, 100, 1000]},]
        self.classNames = ['standalone', 'auxiliary']
        
        
        if self.isTrain:
            ## New Model Name
            self.modelName = 'dismantler_matsplit_matsvm_ceil'
            ## Corpus Path
            self.trainCorpusPath = "/Users/sephon/Desktop/Research/VizioMetrics/Dismantler/Corpus/train_corpus"
#             self.trainCorpusPath = '/home/ec2-user/VizioMetrics/Corpus/Dismantler/train_corpus/ee_cat1_multi_subimages'
            ## Model Saving Path
            self.modelSavingPath = "/Users/sephon/Desktop/Research/VizioMetrics/Model/Dismantler"
#             self.modelSavingPath = '/home/ec2-user/VizioMetrics/Model/Dismantler'
            ## New Model Path
            self.modelPath = Common.getModelPath(self.modelSavingPath, self.modelName)   
        
        ##### Classifying #####
        if self.isClassify:
            ## Model ID
            self.modelName = 'dismantler_matsplit_matsvm_ceil2015-10-01'
            ## Model Saving Path
            self.modelSavingPath = '/Users/sephon/Desktop/Research/VizioMetrics/Model/Dismantler'
#             self.modelSavingPath = '/home/ec2-user/VizioMetrics/Model/Dismantler'
            ## Default Dictionary Path
            self.dicPath = os.path.join(self.modelSavingPath, self.modelName)
            ## Default SVM Model Path
            self.svmModelPath = os.path.join(self.modelSavingPath, self.modelName)
            
            
        print 'Options set!\n'
예제 #2
0
    def __init__(self, isTrain = False, isTest = False, isClassify = False):
        
        ## Mode
        logic = isTrain + isTest + isClassify
        if logic == 0:
            isClassify = True # Default
        elif logic > 1:
            print 'Warning! Must select either training mode or classifying mode'
        
        if isTrain:
            print 'Training Mode'
        elif isTest:
            print 'Testing Mode'
        elif isClassify:
            print 'Classifying Mode'
            
        self.isTrain = isTrain
        self.isTest = isTest
        self.isClassify = isClassify
        self.validImageFormat = ['jpg', 'tif', 'bmp', 'png', 'tiff']
        self.classNames = ['single', 'composite']
        self.classNames = sorted(self.classNames)
        self.classIDs = range(1, len(self.classNames)+1)        # Start from 1
        self.classInfo = dict(zip(self.classNames, self.classIDs))
        
        if self.isTrain or self.isClassify:
            print 'Warning! Must select either training mode or classifying mode'
        
        ## Descriptor Parameter
        # Size Normalization
        self.offset_dim = (512, 581)
        
        # Firelane approach
        self.num_cut = 12
        self.thresholds = {'splitThres': 0.999, 'varThres': 3, 'var2Thres': 100}
        
        # Firelane map approach
        self.division = (10, 10)

        ## Classifiers
        self.availableClassifiers = ['SVM', 'CNN']
        self.activatedClassifiers = 'SVM'
        self.tuned_parameters = [{'kernel': ['rbf', 'linear', 'poly'], 'gamma': [0, 1e-3, 1e-4], 'C': [1, 10, 100, 1000]},]        
        
        ##### Training #####
        if self.isTrain:
            ## New Model Name
            self.modelName = 'nClass_%d_' % len(self.classNames)
            ## Corpus Path
            self.trainCorpusPath = "/Users/sephon/Desktop/Research/VizioMetrics/Corpus/Dismantler/ee_cat1_multi_subimages"
#             self.trainCorpusPath = "/home/ec2-user/VizioMetrics/Corpus/Dismantler/ee_cat1_multi_subimages"
            ## Model Saving Path
            self.modelSavingPath = "/Users/sephon/Desktop/Research/VizioMetrics/Model/Dismantler"
#             self.modelSavingPath = "/home/ec2-user/VizioMetrics/Model/Dismantler"
            ## New Model Path
            self.modelPath = Common.getModelPath(self.modelSavingPath, self.modelName)
        
        
        ##### Classifying #####
        if self.isClassify:
            ## Model ID
#             self.modelName = 'nClass_6_2014-10-30'
            self.modelName = 'composite_detector_firelanemap'
            ## Model Saving Path
            self.modelSavingPath = '/Users/sephon/Desktop/Research/VizioMetrics/Model/Dismantler'
#             self.modelSavingPath = '/home/ec2-user/VizioMetrics/Model/Classifier'
            ## Default SVM Model Path
            self.modelPath = os.path.join(self.modelSavingPath, self.modelName)
            
        print 'Options set!\n'
    def __init__(self, isTrain = False, isTest = False, isClassify = False):
        
        ## Mode
        logic = isTrain + isTest + isClassify
        if logic == 0:
            isClassify = True # Default
        elif logic > 1:
            print 'Warning! Must select either training mode or classifying mode'
        
        if isTrain:
            print 'Training Mode'
        elif isTest:
            print 'Testing Mode'
        elif isClassify:
            print 'Classifying Mode'
            
        self.isTrain = isTrain
        self.isTest = isTest
        self.isClassify = isClassify
        
        if self.isTrain or self.isClassify:
            print 'Warning! Must select either training mode or classifying mode'
        
        ## Classifiers
        self.availableClassifiers = ['SVM', 'CNN']
        self.activatedClassifiers = 'SVM'

        ## S3 Data Read Parameter
        self.keyPath = '/Users/sephon/Desktop/Research/VizioMetrics/keys.txt'
#         self.keyPath = '/home/ec2-user/VizioMetrics/keys.txt'
        self.host = 'escience.washington.edu.viziometrics'

        ## Data Read Parameter
        self.finalDim = [32, 32, 1]    # Final image dimensions
#         self.Ntrain = 1                  #/ Number of training images per category
#         self.Ntest = 1                   #/ Number of test images per category
        self.validImageFormat = ['jpg', 'tif', 'bmp', 'png', 'tiff']    # Valid image formats
        self.classNames = self.getTextDirNames(1,40)
#         self.classNames = ['bar', 'boxplot', 'heatmap', 'line', 'pie', 'scatter']
        self.classNames = sorted(self.classNames)
        self.classIDs = range(1, len(self.classNames)+1)        # Start from 1
        self.classInfo = dict(zip(self.classNames, self.classIDs))
        
        
        ## Dictionary Parameter
        self.Npatches = 200000;             # Number of patches
        self.Ncentroids = 40;              # Number of centroids
        self.rfSize = 8;                    # Receptor Field Size (i.e. Patch Size)
        self.kmeansIterations = 100         # Iterations for kmeans centroid computation
        self.whitening = True               # Whether to use whitening
        self.normContrast = True            # Whether to normalize patches for contrast
        self.minibatch = True              # Use minibatch to train SVM 
        self.MIN_PATCH_VAR = float(38)/255  # Minimum Patch Variance for accepting as potential centroid (empirically set to about 25% quartile of var)
        self.MAX_TRY = 30                   # Maximum number of try to find a qualify patch from an image
        self.kmeansIterations = 50
        
        ## SVM Classifier Parameter
        
        
        ##### Training #####
        if self.isTrain:
            ## New Model Name
            self.modelName = 'nClass_%d_' % len(self.classNames)
            ## Corpus Path
            self.trainCorpusPath = "/Users/sephon/Desktop/Research/VizioMetrics/Corpus/TextRecognizer/English/Fnt"
#             self.trainCorpusPath = "/home/ec2-user/VizioMetrics/Corpus/TextRecognizer/English/Fnt"
            ## Model Saving Path
            self.modelSavingPath = "/Users/sephon/Desktop/Research/VizioMetrics/Model/TextRecognizer"
#             self.modelSavingPath = "/home/ec2-user/VizioMetrics/Model/TextRecognizer"
            ## New Model Path
            self.modelPath = Common.getModelPath(self.modelSavingPath, self.modelName)
        
        ##### Testing ######
        if self.isTest:
            ## Model ID
            self.modelName = 'nClass_7_2014-10-19_4cat'
            ## Model Saving Path
            self.modelSavingPath = '/Users/sephon/Desktop/Research/VizioMetrics/Model'
#             self.modelSavingPath = '/home/ec2-user/VizioMetrics/Model'
            ## Corpus Path
            self.testCorpusPath = "/Users/sephon/Desktop/Research/VizioMetrics/Corpus/VizSet_pm_ee_cat014_test"
#             self.testCorpusPath = "/home/ec2-user/VizioMetrics/Corpus/VizSet_pm_ee_cat014_test"
            ## Result Directory
            self.resultSavingPath = '/Users/sephon/Desktop/Research/VizioMetrics/class_result'
#             self.resultSavingPath = '/home/ec2-user/VizioMetrics/class_result'
            ## Default Dictionary Path
            self.dicPath = os.path.join(self.modelSavingPath, self.modelName)
            ## Default SVM Model Path
            self.svmModelPath = os.path.join(self.modelSavingPath, self.modelName)
            ## Assign new folder as result directory
            self.resultPath  = Common.getModelPath(self.resultSavingPath, '')

        
        
        ##### Classifying #####
        if self.isClassify:
            ## Model ID
#             self.modelName = 'nClass_6_2014-10-30'
            self.modelName = 'nClass_7_2014-10-19_4cat'
            ## Model Saving Path
            self.modelSavingPath = '/Users/sephon/Desktop/Research/VizioMetrics/Model/TextRecognizer'
#             self.modelSavingPath = '/home/ec2-user/VizioMetrics/Model'
            ## Corpus Path
            self.classifyCorpusPath = '/Users/sephon/Desktop/Research/VizioMetrics/Corpus/sketchCorpus'
#             self.classifyCorpusPath = "/home/ec2-user/VizioMetrics/Corpus/VizSet_pm_ee_cat014_test"
            ## Result Directory
            self.resultSavingPath = '/Users/sephon/Desktop/Research/VizioMetrics/class_result'
#             self.resultSavingPath = '/home/ec2-user/VizioMetrics/class_result'
            ## Default Dictionary Path
            self.dicPath = os.path.join(self.modelSavingPath, self.modelName)
            ## Default SVM Model Path
            self.svmModelPath = os.path.join(self.modelSavingPath, self.modelName)
            ## Assign new folder as result directory
            self.resultPath  = Common.getModelPath(self.resultSavingPath, '')
            
        print 'Options set!\n'