JeVoisBase  1.21
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Loading...
Searching...
No Matches
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.
 
virtual ~ObjectRecognitionMNIST ()
 Destructor.
 
virtual void define () override
 Define the network structure.
 
virtual void train (std::string const &path) override
 Train the network.
 
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)
 
- Public Member Functions inherited from ObjectRecognition< tiny_dnn::sequential >
 ObjectRecognition (std::string const &instance)
 Constructor allocates the (empty) network.
 
virtual ~ObjectRecognition ()
 Destructor.
 
virtual tiny_dnn::index3d< size_t > insize () const override
 Get the input size for the current network, useful to prepare inputs to process()
 
vec_t process (cv::Mat const &img, bool normalize=true) override
 Process an image, results are confidence for each category.
 
- Public Member Functions inherited from ObjectRecognitionBase
 ObjectRecognitionBase (std::string const &instance)
 Constructor.
 
virtual ~ObjectRecognitionBase ()
 Virtual destructor for safe inheritance.
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 
virtual ~Component ()
 
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, bool doit)
 
void freezeAllParams (bool doit)
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
 
void setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
 
void removeDynamicParameter (std::string const &name, bool throw_if_not_found=true)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path 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, bool doit)
 
void freezeAllParams (bool doit)
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
 
void setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
 
void removeDynamicParameter (std::string const &name, bool throw_if_not_found=true)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path 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:
 
- Protected Member Functions inherited from ObjectRecognition< tiny_dnn::sequential >
virtual void postInit () override
 Initialize the network, required before one starts using it.
 
- 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: