提交 52c9f16e 编写于 作者: M MissPenguin

add result comparison for det cpp_infer

上级 988afe1a
...@@ -91,7 +91,7 @@ int main_det(std::vector<cv::String> cv_all_img_names) { ...@@ -91,7 +91,7 @@ int main_det(std::vector<cv::String> cv_all_img_names) {
FLAGS_use_tensorrt, FLAGS_precision); FLAGS_use_tensorrt, FLAGS_precision);
for (int i = 0; i < cv_all_img_names.size(); ++i) { for (int i = 0; i < cv_all_img_names.size(); ++i) {
LOG(INFO) << "The predict img: " << cv_all_img_names[i]; // LOG(INFO) << "The predict img: " << cv_all_img_names[i];
cv::Mat srcimg = cv::imread(cv_all_img_names[i], cv::IMREAD_COLOR); cv::Mat srcimg = cv::imread(cv_all_img_names[i], cv::IMREAD_COLOR);
if (!srcimg.data) { if (!srcimg.data) {
...@@ -106,6 +106,16 @@ int main_det(std::vector<cv::String> cv_all_img_names) { ...@@ -106,6 +106,16 @@ int main_det(std::vector<cv::String> cv_all_img_names) {
time_info[0] += det_times[0]; time_info[0] += det_times[0];
time_info[1] += det_times[1]; time_info[1] += det_times[1];
time_info[2] += det_times[2]; time_info[2] += det_times[2];
if (FLAGS_benchmark) {
cout << cv_all_img_names[i] << '\t';
for (int n = 0; n < boxes.size(); n++) {
for (int m = 0; m < boxes[n].size(); m++) {
cout << boxes[n][m][0] << ' ' << boxes[n][m][1] << ' ';
}
}
cout << endl;
}
} }
if (FLAGS_benchmark) { if (FLAGS_benchmark) {
......
...@@ -32,7 +32,6 @@ def run_shell_command(cmd): ...@@ -32,7 +32,6 @@ def run_shell_command(cmd):
else: else:
return None return None
def parser_results_from_log_by_name(log_path, names_list): def parser_results_from_log_by_name(log_path, names_list):
if not os.path.exists(log_path): if not os.path.exists(log_path):
raise ValueError("The log file {} does not exists!".format(log_path)) raise ValueError("The log file {} does not exists!".format(log_path))
...@@ -46,11 +45,13 @@ def parser_results_from_log_by_name(log_path, names_list): ...@@ -46,11 +45,13 @@ def parser_results_from_log_by_name(log_path, names_list):
outs = run_shell_command(cmd) outs = run_shell_command(cmd)
outs = outs.split("\n")[0] outs = outs.split("\n")[0]
result = outs.split("{}".format(name))[-1] result = outs.split("{}".format(name))[-1]
result = json.loads(result) try:
result = json.loads(result)
except:
result = np.array([int(r) for r in result.split()]).reshape(-1, 4)
parser_results[name] = result parser_results[name] = result
return parser_results return parser_results
def load_gt_from_file(gt_file): def load_gt_from_file(gt_file):
if not os.path.exists(gt_file): if not os.path.exists(gt_file):
raise ValueError("The log file {} does not exists!".format(gt_file)) raise ValueError("The log file {} does not exists!".format(gt_file))
...@@ -60,7 +61,11 @@ def load_gt_from_file(gt_file): ...@@ -60,7 +61,11 @@ def load_gt_from_file(gt_file):
parser_gt = {} parser_gt = {}
for line in data: for line in data:
image_name, result = line.strip("\n").split("\t") image_name, result = line.strip("\n").split("\t")
result = json.loads(result) image_name = image_name.split('/')[-1]
try:
result = json.loads(result)
except:
result = np.array([int(r) for r in result.split()]).reshape(-1, 4)
parser_gt[image_name] = result parser_gt[image_name] = result
return parser_gt return parser_gt
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册