23#include <ovxlib/vsi_nn_pub.h>
25#include <opencv2/core/core.hpp>
48 "are relative paths.",
53 "Can have extension .prototxt (Caffe), .pbtxt (TensorFlow), or .cfg (Darknet). "
54 "If path is relative, it will be prefixed by dataroot.",
59 "Can have extension .caffemodel (Caffe), .pb (TensorFlow), .t7 or .net (Torch), "
60 ".tflite (TensorFlow Lite), or .weights (Darknet). If path is relative, it will be "
61 "prefixed by dataroot.",
66 "instantiate a NPU model. If a library is provided, then intensors and outtensors "
67 "can be left empty, otherwise they have to describe exactly the inputs and outputs "
68 "of the NPU model. This library is obtained along with the NPU .nb model when "
69 "converting for NPU using the KSNN convert tool. If path is relative, it will be "
70 "prefixed by dataroot.",
84 "next time you load a different model.",
85 Target::CPU, Target_Values, ParamCateg);
89#define JEVOIS_BACKEND_DEFAULT Backend::OpenCV
93#define JEVOIS_BACKEND_DEFAULT Backend::Default
98 "engine if available, otherwise OpenCV (note that inference engine only works on Intel "
99 "processors or MyriadX hardware, thus you should normally select OpenCV when running "
100 "on JeVois-Pro Platform, unless you want to use an optional MyriadX accelerator). "
101 "Changes will take effect next time you load a model.",
110 "added after the regular intensors. Format is: "
111 "<type>:<shape>:val1 val2 ... valN, <type>:<shape>:val1 ... valN. For example, for "
112 "URetinex-Net: 32F:1x1x1:3.0",
121 "(reshape, transpose, split, merge, etc) to be applied to the output "
122 "tensors. Useful to match a particular network's outputs to the "
123 "tensor shapes expected by a particular post-processor. The sequence of "
124 "operations is separated by semicolons, and applied from left to right. "
125 "Operations specified here are applied after any de-quantization.",
141 "Name of class defined in the file must match the file name without "
142 "the trailing '.py'",
147 "1 when using a dual-TPU add-on board, or more when using additional TPUs connected "
153 "several Hailo8 accelerators are connected to the system",
162 "to use latest version",
163 "", boost::regex(
"^$|^[0-9]+\\.[0-9]+\\.[0-9]+$"), ParamCateg);
167 "fast networks. Use with caution as it may lead to overheating, not "
168 "recommended for production",
211 public Parameter<network::comment, network::url, network::outtransform, network::extraintensors>
238 std::vector<cv::Mat>
process(std::vector<cv::Mat>
const & blobs, std::vector<std::string> & info);
243 virtual void freeze(
bool doit);
250 virtual std::vector<cv::Mat>
doprocess(std::vector<cv::Mat>
const & blobs,
251 std::vector<std::string> & info) = 0;
253 void onParamChange(network::outtransform
const & param, std::string
const & val)
override;
256 std::atomic<bool> itsLoading =
false;
257 std::atomic<bool> itsLoaded =
false;
258 std::future<void> itsLoadFut;
261 enum class Operator { Shape, Transpose, Order, Split, Merge };
265 std::vector<size_t> tnum;
266 std::vector<int> newvals;
268 std::vector<Oper> itsOps;
#define JEVOIS_SHARE_PATH
Base path for shared files (e.g., neural network weights, etc)
#define JEVOIS_BACKEND_DEFAULT
A component of a model hierarchy.
friend class Component
Allow Component and DynamicParameter to access our registry data, everyone else is locked out.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(turbo, bool, "Turbo mode. Has no significant effect on small or " "fast networks. Use with caution as it may lead to overheating, not " "recommended for production", false, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(verifygraph, bool, "Verify NPU graph after loading it", true, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(ovxver, std::string, "ovxlib version to use with NPU network, or leave blank " "to use latest version", "", boost::regex("^$|^[0-9]+\\.[0-9]+\\.[0-9]+$"), ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(library, std::string, "Optional path to a compiled .so library that can load and " "instantiate a NPU model. If a library is provided, then intensors and outtensors " "can be left empty, otherwise they have to describe exactly the inputs and outputs " "of the NPU model. This library is obtained along with the NPU .nb model when " "converting for NPU using the KSNN convert tool. If path is relative, it will be " "prefixed by dataroot.", "", ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(pynet, std::string, "Full path of the python network processor file. " "Name of class defined in the file must match the file name without " "the trailing '.py'", "", ParamCateg)
Parameter.
Abstract class to represent a neural network.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(outtransform, std::string, "Specification of a sequence of operations " "(reshape, transpose, split, merge, etc) to be applied to the output " "tensors. Useful to match a particular network's outputs to the " "tensor shapes expected by a particular post-processor. The sequence of " "operations is separated by semicolons, and applied from left to right. " "Operations specified here are applied after any de-quantization.", "", ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(url, std::string, "Optional URL for the network", "", ParamCateg)
Parameter.
virtual void load()=0
Load from disk.
bool ready()
Returns true when network is ready to run (loaded and initialized)
JEVOIS_DECLARE_PARAMETER(dequant, bool, "Dequantize output tensors to float32 from their native quantized type", true, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(spunum, size_t, "Hailo8 device number to use to run this model, typically 0 unless " "several Hailo8 accelerators are connected to the system", 0, ParamCateg)
Parameter.
std::vector< cv::Mat > process(std::vector< cv::Mat > const &blobs, std::vector< std::string > &info)
Process input blobs and obtain output blobs.
JEVOIS_DECLARE_PARAMETER(config, std::string, "Path to a text file that contains network configuration. " "Can have extension .prototxt (Caffe), .pbtxt (TensorFlow), or .cfg (Darknet). " "If path is relative, it will be prefixed by dataroot.", "", ParamCateg)
Parameter.
void onParamChange(network::outtransform const ¶m, std::string const &val) override
JEVOIS_DECLARE_PARAMETER(intensors, std::string, "Specification of input tensors", "", ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(target, Target, "OpenCV compute target to use. Changes will take effect " "next time you load a different model.", Target::CPU, Target_Values, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(model, std::string, "Path to a binary file of model contains trained weights. " "Can have extension .caffemodel (Caffe), .pb (TensorFlow), .t7 or .net (Torch), " ".tflite (TensorFlow Lite), or .weights (Darknet). If path is relative, it will be " "prefixed by dataroot.", "", ParamCateg)
Parameter.
void waitBeforeDestroy()
If network is currently loading, wait until that is done before destroying.
JEVOIS_DECLARE_PARAMETER(backend, Backend, "OpenCV compute backend to use. Default will use the inference " "engine if available, otherwise OpenCV (note that inference engine only works on Intel " "processors or MyriadX hardware, thus you should normally select OpenCV when running " "on JeVois-Pro Platform, unless you want to use an optional MyriadX accelerator). " "Changes will take effect next time you load a model.", JEVOIS_BACKEND_DEFAULT, Backend_Values, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(outtensors, std::string, "Specification of output tensors", "", ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(tpunum, size_t, "Coral EdgeTPU number to use to run this model, typically 0, or can be " "1 when using a dual-TPU add-on board, or more when using additional TPUs connected " "to USB ports", 0, ParamCateg)
Parameter.
virtual std::vector< vsi_nn_tensor_attr_t > outputShapes()=0
Get shapes of all output tensors.
virtual std::vector< vsi_nn_tensor_attr_t > inputShapes()=0
Get shapes of all input tensors.
JEVOIS_DECLARE_PARAMETER(extraintensors, std::string, "Specification of extra fixed input tensors that will be " "added after the regular intensors. Format is: " "<type>:<shape>:val1 val2 ... valN, <type>:<shape>:val1 ... valN. For example, for " "URetinex-Net: 32F:1x1x1:3.0", "", ParamCateg)
Parameter.
virtual std::vector< cv::Mat > doprocess(std::vector< cv::Mat > const &blobs, std::vector< std::string > &info)=0
Process input blobs and obtain output blobs.
JEVOIS_DECLARE_PARAMETER(comment, std::string, "Optional comment about the network", "", ParamCateg)
Parameter.
virtual ~Network()
Destructor.
JEVOIS_DEFINE_ENUM_CLASS(Target,(CPU)(OpenCL)(OpenCL_FP16)(Myriad)(NPU))
Enum.
JEVOIS_DEFINE_ENUM_CLASS(Backend,(OpenCV)(InferenceEngine)(TimVX))
Enum.
virtual void freeze(bool doit)
Freeze/unfreeze parameters that users should not change while running.
JEVOIS_DECLARE_PARAMETER(dataroot, std::string, "Root directory to use when config or model parameters " "are relative paths.", JEVOIS_SHARE_PATH, ParamCateg)
Parameter.
JEVOIS_DEFINE_ENUM_CLASS(CameraSensor,(any)(imx290)(os08a10)(ar0234))
Enum for different sensor models.
Main namespace for all JeVois classes and functions.
A category to which multiple ParameterDef definitions can belong.