32 void loadpy(std::string
const & pypath);
36 std::vector<cv::Mat>
doprocess(std::vector<cv::Mat>
const & outs, std::vector<std::string> & info);
59 LINFO(
"Loaded " << pypath);
69 else LFATAL(
"No load() method provided. It is required, please add it to your Python network processor.");
74 std::vector<std::string> & info)
77 LFATAL(
"No process() method provided. It is required, please add it to your Python network processor.");
81 boost::python::tuple rett = boost::python::extract<boost::python::tuple>(ret);
82 if (boost::python::len(rett) != 2)
LFATAL(
"Expected tuple(list of output blobs, list of info strings)");
84 std::vector<cv::Mat> retm = jevois::python::pyListToVec<cv::Mat>(rett[0]);
85 info = jevois::python::pyListToVec<std::string>(rett[1]);
95 itsImpl = addSubComponent<jevois::dnn::NetworkPythonImpl>(
"pynet");
109 itsImpl->freeze(doit);
117 if (newval.empty() ==
false) itsImpl->loadpy(newval);
122 std::vector<std::string> & info)
123{
return itsImpl->doprocess(outs, info); }
#define JEVOIS_SHARE_PATH
Base path for shared files (e.g., neural network weights, etc)
A component of a model hierarchy.
void unRegisterPythonComponent(Component *comp)
Unregister a component as linked to some python code, used by dynamic params created in python.
friend class Component
Allow Component and DynamicParameter to access our registry data, everyone else is locked out.
Helper class to run python code from C++.
void pythonload(std::string const &path)
Init from path if default constructor was used.
boost::python::object & pyinst()
Get the python class pyinst, or throw if construction error occurred (e.g., file not found)
virtual ~NetworkPythonImpl()
std::vector< cv::Mat > doprocess(std::vector< cv::Mat > const &outs, std::vector< std::string > &info)
void loadpy(std::string const &pypath)
std::vector< cv::Mat > doprocess(std::vector< cv::Mat > const &blobs, std::vector< std::string > &info) override
Process input blobs and obtain output blobs.
virtual ~NetworkPython()
Destructor.
void load() override
Load from disk.
std::vector< vsi_nn_tensor_attr_t > inputShapes() override
Get shapes of all input tensors.
void onParamChange(network::pynet const ¶m, std::string const &newval) override
std::shared_ptr< NetworkPythonImpl > itsImpl
std::vector< vsi_nn_tensor_attr_t > outputShapes() override
Get shapes of all output tensors.
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
NetworkPython(std::string const &instance)
Constructor.
Abstract class to represent a neural network.
virtual void freeze(bool doit)
Freeze/unfreeze parameters that users should not change while running.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
#define LINFO(msg)
Convenience macro for users to print out console or syslog messages, INFO level.
std::vector< vsi_nn_tensor_attr_t > parseTensorSpecs(std::string const &specs)
Parse tensor specification.
boost::python::list pyVecToList(std::vector< T > const &v)
Helper to convert std::vector<T> to python list.
bool hasattr(boost::python::object &o, char const *name)
Check whether a boost::python::object has an attribute.
Main namespace for all JeVois classes and functions.