Ejemplo n.º 1
0
 void SoftCascadeLearner::classify(const nor_utils::Args& args)
 {
     SoftCascadeClassifier classifier(args, _verbose);
             
     string testFileName = args.getValue<string>("test", 0);
     string shypFileName = args.getValue<string>("test", 1);
     int numIterations = args.getValue<int>("test", 2);
             
     string outResFileName = "";
     if ( args.getNumValues("test") > 3 )
         args.getValue("test", 3, outResFileName);
             
     classifier.run(testFileName, shypFileName, numIterations, outResFileName);
 }
Ejemplo n.º 2
0
	void FilterBoostLearner::classify(const nor_utils::Args& args)
	{
		FilterBoostClassifier classifier(args, _verbose);

		// -test <dataFile> <shypFile>
		string testFileName = args.getValue<string>("test", 0);
		string shypFileName = args.getValue<string>("test", 1);
		int numIterations = args.getValue<int>("test", 2);

		string outResFileName;
		if ( args.getNumValues("test") > 3 )
			args.getValue("test", 3, outResFileName);

		classifier.run(testFileName, shypFileName, numIterations, outResFileName);
	}
Ejemplo n.º 3
0
	void AdaBoostMHLearner::doPosteriors(const nor_utils::Args& args)
	{
		AdaBoostMHClassifier classifier(args, _verbose);
		int numofargs = args.getNumValues( "posteriors" );
		// -posteriors <dataFile> <shypFile> <outFile> <numIters>
		string testFileName = args.getValue<string>("posteriors", 0);
		string shypFileName = args.getValue<string>("posteriors", 1);
		string outFileName = args.getValue<string>("posteriors", 2);
		int numIterations = args.getValue<int>("posteriors", 3);
		int period = 0;
		
		if ( numofargs == 5 )
			period = args.getValue<int>("posteriors", 4);
		
		classifier.savePosteriors(testFileName, shypFileName, outFileName, numIterations, period);
	}
Ejemplo n.º 4
0
    void SoftCascadeLearner::getArgs(const nor_utils::Args& args)
    {
        if ( args.hasArgument("verbose") )
            args.getValue("verbose", 0, _verbose);

        ///////////////////////////////////////////////////
        // get the output strong hypothesis file name, if given
        if ( args.hasArgument("shypname") )
            args.getValue("shypname", 0, _shypFileName);
        else
            _shypFileName = string(SHYP_NAME);

        _shypFileName = nor_utils::addAndCheckExtension(_shypFileName, SHYP_EXTENSION);


        ///////////////////////////////////////////////////

        //TODO : create an abstract classe for cascade compliant base learners and accept only its offspring!
        // get the name of the learner
        _baseLearnerName = defaultLearner;
        if ( args.hasArgument("learnertype") )
            args.getValue("learnertype", 0, _baseLearnerName);
//            cout << "! Only HaarSingleStumpeLearner is allowed.\n";
        
        // -train <dataFile> <nInterations>
        if ( args.hasArgument("train") )
        {
            args.getValue("train", 0, _trainFileName);
            args.getValue("train", 1, _numIterations);
        }
        // -traintest <trainingDataFile> <testDataFile> <nInterations>
        else if ( args.hasArgument("traintest") ) 
        {
            args.getValue("traintest", 0, _trainFileName);
            args.getValue("traintest", 1, _testFileName);
            args.getValue("traintest", 2, _numIterations);
        }

        // The file with the step-by-step information
        if ( args.hasArgument("outputinfo") )
            args.getValue("outputinfo", 0, _outputInfoFile);
        else
            _outputInfoFile = OUTPUT_NAME;
        
        // --constant: check constant learner in each iteration
        if ( args.hasArgument("constant") )
            _withConstantLearner = true;
        
        if ( args.hasArgument("positivelabel") )
        {
            args.getValue("positivelabel", 0, _positiveLabelName);
        } else {
            cout << "Error : The name of positive label must to given. \n Type --h softcascade to know the mandatory options." << endl;
            exit(-1);
        }
        
        if (args.hasArgument("trainposteriors")) {
            args.getValue("trainposteriors", 0, _trainPosteriorsFileName);
        }

        if (args.hasArgument("testposteriors")) {
            args.getValue("testposteriors", 0, _testPosteriorsFileName);
        }

        if (args.hasArgument("detectionrate")) {
            args.getValue("detectionrate", 0, _targetDetectionRate);
        }
        else {
            cout << "Error : the target detection rate must be given. \n Type --h softcascade to know the mandatory options.";
            exit(-1);
        }

        
        if (args.hasArgument("expalpha")) {
            args.getValue("expalpha", 0, _alphaExponentialParameter);
        }
        else {
            cout << "Error : the parameter used to initialize the rejection distribution vector must be given. \n Type --h softcascade to know the mandatory options.";
            exit(-1);
        }

        if (args.hasArgument("calibrate")) {
            args.getValue("calibrate", 0, _unCalibratedShypFileName);
            if (args.getNumValues("calibrate") > 1) {
                args.getValue("calibrate", 0, _inShypLimit);
            }
        }
        else {
            _fullRun = true;
            _unCalibratedShypFileName = "shypToBeCalibrated.xml";
            cout << "The strong hypothesis file will be seved into the file " << _unCalibratedShypFileName;
            //cout << "Error : the shyp file of the uncalibrated trained classifier must be given ! \n";
            //exit(-1);

        }
        
        if (args.hasArgument("bootstrap")) {
            cout << "Warning ! The bootstrapping set and the training set must come from the same superset. \n";
            args.getValue("bootstrap", 0, _bootstrapFileName);
            args.getValue("bootstrap", 1, _bootstrapRate);
        }
    }