MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / NormalizeAndAddImages

Function NormalizeAndAddImages

tensorflow/core/summary/summary_converter.cc:179–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178template <class T>
179Status NormalizeAndAddImages(const Tensor& tensor, int max_images, int h, int w,
180 int hw, int depth, int batch_size,
181 const string& base_tag, Tensor bad_color_tensor,
182 Summary* s) {
183 // For float and half images, nans and infs are replaced with bad_color.
184 if (bad_color_tensor.dim_size(0) < depth) {
185 return errors::InvalidArgument(
186 "expected depth <= bad_color.size, got depth = ", depth,
187 ", bad_color.size = ", bad_color_tensor.dim_size(0));
188 }
189 auto bad_color_full = bad_color_tensor.vec<uint8>();
190 typename TTypes<uint8>::ConstVec bad_color(bad_color_full.data(), depth);
191
192 // Float images must be scaled and translated.
193 Uint8Image image(hw, depth);
194 auto ith_image = [&tensor, &image, bad_color, batch_size, hw, depth](int i) {
195 auto tensor_eigen = tensor.template shaped<T, 3>({batch_size, hw, depth});
196 typename TTypes<T>::ConstMatrix values(
197 &tensor_eigen(i, 0, 0), Eigen::DSizes<Eigen::DenseIndex, 2>(hw, depth));
198 NormalizeFloatImage<T>(hw, depth, values, bad_color, &image);
199 return image;
200 };
201 return AddImages(base_tag, max_images, batch_size, w, h, depth, ith_image, s);
202}
203
204} // namespace
205

Callers

nothing calls this directly

Calls 4

InvalidArgumentFunction · 0.85
AddImagesFunction · 0.85
dim_sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected