ImageNetData.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**
  2. * @file ImageNetData.h
  3. * @author Erik Rodner
  4. * @date 02/03/2012
  5. */
  6. #ifndef _NICE_IMAGENETDATAINCLUDE
  7. #define _NICE_IMAGENETDATAINCLUDE
  8. #ifdef NICE_USELIB_MATIO
  9. #include <string>
  10. #include <core/vector/VectorT.h>
  11. #include <core/vector/SparseVectorT.h>
  12. #include <core/matlabAccess/MatFileIO.h>
  13. #include "vislearning/cbaselib/LabeledSet.h"
  14. namespace NICE {
  15. /** @class ImageNetData
  16. * wrapper class for matlab IO with ImageNet data
  17. *
  18. * @author Erik Rodner
  19. */
  20. class ImageNetData
  21. {
  22. protected:
  23. std::string imageNetRoot;
  24. std::vector< SparseVector > XPreload;
  25. Vector yPreload;
  26. public:
  27. /** simple constructor */
  28. ImageNetData( const std::string & imageNetRoot = "/home/dbv/bilder/imagenet/devkit-1.0/demo/" );
  29. /** simple destructor */
  30. virtual ~ImageNetData();
  31. /**
  32. * @brief get a bulk of (training) data with labels
  33. *
  34. * @param data feature vectors
  35. * @param y label vector
  36. * @param fileTag demo.<tag>.mat will be accessed
  37. * @param variableTag variables are named <tag>_instance_matrix and <tag>_label_vector
  38. */
  39. void getBatchData ( sparse_t & data, Vector & y, const std::string & fileTag = "train", const std::string & variableTag = "training" );
  40. /**
  41. * @brief load the data specified for later access using the get functions
  42. *
  43. * @param fileTag
  44. * @param variableTag
  45. */
  46. void preloadData ( const std::string & fileTag = "val", const std::string & variableTag = "testing" );
  47. /**
  48. * @brief normalize the data given the specified norm
  49. *
  50. * @param normTag vector norm used in normalization, "L1" or "L2"
  51. */
  52. void normalizeData ( const std::string & normTag = "L1" );
  53. /**
  54. * @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)
  55. *
  56. * @date 23-05-2012 (dd-mm-yyyy)
  57. * @param fileTag
  58. * @param variableTag
  59. * @param lsVector
  60. */
  61. void loadDataAsLabeledSetVector( OBJREC::LabeledSetVector & lsVector, const std::string & fileTag = "train", const std::string & variableTag = "training" );
  62. /**
  63. * @brief get a specific feature vector
  64. *
  65. * @param index index of the example
  66. * @return constant reference to the SparseVector
  67. */
  68. const SparseVector & getPreloadedExample ( int index ) const;
  69. /**
  70. * @brief get the label of a specific example
  71. *
  72. * @param index index of the example
  73. *
  74. * @return label of the example (can be continous)
  75. */
  76. double getPreloadedLabel ( int index ) const;
  77. /**
  78. * @brief get number of examples
  79. */
  80. int getNumPreloadedExamples () const;
  81. /**
  82. * @brief load external labels
  83. *
  84. * @param fn file name of the external labels
  85. * @param n number of examples, if this parameter is set to -1 we assume that
  86. * the data is already loaded
  87. */
  88. void loadExternalLabels ( const std::string & fn, int n = -1 );
  89. std::vector< SparseVector > getPreloadedData() { return XPreload;};
  90. NICE::Vector getPreloadedLabels()const {return yPreload;};
  91. };
  92. }
  93. #endif
  94. #endif