123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- #ifndef MODULES_INFERENCE_INCLUDE_INFERENCER_HPP_
- #define MODULES_INFERENCE_INCLUDE_INFERENCER_HPP_
- #include <memory>
- #include <string>
- #include <thread>
- #include <vector>
- #include "cnstream_module.hpp"
- #include "exception.hpp"
- #define DECLARE_PRIVATE(d_ptr, Class) \
- friend class Class##Private; \
- Class##Private* d_ptr = nullptr;
- #define DECLARE_PUBLIC(q_ptr, Class) \
- friend class Class; \
- Class* q_ptr = nullptr;
- namespace cnstream {
- CNSTREAM_REGISTER_EXCEPTION(Inferencer);
- class InferencerPrivate;
- class InferParamManager;
- /**
- * @class Inferencer
- *
- * @brief Inferencer is a module for running offline model to do inference.
- * The input data could come from Decoder or other plugins, in MLU memory
- * or CPU memory. Also, If the ``preproc_name`` parameter is set to ``PreprocCpu``
- * in the Open function or configuration file, CPU is used for image preprocessing.
- * Otherwise, if the ``preproc_name`` parameter is not
- * set, MLU is used for image preprocessing. The image preprocessing includes
- * data shape resizing and color space convertion.
- * Afterwards, you can infer with offline model loading from the model path.
- *
- * @attention
- * The error log will be reported when the following two situations occur as MLU is used to do preprocessing.
- * case 1: scale-up factor is greater than 100.
- * case 2: the image width before resize is greater than 7680.
- */
- class Inferencer : public Module, public ModuleCreator<Inferencer> {
- public:
-
- explicit Inferencer(const std::string& name);
-
- virtual ~Inferencer();
-
- bool Open(ModuleParamSet paramSet) override;
-
- void Close() override;
-
- int Process(CNFrameInfoPtr data) final;
-
- bool CheckParamSet(const ModuleParamSet ¶m_set) const override;
- private:
- InferParamManager *param_manager_ = nullptr;
- DECLARE_PRIVATE(d_ptr_, Inferencer);
- };
- }
- #endif
|