/** * @file ImageNetData.h * @author Erik Rodner * @date 02/03/2012 */ #ifndef _NICE_IMAGENETDATAINCLUDE #define _NICE_IMAGENETDATAINCLUDE #ifdef NICE_USELIB_MATIO #include #include #include #include #include "vislearning/cbaselib/LabeledSet.h" namespace NICE { /** @class ImageNetData * wrapper class for matlab IO with ImageNet data * * @author Erik Rodner */ class ImageNetData { protected: std::string imageNetRoot; std::vector< SparseVector > XPreload; Vector yPreload; public: /** simple constructor */ ImageNetData( const std::string & imageNetRoot = "/home/dbv/bilder/imagenet/devkit-1.0/demo/" ); /** simple destructor */ virtual ~ImageNetData(); /** * @brief get a bulk of (training) data with labels * * @param data feature vectors * @param y label vector * @param fileTag demo..mat will be accessed * @param variableTag variables are named _instance_matrix and _label_vector */ void getBatchData ( sparse_t & data, Vector & y, const std::string & fileTag = "train", const std::string & variableTag = "training" ); /** * @brief load the data specified for later access using the get functions * * @param fileTag * @param variableTag */ void preloadData ( const std::string & fileTag = "val", const std::string & variableTag = "testing" ); /** * @brief normalize the data given the specified norm * * @param normTag vector norm used in normalization, "L1" or "L2" */ void normalizeData ( const std::string & normTag = "L1" ); /** * @brief load the data specified for later access using the get functions, give everything as a LabeledSetVector object which is usefull for objects of type KernelClassifier (as used in vislearning) * * @date 23-05-2012 (dd-mm-yyyy) * @param fileTag * @param variableTag * @param lsVector */ void loadDataAsLabeledSetVector( OBJREC::LabeledSetVector & lsVector, const std::string & fileTag = "train", const std::string & variableTag = "training" ); /** * @brief get a specific feature vector * * @param index index of the example * @return constant reference to the SparseVector */ const SparseVector & getPreloadedExample ( int index ) const; /** * @brief get the label of a specific example * * @param index index of the example * * @return label of the example (can be continous) */ double getPreloadedLabel ( int index ) const; /** * @brief get number of examples */ int getNumPreloadedExamples () const; /** * @brief load external labels * * @param fn file name of the external labels * @param n number of examples, if this parameter is set to -1 we assume that * the data is already loaded */ void loadExternalLabels ( const std::string & fn, int n = -1 ); std::vector< SparseVector > getPreloadedData() { return XPreload;}; NICE::Vector getPreloadedLabels()const {return yPreload;}; }; } #endif #endif