Lens AI Profiler Cpp
Public Member Functions | Public Attributes | List of all members
ImageSampler Class Reference

Class for selecting uncertain image samples for further analysis based on various confidence metrics. More...

#include <imagesampler.h>

Public Member Functions

 ImageSampler (const std::string &conf_path, int save_interval, const std::string &model_type)
 Constructor to initialize ImageSampler object with configuration file path. More...
 
int sample (const void *raw_output, cv::Mat &img, bool save_sample)
 Selects uncertain image samples based on configured criteria. More...
 
float margin_confidence (std::vector< float > &prob_dist, bool sorted)
 Calculates margin confidence (difference between top two probabilities) More...
 
float least_confidence (std::vector< float > &prob_dist, bool sorted)
 Calculates least confidence (normalized maximum probability) More...
 
float ratio_confidence (std::vector< float > &prob_dist, bool sorted)
 Calculates ratio confidence (ratio of top two probabilities) More...
 
float entropy_confidence (std::vector< float > &prob_dist)
 Calculates entropy-based confidence. More...
 

Public Attributes

std::string statSavepath
 
std::string dataSavepath
 

Detailed Description

Class for selecting uncertain image samples for further analysis based on various confidence metrics.

Class for selecting uncertain image samples for further analysis.

Constructor & Destructor Documentation

◆ ImageSampler()

ImageSampler::ImageSampler ( const std::string &  conf_path,
int  save_interval,
const std::string &  model_type 
)

Constructor to initialize ImageSampler object with configuration file path.

Constructor to initialize ImageSampler object.

Parameters
configFilePathPath to the configuration file
conf_pathPath to configuration file
saverSaver object for saving sampling statistics

Member Function Documentation

◆ entropy_confidence()

float ImageSampler::entropy_confidence ( std::vector< float > &  prob_dist)

Calculates entropy-based confidence.

Calculates entropy based confidence.

Parameters
probabilityDistributionVector of class probabilities
Returns
Entropy-based confidence score
Parameters
prob_distVector of class probabilities
sortedFlag indicating if probabilities are already sorted (default: false)
Returns
Entropy confidence score

◆ least_confidence()

float ImageSampler::least_confidence ( std::vector< float > &  prob_dist,
bool  sorted = false 
)

Calculates least confidence (normalized maximum probability)

Calculates least confidence.

Parameters
probabilityDistributionVector of class probabilities
sortedFlag indicating if probabilities are already sorted (default: false)
Returns
Least confidence score
Parameters
prob_distVector of class probabilities
sortedFlag indicating if probabilities are already sorted (default: false)
Returns
least confidence score

◆ margin_confidence()

float ImageSampler::margin_confidence ( std::vector< float > &  prob_dist,
bool  sorted = false 
)

Calculates margin confidence (difference between top two probabilities)

Parameters
probabilityDistributionVector of class probabilities
sortedFlag indicating if probabilities are already sorted (default: false)
Returns
Margin confidence score
Parameters
prob_distVector of class probabilities
sortedFlag indicating if probabilities are already sorted (default: false)
Returns
Margin confidence score

◆ ratio_confidence()

float ImageSampler::ratio_confidence ( std::vector< float > &  prob_dist,
bool  sorted = false 
)

Calculates ratio confidence (ratio of top two probabilities)

Calculates ratio confidence (difference between top two probabilities)

Parameters
probabilityDistributionVector of class probabilities
sortedFlag indicating if probabilities are already sorted (default: false)
Returns
Ratio confidence score
Parameters
prob_distVector of class probabilities
sortedFlag indicating if probabilities are already sorted (default: false)
Returns
Margin confidence score

◆ sample()

int ImageSampler::sample ( const void *  raw_output,
cv::Mat &  img,
bool  save_sample 
)

Selects uncertain image samples based on configured criteria.

Parameters
classificationResultsVector of confidence scores for each image prediction
imageOpenCV image matrix
saveSampleFlag indicating whether to save sampled images
resultsVector of confidence scores for each image prediction
uncertainty_samplingVector indicating uncertainty criteria for each sample
imgOpenCV image matrix
save_sampleFlag indicating whether to save sampled images
Returns
1 on success, error code on failure

The documentation for this class was generated from the following files: