JeVoisBase  1.5
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
ObjectRecognitionMNIST Class Reference

Object recognition CNN for MNIST handwritten digits. More...

#include <jevoisbase/Components/ObjectRecognition/ObjectRecognitionMNIST.H>

Inheritance diagram for ObjectRecognitionMNIST:
Collaboration diagram for ObjectRecognitionMNIST:

Public Member Functions

 ObjectRecognitionMNIST (std::string const &instance)
 Constructor, loads the given CNN, its sizes must match our (fixed) internal network structure. More...
 
virtual ~ObjectRecognitionMNIST ()
 Destructor. More...
 
virtual void define () override
 Define the network structure. More...
 
virtual void train (std::string const &path) override
 Train the network. More...
 
virtual std::string const & category (size_t idx) const override
 Return the name of a given category (0-based index in the vector of results) More...
 
- Public Member Functions inherited from ObjectRecognition< tiny_dnn::sequential >
 ObjectRecognition (std::string const &instance)
 Constructor allocates the (empty) network. More...
 
virtual ~ObjectRecognition ()
 Destructor. More...
 
virtual tiny_dnn::index3d< size_t > insize () const override
 Get the input size for the current network, useful to prepare inputs to process() More...
 
vec_t process (cv::Mat const &img, bool normalize=true) override
 Process an image, results are confidence for each category. More...
 
- Public Member Functions inherited from ObjectRecognitionBase
 ObjectRecognitionBase (std::string const &instance)
 Constructor. More...
 
virtual ~ObjectRecognitionBase ()
 Virtual destructor for safe inheritance. More...
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 
virtual ~Component ()
 
std::shared_ptr< ComponentgetSubComponent (std::string const &instance) const
 
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 
void removeSubComponent (std::shared_ptr< Comp > &component)
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 
bool isTopLevel () const
 
bool initialized () const
 
std::string const & className () const
 
std::string const & instanceName () const
 
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
void setPath (std::string const &path)
 
std::string absolutePath (std::string const &path="")
 
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 
void removeSubComponent (std::shared_ptr< Comp > &component)
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 
bool isTopLevel () const
 
bool initialized () const
 
std::string const & className () const
 
std::string const & instanceName () const
 
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
void setPath (std::string const &path)
 
std::string absolutePath (std::string const &path="")
 
- Public Member Functions inherited from jevois::ParameterRegistry
virtual ~ParameterRegistry ()
 

Additional Inherited Members

- Public Types inherited from ObjectRecognitionBase
typedef std::vector< tiny_dnn::float_t, tiny_dnn::aligned_allocator< tiny_dnn::float_t, 64 > > vec_t
 Type used by tiny-dnn for the results: More...
 
- Protected Member Functions inherited from ObjectRecognition< tiny_dnn::sequential >
virtual void postInit () override
 Initialize the network, required before one starts using it. More...
 
- Protected Member Functions inherited from jevois::Component
virtual void preInit ()
 
virtual void preUninit ()
 
virtual void postUninit ()
 
virtual void preInit ()
 
virtual void preUninit ()
 
virtual void postUninit ()
 
- Protected Member Functions inherited from jevois::ParameterRegistry
void addParameter (ParameterBase *const param)
 
void removeParameter (ParameterBase *const param)
 
void callbackInitCall ()
 
- Protected Attributes inherited from ObjectRecognition< tiny_dnn::sequential >
tiny_dnn::network< tiny_dnn::sequential > * net
 

Detailed Description

Object recognition CNN for MNIST handwritten digits.

Definition at line 25 of file ObjectRecognitionMNIST.H.

Constructor & Destructor Documentation

◆ ObjectRecognitionMNIST()

ObjectRecognitionMNIST::ObjectRecognitionMNIST ( std::string const &  instance)

Constructor, loads the given CNN, its sizes must match our (fixed) internal network structure.

All network data is assumed to be in the module's path plus "tiny-dnn/<instance>". In there, we will look for weights.tnn, and if not found, we will train the network using data in that path and then save weights.tnn.

Definition at line 23 of file ObjectRecognitionMNIST.C.

◆ ~ObjectRecognitionMNIST()

ObjectRecognitionMNIST::~ObjectRecognitionMNIST ( )
virtual

Destructor.

Definition at line 30 of file ObjectRecognitionMNIST.C.

Member Function Documentation

◆ category()

std::string const & ObjectRecognitionMNIST::category ( size_t  idx) const
overridevirtual

Return the name of a given category (0-based index in the vector of results)

Implements ObjectRecognitionBase.

Definition at line 131 of file ObjectRecognitionMNIST.C.

References LFATAL.

◆ define()

void ObjectRecognitionMNIST::define ( )
overridevirtual

Define the network structure.

Implements ObjectRecognitionBase.

Definition at line 36 of file ObjectRecognitionMNIST.C.

References O, and X.

◆ train()

void ObjectRecognitionMNIST::train ( std::string const &  path)
overridevirtual

Train the network.

Implements ObjectRecognitionBase.

Definition at line 86 of file ObjectRecognitionMNIST.C.

References LINFO, and ObjectRecognition< tiny_dnn::sequential >::net.


The documentation for this class was generated from the following files: