JeVois  1.18
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
NetworkPython.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2021 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 #pragma once
19 
20 #include <jevois/DNN/Network.H>
22 
23 namespace jevois
24 {
25  namespace dnn
26  {
27  class NetworkPythonImpl;
28 
29  //! Wrapper around an DNN neural network invoked through python
30  /*! \ingroup dnn */
31  class NetworkPython : public Network, public Parameter<network::pynet>
32  {
33  public:
34  //! Constructor
35  NetworkPython(std::string const & instance);
36 
37  //! Destructor
38  virtual ~NetworkPython();
39 
40  //! Freeze/unfreeze parameters that users should not change while running
41  void freeze(bool doit) override;
42 
43  //! Get shapes of all input tensors
44  std::vector<vsi_nn_tensor_attr_t> inputShapes() override;
45 
46  //! Get shapes of all output tensors
47  std::vector<vsi_nn_tensor_attr_t> outputShapes() override;
48 
49  //! Load from disk
50  void load() override;
51 
52  //! Process input blobs and obtain output blobs
53  std::vector<cv::Mat> doprocess(std::vector<cv::Mat> const & blobs,
54  std::vector<std::string> & info) override;
55 
56  protected:
57  // Load the python code as soon as the file is set, and call init() on it if defined
58  void onParamChange(network::pynet const & param, std::string const & newval) override;
59 
60  // Python init() may create new dynamic parameters, but in onParamChange() we are locked up, so we need to use a
61  // sub-Component for our actual implementation, and the sub can get its dynamic parameters created while our own
62  // params are locked up...
63  std::shared_ptr<NetworkPythonImpl> itsImpl;
64  };
65 
66  } // namespace dnn
67 } // namespace jevois
68 
Network.H
jevois::dnn::NetworkPython::outputShapes
std::vector< vsi_nn_tensor_attr_t > outputShapes() override
Get shapes of all output tensors.
Definition: NetworkPython.C:127
jevois::dnn::NetworkPython::doprocess
std::vector< cv::Mat > doprocess(std::vector< cv::Mat > const &blobs, std::vector< std::string > &info) override
Process input blobs and obtain output blobs.
Definition: NetworkPython.C:114
jevois
Definition: Concepts.dox:1
jevois::dnn::NetworkPython::inputShapes
std::vector< vsi_nn_tensor_attr_t > inputShapes() override
Get shapes of all input tensors.
Definition: NetworkPython.C:123
jevois::dnn::NetworkPython::~NetworkPython
virtual ~NetworkPython()
Destructor.
Definition: NetworkPython.C:93
jevois::dnn::NetworkPython::freeze
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
Definition: NetworkPython.C:97
jevois::dnn::NetworkPython::onParamChange
void onParamChange(network::pynet const &param, std::string const &newval) override
Definition: NetworkPython.C:107
jevois::dnn::NetworkPython::itsImpl
std::shared_ptr< NetworkPythonImpl > itsImpl
Definition: NetworkPython.H:63
jevois::dnn::NetworkPython::NetworkPython
NetworkPython(std::string const &instance)
Constructor.
Definition: NetworkPython.C:86
PythonWrapper.H
jevois::dnn::NetworkPython
Wrapper around an DNN neural network invoked through python.
Definition: NetworkPython.H:31
jevois::dnn::NetworkPython::load
void load() override
Load from disk.
Definition: NetworkPython.C:119
jevois::dnn::Network
Abstract class to represent a neural network.
Definition: Network.H:153