MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / Transform

Method Transform

rtpose_wrapper/src/caffe/data_transformer.cpp:57–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55
56template<typename Dtype>
57void DataTransformer<Dtype>::Transform(const Datum& datum,
58 Dtype* transformed_data) {
59 const string& data = datum.data();
60 const int datum_channels = datum.channels();
61 const int datum_height = datum.height();
62 const int datum_width = datum.width();
63
64 const int crop_size = param_.crop_size();
65 const Dtype scale = param_.scale();
66 const bool do_mirror = param_.mirror() && Rand(2);
67 const bool has_mean_file = param_.has_mean_file();
68 const bool has_uint8 = data.size() > 0;
69 const bool has_mean_values = mean_values_.size() > 0;
70
71 CHECK_GT(datum_channels, 0);
72 CHECK_GE(datum_height, crop_size);
73 CHECK_GE(datum_width, crop_size);
74
75 Dtype* mean = NULL;
76 if (has_mean_file) {
77 CHECK_EQ(datum_channels, data_mean_.channels());
78 CHECK_EQ(datum_height, data_mean_.height());
79 CHECK_EQ(datum_width, data_mean_.width());
80 mean = data_mean_.mutable_cpu_data();
81 }
82 if (has_mean_values) {
83 CHECK(mean_values_.size() == 1 || mean_values_.size() == datum_channels) <<
84 "Specify either 1 mean_value or as many as channels: " << datum_channels;
85 if (datum_channels > 1 && mean_values_.size() == 1) {
86 // Replicate the mean_value for simplicity
87 for (int c = 1; c < datum_channels; ++c) {
88 mean_values_.push_back(mean_values_[0]);
89 }
90 }
91 }
92
93 int height = datum_height;
94 int width = datum_width;
95
96 int h_off = 0;
97 int w_off = 0;
98 if (crop_size) {
99 height = crop_size;
100 width = crop_size;
101 // We only do random crop when we do training.
102 if (phase_ == TRAIN) {
103 h_off = Rand(datum_height - crop_size + 1);
104 w_off = Rand(datum_width - crop_size + 1);
105 } else {
106 h_off = (datum_height - crop_size) / 2;
107 w_off = (datum_width - crop_size) / 2;
108 }
109 }
110
111 Dtype datum_element;
112 int top_index, data_index;
113 for (int c = 0; c < datum_channels; ++c) {
114 for (int h = 0; h < height; ++h) {

Callers 6

NumSequenceMatchesMethod · 0.80
TYPED_TESTFunction · 0.80
AddDatumVectorMethod · 0.80
AddMatVectorMethod · 0.80
load_batchMethod · 0.80
load_batchMethod · 0.80

Calls 15

DecodeDatumToCVMatFunction · 0.85
DecodeDatumToCVMatNativeFunction · 0.85
caffe_add_scalarFunction · 0.85
dataMethod · 0.80
numMethod · 0.80
offsetMethod · 0.80
countMethod · 0.80
channelsMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45
sizeMethod · 0.45
mutable_cpu_dataMethod · 0.45

Tested by 2

NumSequenceMatchesMethod · 0.64
TYPED_TESTFunction · 0.64