Skip to content

Commit eb52492

Browse files
author
wangsiyuan06
committed
fix code style
1 parent 2a926e4 commit eb52492

18 files changed

+853
-781
lines changed

cpp/demo/paddle_inference/ppdet_infer.cpp

+36-36
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,41 @@ DEFINE_string(pptype, "det", "Type of PaddleToolKit");
3838

3939

4040
int main(int argc, char** argv) {
41-
// Parsing command-line
42-
google::ParseCommandLineFlags(&argc, &argv, true);
43-
//parser yaml file
44-
Deploy::ConfigParser parser;
45-
parser.Load(FLAGS_cfg_file, FLAGS_pptype);
41+
// Parsing command-line
42+
google::ParseCommandLineFlags(&argc, &argv, true);
43+
// parser yaml file
44+
Deploy::ConfigParser parser;
45+
parser.Load(FLAGS_cfg_file, FLAGS_pptype);
4646

47-
// data preprocess
48-
// preprocess init
49-
Deploy::PaddleDetPreProc detpreprocess;
50-
detpreprocess.Init(parser);
51-
// postprocess init
52-
Deploy::PaddleDetPostProc detpostprocess;
53-
detpostprocess.Init(parser);
54-
//engine init
55-
Deploy::PaddleInferenceEngine ppi_engine;
56-
Deploy::PaddleInferenceConfig ppi_config;
57-
ppi_engine.Init(FLAGS_model_dir, ppi_config);
58-
if (FLAGS_image_list != "") {
59-
//img_list
60-
} else {
61-
//read image
62-
std::vector<cv::Mat> imgs;
63-
cv::Mat img;
64-
img = cv::imread(FLAGS_image, 1);
65-
imgs.push_back(std::move(img));
66-
//create inpus and shape_traces
67-
std::vector<Deploy::ShapeInfo> shape_traces;
68-
std::vector<Deploy::DataBlob> inputs;
69-
//preprocess
70-
detpreprocess.Run(imgs, &inputs, &shape_traces);
71-
//infer
72-
std::vector<Deploy::DataBlob> outputs;
73-
ppi_engine.Infer(inputs, &outputs);
74-
//postprocess
75-
std::vector<Deploy::PaddleDetResult> detresults;
76-
detpostprocess.Run(outputs, shape_traces, &detresults);
77-
}
47+
// data preprocess
48+
// preprocess init
49+
Deploy::PaddleDetPreProc det_preprocess;
50+
det_preprocess.Init(parser);
51+
// postprocess init
52+
Deploy::PaddleDetPostProc det_postprocess;
53+
det_postprocess.Init(parser);
54+
// engine init
55+
Deploy::PaddleInferenceEngine ppi_engine;
56+
Deploy::PaddleInferenceConfig ppi_config;
57+
ppi_engine.Init(FLAGS_model_dir, ppi_config);
58+
if (FLAGS_image_list != "") {
59+
// img_list
60+
} else {
61+
// read image
62+
std::vector<cv::Mat> imgs;
63+
cv::Mat img;
64+
img = cv::imread(FLAGS_image, 1);
65+
imgs.push_back(std::move(img));
66+
// create inpus and shape_traces
67+
std::vector<Deploy::ShapeInfo> shape_traces;
68+
std::vector<Deploy::DataBlob> inputs;
69+
// preprocess
70+
det_preprocess.Run(imgs, &inputs, &shape_traces);
71+
// infer
72+
std::vector<Deploy::DataBlob> outputs;
73+
ppi_engine.Infer(inputs, &outputs);
74+
// postprocess
75+
std::vector<Deploy::PaddleDetResult> detresults;
76+
det_postprocess.Run(outputs, shape_traces, &detresults);
77+
}
7878
}

cpp/include/deploy/common/blob.h

+15-17
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,41 @@
1616

1717
#include <vector>
1818
#include <map>
19+
#include <string>
1920

2021
namespace Deploy {
2122

2223
class DataBlob{
23-
public:
24+
public:
2425
// data
25-
std::vector<char> data;
26-
26+
std::vector<char> data;
27+
2728
// data name
28-
std::string name;
29+
std::string name;
2930

3031
// data shape
31-
std::vector<int> shape;
32+
std::vector<int> shape;
3233

33-
/*
34+
/*
3435
data dtype
3536
0: FLOAT32
3637
1: INT64
3738
2: INT32
3839
3: UINT8
3940
*/
40-
int dtype;
41-
42-
//LoD信息
43-
std::vector<std::vector<size_t>> lod;
41+
int dtype;
4442

43+
// Lod Info
44+
std::vector<std::vector<size_t>> lod;
4545
};
4646

4747
class ShapeInfo{
48-
public:
49-
48+
public:
5049
// shape trace
51-
std::vector<std::vector<int> > shape;
52-
50+
std::vector<std::vector<int> > shape;
51+
5352
// transform order
54-
std::vector<std::string> transform_order;
55-
53+
std::vector<std::string> transform_order;
5654
};
5755

58-
}//namespace
56+
} // namespace Deploy

cpp/include/deploy/common/config.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@
2424
namespace Deploy {
2525

2626
class ConfigParser {
27-
public:
28-
ConfigParser() {}
27+
public:
28+
ConfigParser() {}
2929

30-
~ConfigParser() {}
30+
~ConfigParser() {}
3131

32-
bool Load(const std::string &cfg_file, const std::string &pp_type);
32+
bool Load(const std::string &cfg_file, const std::string &pp_type);
3333

34-
template <typename T>
35-
const T& Get(const std::string &name) const {
36-
return config_[name].as<T>();
37-
}
34+
template <typename T>
35+
const T& Get(const std::string &name) const {
36+
return config_[name].as<T>();
37+
}
3838

39-
YAML::Node GetNode(const std::string &node_name) const;
40-
41-
private:
42-
bool DetParser(const YAML::Node &det_config);
39+
YAML::Node GetNode(const std::string &node_name) const;
4340

44-
bool DetParserTransforms(const YAML::Node &preprocess_op);
41+
private:
42+
bool DetParser(const YAML::Node &det_config);
4543

46-
YAML::Node config_;
44+
bool DetParserTransforms(const YAML::Node &preprocess_op);
45+
46+
YAML::Node config_;
4747
};
4848

49-
}//namespace
49+
} // namespace Deploy

0 commit comments

Comments
 (0)