#pragma once #include #include #include #include #include "utils.h" class YOLOPredictor { public: explicit YOLOPredictor(std::nullptr_t){}; YOLOPredictor(const std::string &modelPath, const bool &isGPU, float confThreshold, float iouThreshold, float maskThreshold); // ~YOLOPredictor(); std::vector> predict(std::vector &images); int classNums = 80; private: Ort::Env env{nullptr}; Ort::SessionOptions sessionOptions{nullptr}; Ort::Session session{nullptr}; void preprocessing(std::vector &image, float *&blob, std::vector &inputTensorShape); std::vector> postprocessing(const cv::Size &resizedImageShape, const std::vector &originalImageShapes, std::vector &outputTensors); static void getBestClassInfo(std::vector::iterator it, float &bestConf, int &bestClassId, const int _classNums); cv::Mat getMask(const cv::Mat &maskProposals, const cv::Mat &maskProtos); bool isDynamicInputShape{}; std::vector inputNames; std::vector input_names_ptr; std::vector outputNames; std::vector output_names_ptr; std::vector> inputShapes; std::vector> outputShapes; float confThreshold = 0.3f; float iouThreshold = 0.4f; bool hasMask = false; float maskThreshold = 0.5f; };