diff options
author | Gian Marco <gianmarco.iodice@arm.com> | 2017-10-19 14:13:38 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 44ec2e7c1edd57eb2fb2674a28452aac02bd8c0a (patch) | |
tree | 648311be8809fd64a027d3e26485896db915dbb8 /utils/GraphUtils.h | |
parent | fa4cacdff825a38eac31ef7ecd3ad6b30da53eaa (diff) | |
download | ComputeLibrary-44ec2e7c1edd57eb2fb2674a28452aac02bd8c0a.tar.gz |
COMPMID-639 - Add PPMAccessor and TopNPredictionsAccessor in graph_utils
Change-Id: I40c3e2dfcde10c65ed9c86f9283a53f9e679d4fa
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/92437
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'utils/GraphUtils.h')
-rw-r--r-- | utils/GraphUtils.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h index 5c370e5eba..39b3f115bd 100644 --- a/utils/GraphUtils.h +++ b/utils/GraphUtils.h @@ -29,6 +29,8 @@ #include "arm_compute/graph/Types.h" #include <random> +#include <string> +#include <vector> namespace arm_compute { @@ -76,6 +78,60 @@ private: unsigned int _maximum; }; +/** PPM accessor class */ +class PPMAccessor final : public graph::ITensorAccessor +{ +public: + /** Constructor + * + * @param[in] ppm_path Path to PPM file + * @param[in] bgr (Optional) Fill the first plane with blue channel (default = false) + * @param[in] mean_r (Optional) Red mean value to be subtracted from red channel + * @param[in] mean_g (Optional) Green mean value to be subtracted from green channel + * @param[in] mean_b (Optional) Blue mean value to be subtracted from blue channel + */ + PPMAccessor(const std::string &ppm_path, bool bgr = true, float mean_r = 0.0f, float mean_g = 0.0f, float mean_b = 0.0f); + /** Allow instances of this class to be move constructed */ + PPMAccessor(PPMAccessor &&) = default; + + // Inherited methods overriden: + bool access_tensor(ITensor &tensor) override; + +private: + const std::string &_ppm_path; + const bool _bgr; + const float _mean_r; + const float _mean_g; + const float _mean_b; +}; + +/** Result accessor class */ +class TopNPredictionsAccessor final : public graph::ITensorAccessor +{ +public: + /** Constructor + * + * @param[in] labels_path Path to labels text file. + * @param[in] top_n (Optional) Number of output classes to print + * @param[out] output_stream (Optional) Output stream + */ + TopNPredictionsAccessor(const std::string &labels_path, size_t top_n = 5, std::ostream &output_stream = std::cout); + /** Allow instances of this class to be move constructed */ + TopNPredictionsAccessor(TopNPredictionsAccessor &&) = default; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + TopNPredictionsAccessor(const TopNPredictionsAccessor &) = delete; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + TopNPredictionsAccessor &operator=(const TopNPredictionsAccessor &) = delete; + + // Inherited methods overriden: + bool access_tensor(ITensor &tensor) override; + +private: + std::vector<std::string> _labels; + std::ostream &_output_stream; + size_t _top_n; +}; + /** Random accessor class */ class RandomAccessor final : public graph::ITensorAccessor { |