ImageNetData.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/SparseVector.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 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)
  49. *
  50. * @date 23-05-2012 (dd-mm-yyyy)
  51. * @param fileTag
  52. * @param variableTag
  53. * @param lsVector
  54. */
  55. void loadDataAsLabeledSetVector( OBJREC::LabeledSetVector & lsVector, const std::string & fileTag = "train", const std::string & variableTag = "training" );
  56. /**
  57. * @brief get a specific feature vector
  58. *
  59. * @param index index of the example
  60. * @return constant reference to the SparseVector
  61. */
  62. const SparseVector & getPreloadedExample ( int index ) const;
  63. /**
  64. * @brief get the label of a specific example
  65. *
  66. * @param index index of the example
  67. *
  68. * @return label of the example (can be continous)
  69. */
  70. double getPreloadedLabel ( int index ) const;
  71. /**
  72. * @brief get number of examples
  73. */
  74. int getNumPreloadedExamples () const;
  75. /**
  76. * @brief load external labels
  77. *
  78. * @param fn file name of the external labels
  79. * @param n number of examples, if this parameter is set to -1 we assume that
  80. * the data is already loaded
  81. */
  82. void loadExternalLabels ( const std::string & fn, int n = -1 );
  83. std::vector< SparseVector > getPreloadedData() { return XPreload;};
  84. NICE::Vector getPreloadedLabels()const {return yPreload;};
  85. };
  86. }
  87. #endif
  88. #endif