19 #ifndef SINGA_IO_TRANSFORMER_H_ 20 #define SINGA_IO_TRANSFORMER_H_ 24 #include "singa/core/tensor.h" 25 #include "singa/proto/io.pb.h" 26 #include "singa/proto/model.pb.h" 36 virtual void Setup(
const TransformerConf& conf) {}
43 void Setup(
const TransformerConf& conf)
override {
44 featurewise_center_ = conf.featurewise_center();
45 featurewise_std_norm_ = conf.featurewise_std_norm();
46 resize_height_ = conf.resize_height();
47 resize_width_ = conf.resize_width();
48 rescale_ = conf.rescale();
49 horizontal_mirror_ = conf.horizontal_mirror();
50 image_dim_order_ = conf.image_dim_order();
53 if (conf.crop_shape_size() == 2)
54 crop_shape_ = {conf.crop_shape(0), conf.crop_shape(1)};
59 const bool featurewise_center()
const {
return featurewise_center_; }
60 const bool featurewise_std_norm()
const {
return featurewise_std_norm_; }
61 const bool horizontal_mirror()
const {
return horizontal_mirror_; }
62 const int resize_height()
const {
return resize_height_; }
63 const int resize_width()
const {
return resize_width_; }
64 const float rescale()
const {
return rescale_; }
65 const Shape crop_shape()
const {
return crop_shape_; }
66 const string image_dim_order()
const {
return image_dim_order_; }
69 bool featurewise_center_ =
false;
70 bool featurewise_std_norm_ =
false;
71 bool horizontal_mirror_ =
false;
72 int resize_height_ = 0;
73 int resize_width_ = 0;
75 Shape crop_shape_ = {};
76 std::string image_dim_order_ =
"CHW";
81 const size_t resize_width,
const string& image_dim_order);
84 const size_t crop_width,
const size_t crop_h_offset,
85 const size_t crop_w_offset,
const string& image_dim_order);
86 Tensor mirror(
Tensor& input,
const bool horizontal_mirror,
87 const bool vertical_mirror,
const string& image_dim_order);
89 #endif // SINGA_IO_TRANSFORMER_H_
A Tensor instance is a multi-dimensional array resident on a Device (default device is the host CPU)...
Definition: tensor.h:56
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: common.h:48