/**Predict data from 'data_file' using model from 'model_file' and save predictions to 'prediction_file' */ void PredictData(const string& data_file, const string& model_file, const string& prediction_file, bool sse_on) { // List of image file names and its labels TFileList file_list; // Structure of images and its labels TDataSet data_set; // Structure of features of images and its labels TFeatures features; // List of image labels TLabels labels; // Load list of image file names and its labels LoadFileList(data_file, &file_list); // Load images LoadImages(file_list, &data_set); // Extract features from images ExtractFeatures(data_set, &features, sse_on); // Classifier TClassifier classifier = TClassifier(TClassifierParams()); // Trained model TModel model; // Load model from file model.Load(model_file); // Predict images by its features using 'model' and store predictions // to 'labels' classifier.Predict(features, model, &labels); // Save predictions SavePredictions(file_list, labels, prediction_file); // Clear dataset structure ClearDataset(&data_set); }
HOGFeatureClassifier::TModel OptimizeThresholdsInModel(const string &images_list, const string& model_file, RecognitionStatistics &stat) { TModel model; model.Load(model_file); float model_threshold = ImageRecognition::FindOptimalThresholdForModel(images_list, model, stat); model.setModelThreshold(model_threshold); model.Save(model_file); return model; }
void ResponseImage(vector<ImageRecognition::SlidingRect> &rects, const Mat &image, const string &model_filename, RecognitionStatistics &stat) { TModel model; model.Load(model_filename); ResponseImage(rects, image, model, stat); }