forked from leovandriel/caffe2_cpp_tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtensor.h
More file actions
33 lines (26 loc) · 1.14 KB
/
tensor.h
File metadata and controls
33 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef UTIL_TENSOR_H
#define UTIL_TENSOR_H
#include <caffe2/core/tensor.h>
namespace caffe2 {
class TensorUtil {
public:
TensorUtil(Tensor<CPUContext>& tensor) : tensor_(tensor) {}
void ShowImages(const std::string& name, float scale = 1.0, float mean = 128,
bool flush = true);
void ShowImage(const std::string& title, int index, float scale = 1.0,
float mean = 128, bool flush = true);
void WriteImages(const std::string& name, float mean = 128,
bool lossy = false, int index = 0);
void WriteImage(const std::string& name, int index, float mean = 128,
bool lossy = false);
TensorCPU ScaleImageTensor(int width, int height);
void ReadImages(const std::vector<std::string>& filenames, int width,
int height, std::vector<int>& indices, float mean = 128,
TensorProto::DataType type = TensorProto_DataType_FLOAT);
void ReadImage(const std::string& filename, int width, int height);
void Print(const std::string& name = "", int max = 100);
protected:
Tensor<CPUContext>& tensor_;
};
} // namespace caffe2
#endif // UTIL_TENSOR_H