Program Listing for File vision_lite.h

Return to documentation for file (include/vision_lite.h)

#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_LITE_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_LITE_H_

#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "include/api/status.h"
#include "include/dataset/constants.h"
#include "include/dataset/transforms.h"

namespace mindspore {
namespace dataset {

// Transform operations for performing computer vision.
namespace vision {

// Forward Declarations
class RotateOperation;

class  Affine final : public TensorTransform {
 public:
  explicit Affine(float_t degrees, const std::vector<float> &translation = {0.0, 0.0}, float scale = 0.0,
                  const std::vector<float> &shear = {0.0, 0.0},
                  InterpolationMode interpolation = InterpolationMode::kNearestNeighbour,
                  const std::vector<uint8_t> &fill_value = {0, 0, 0});

  ~Affine() = default;

  std::shared_ptr<TensorOperation> Parse() override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  CenterCrop final : public TensorTransform {
 public:
  explicit CenterCrop(std::vector<int32_t> size);

  ~CenterCrop() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;

  std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  Crop final : public TensorTransform {
 public:
  Crop(std::vector<int32_t> coordinates, std::vector<int32_t> size);

  ~Crop() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  Decode final : public TensorTransform {
 public:
  explicit Decode(bool rgb = true);

  ~Decode() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;

  std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  GaussianBlur final : public TensorTransform {
 public:
  GaussianBlur(const std::vector<int32_t> &kernel_size, const std::vector<float> &sigma = {0., 0.});

  ~GaussianBlur() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  Normalize final : public TensorTransform {
 public:
  Normalize(std::vector<float> mean, std::vector<float> std);

  ~Normalize() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;

  std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  RandomAffine final : public TensorTransform {
 public:
  explicit RandomAffine(const std::vector<float_t> &degrees,
                        const std::vector<float_t> &translate_range = {0.0, 0.0, 0.0, 0.0},
                        const std::vector<float_t> &scale_range = {1.0, 1.0},
                        const std::vector<float_t> &shear_ranges = {0.0, 0.0, 0.0, 0.0},
                        InterpolationMode interpolation = InterpolationMode::kNearestNeighbour,
                        const std::vector<uint8_t> &fill_value = {0, 0, 0});

  ~RandomAffine() = default;

  std::shared_ptr<TensorOperation> Parse() override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  Resize final : public TensorTransform {
 public:
  explicit Resize(std::vector<int32_t> size, InterpolationMode interpolation = InterpolationMode::kLinear);

  ~Resize() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;

  std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  ResizePreserveAR final : public TensorTransform {
 public:
  ResizePreserveAR(int32_t height, int32_t width, int32_t img_orientation = 0);

  ~ResizePreserveAR() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;

 private:
  struct Data;
  std::shared_ptr<Data> data_;
};

class  RGB2BGR final : public TensorTransform {
 public:
  RGB2BGR() = default;

  ~RGB2BGR() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;
};

class  RGB2GRAY final : public TensorTransform {
 public:
  RGB2GRAY() = default;

  ~RGB2GRAY() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;
};

class  Rotate final : public TensorTransform {
 public:
  explicit Rotate(FixRotationAngle angle_id = FixRotationAngle::k0Degree);

  Rotate(float degrees, InterpolationMode resample = InterpolationMode::kNearestNeighbour, bool expand = false,
         std::vector<float> center = {}, std::vector<uint8_t> fill_value = {0, 0, 0});

  ~Rotate() = default;

 protected:
  std::shared_ptr<TensorOperation> Parse() override;

 private:
  std::shared_ptr<RotateOperation> op_;
  struct Data;
  std::shared_ptr<Data> data_;
};

}  // namespace vision
}  // namespace dataset
}  // namespace mindspore
#endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_LITE_H_