提交 de726400 编写于 作者: D dongshuilong

code format

上级 87873447
......@@ -215,9 +215,9 @@ cp ../configs/inference_cls.yaml tools/
#### 2.3.2 执行
```shell
./build/clas_system -c inference_cls.yaml
./build/clas_system -c tools/inference_cls.yaml
# or
./build/clas_system -config inference_cls.yaml
./build/clas_system -config tools/inference_cls.yaml
```
最终屏幕上会输出结果,如下图所示。
......
......@@ -18,7 +18,7 @@
namespace Feature {
void FeatureExtracter::LoadModel(const std::string &model_path,
void FeatureExtracter::LoadModel(const std::string &model_path,
const std::string &params_path) {
paddle_infer::Config config;
config.SetModel(model_path, params_path);
......@@ -52,9 +52,9 @@ void FeatureExtracter::LoadModel(const std::string &model_path,
config.DisableGlogInfo();
this->predictor_ = CreatePredictor(config);
}
}
void FeatureExtracter::Run(cv::Mat &img, std::vector<float> &out_data,
void FeatureExtracter::Run(cv::Mat &img, std::vector<float> &out_data,
std::vector<double> &times) {
cv::Mat resize_img;
std::vector<double> time;
......@@ -108,12 +108,12 @@ void FeatureExtracter::Run(cv::Mat &img, std::vector<float> &out_data,
times[0] += time[0];
times[1] += time[1];
times[2] += time[2];
}
}
void FeatureExtracter::FeatureNorm(std::vector<float> &featuer) {
void FeatureExtracter::FeatureNorm(std::vector<float> &featuer) {
float featuer_sqrt = std::sqrt(std::inner_product(
featuer.begin(), featuer.end(), featuer.begin(), 0.0f));
for (int i = 0; i < featuer.size(); ++i)
featuer[i] /= featuer_sqrt;
}
}
} // namespace Feature
......@@ -37,13 +37,15 @@
using namespace std;
using namespace cv;
DEFINE_string(config, "", "Path of yaml file");
DEFINE_string(c, "", "Path of yaml file");
DEFINE_string(config,
"", "Path of yaml file");
DEFINE_string(c,
"", "Path of yaml file");
void DetPredictImage(const std::vector<cv::Mat> &batch_imgs,
const std::vector<std::string> &all_img_paths,
void DetPredictImage(const std::vector <cv::Mat> &batch_imgs,
const std::vector <std::string> &all_img_paths,
const int batch_size, Detection::ObjectDetector *det,
std::vector<Detection::ObjectResult> &im_result,
std::vector <Detection::ObjectResult> &im_result,
std::vector<int> &im_bbox_num, std::vector<double> &det_t,
const bool visual_det = false,
const bool run_benchmark = false,
......@@ -63,7 +65,7 @@ void DetPredictImage(const std::vector<cv::Mat> &batch_imgs,
// }
// Store all detected result
std::vector<Detection::ObjectResult> result;
std::vector <Detection::ObjectResult> result;
std::vector<int> bbox_num;
std::vector<double> det_times;
bool is_rbox = false;
......@@ -134,7 +136,7 @@ void DetPredictImage(const std::vector<cv::Mat> &batch_imgs,
}
void PrintResult(std::string &img_path,
std::vector<Detection::ObjectResult> &det_result,
std::vector <Detection::ObjectResult> &det_result,
std::vector<int> &indeices, VectorSearch &vector_search,
SearchResult &search_result) {
printf("%s:\n", img_path.c_str());
......@@ -194,9 +196,9 @@ int main(int argc, char **argv) {
// load image_file_path
std::string path =
config.config_file["Global"]["infer_imgs"].as<std::string>();
std::vector<std::string> img_files_list;
std::vector <std::string> img_files_list;
if (cv::utils::fs::isDirectory(path)) {
std::vector<cv::String> filenames;
std::vector <cv::String> filenames;
cv::glob(path, filenames);
for (auto f : filenames) {
img_files_list.push_back(f);
......@@ -211,10 +213,10 @@ int main(int argc, char **argv) {
std::vector<double> search_times = {0, 0, 0};
int instance_num = 0;
// for read images
std::vector<cv::Mat> batch_imgs;
std::vector<std::string> img_paths;
std::vector <cv::Mat> batch_imgs;
std::vector <std::string> img_paths;
// for detection
std::vector<Detection::ObjectResult> det_result;
std::vector <Detection::ObjectResult> det_result;
std::vector<int> det_bbox_num;
// for vector search
std::vector<float> features;
......@@ -318,7 +320,7 @@ int main(int argc, char **argv) {
config.config_file["Global"]["cpu_num_threads"].as<int>();
int batch_size = config.config_file["Global"]["batch_size"].as<int>();
std::vector<int> shape =
config.config_file["Global"]["image_shape"].as<std::vector<int>>();
config.config_file["Global"]["image_shape"].as < std::vector < int >> ();
std::string det_shape = std::to_string(shape[0]);
for (int i = 1; i < shape.size(); ++i)
det_shape = det_shape + ", " + std::to_string(shape[i]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册