ImageClassificationOrtSessionHandler

Copyright (c) organization

Author

btran

namespace Ort
class ImageClassificationOrtSessionHandler : public Ort::ImageRecognitionOrtSessionHandlerBase
#include <ImageClassificationOrtSessionHandler.hpp>

An ImageClassificationOrtSessionHandler class object. This class inherits ImageRecognitionOrtSessionHandlerBase and is only used in TestImageClassication.cpp where squeezenet1.1.onnx is utilized according to the preface instructions on README.md.

Public Functions

ImageClassificationOrtSessionHandler(const uint16_t numClasses, const std::string &modelPath, const std::optional<size_t> &gpuIdx = std::nullopt, const std::optional<std::vector<std::vector<int64_t>>> &inputShapes = std::nullopt)

This calls ImageClassificationOrtSessionHandler’s constructor. It also:

  1. Initializes m_numClasses with numClasses.

  2. Initializes an internal OrtSessionHandler with modelPath, gpuIdx and inputShapes.

~ImageClassificationOrtSessionHandler()

Calls standard destructor. Is empty destructor.

std::vector<std::pair<int, float>> topK(const std::vector<float*> &inferenceOutput, const uint16_t k = 1, const bool useSoftmax = true) const

A mutator function.

  1. Utilizes external softmax function to parse resulting inference from model.

  2. Map corresponding object class name index to resulting confidence score.

  3. Output the top k pairs of object class name index and corresponding confidence score. K is arbitruarily set by user in TestImageClassication.cpp.

std::string topKToString(const std::vector<float*> &inferenceOutput, const uint16_t k = 1, const bool useSoftmax = true) const

A mutator function.

  1. Utilizes external softmax function to parse resulting inference from model.

  2. Map corresponding object class name string to resulting confidence score.

  3. Print to terminal the top k pairs of object class name string and corresponding confidence score. K is arbitruarily set by user in TestImageClassication.cpp.