ImageNetData.h 2.9 KB

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