未验证 提交 55d8af94 编写于 作者: S Shuangchi He 提交者: GitHub

[cherry-pick] `Fix some typos for Jetson, metrics and result` from...

[cherry-pick] `Fix some typos for Jetson, metrics and result` from release/2.4-typos2 branch and merge. (#6119)

* [cherry-pick] Fix some typos for Jetson, metrics and result from release/2.4-typos2 branch and merge.
上级 e03e52a2
...@@ -809,7 +809,7 @@ plt.imshow(img) ...@@ -809,7 +809,7 @@ plt.imshow(img)
``` ```
fout.write(img_path + "\t" + json.dumps( fout.write(img_path + "\t" + json.dumps(
{ {
"ser_resule": result, "ser_result": result,
}, ensure_ascii=False) + "\n") }, ensure_ascii=False) + "\n")
``` ```
......
...@@ -246,7 +246,7 @@ class MyMetric(object): ...@@ -246,7 +246,7 @@ class MyMetric(object):
def get_metric(self): def get_metric(self):
""" """
return metircs { return metrics {
'acc': 0, 'acc': 0,
'norm_edit_dis': 0, 'norm_edit_dis': 0,
} }
......
...@@ -237,7 +237,7 @@ class MyMetric(object): ...@@ -237,7 +237,7 @@ class MyMetric(object):
def get_metric(self): def get_metric(self):
""" """
return metircs { return metrics {
'acc': 0, 'acc': 0,
'norm_edit_dis': 0, 'norm_edit_dis': 0,
} }
......
...@@ -1876,11 +1876,11 @@ ...@@ -1876,11 +1876,11 @@
" rec_res)\n", " rec_res)\n",
" filter_boxes, filter_rec_res = [], []\n", " filter_boxes, filter_rec_res = [], []\n",
" # 根据识别得分的阈值对结果进行过滤,如果得分小于阈值,就过滤掉\n", " # 根据识别得分的阈值对结果进行过滤,如果得分小于阈值,就过滤掉\n",
" for box, rec_reuslt in zip(dt_boxes, rec_res):\n", " for box, rec_result in zip(dt_boxes, rec_res):\n",
" text, score = rec_reuslt\n", " text, score = rec_result\n",
" if score >= self.drop_score:\n", " if score >= self.drop_score:\n",
" filter_boxes.append(box)\n", " filter_boxes.append(box)\n",
" filter_rec_res.append(rec_reuslt)\n", " filter_rec_res.append(rec_result)\n",
" return filter_boxes, filter_rec_res\n", " return filter_boxes, filter_rec_res\n",
"\n", "\n",
"def sorted_boxes(dt_boxes):\n", "def sorted_boxes(dt_boxes):\n",
...@@ -1886,11 +1886,11 @@ ...@@ -1886,11 +1886,11 @@
" rec_res)\n", " rec_res)\n",
" filter_boxes, filter_rec_res = [], []\n", " filter_boxes, filter_rec_res = [], []\n",
" #Filter the results according to the threshold of the recognition score, if the score is less than the threshold, filter out\n", " #Filter the results according to the threshold of the recognition score, if the score is less than the threshold, filter out\n",
" for box, rec_reuslt in zip(dt_boxes, rec_res):\n", " for box, rec_result in zip(dt_boxes, rec_res):\n",
" text, score = rec_reuslt\n", " text, score = rec_result\n",
" if score >= self.drop_score:\n", " if score >= self.drop_score:\n",
" filter_boxes.append(box)\n", " filter_boxes.append(box)\n",
" filter_rec_res.append(rec_reuslt)\n", " filter_rec_res.append(rec_result)\n",
" return filter_boxes, filter_rec_res\n", " return filter_boxes, filter_rec_res\n",
"\n", "\n",
"def sorted_boxes(dt_boxes):\n", "def sorted_boxes(dt_boxes):\n",
...@@ -64,9 +64,9 @@ class DetMetric(object): ...@@ -64,9 +64,9 @@ class DetMetric(object):
} }
""" """
metircs = self.evaluator.combine_results(self.results) metrics = self.evaluator.combine_results(self.results)
self.reset() self.reset()
return metircs return metrics
def reset(self): def reset(self):
self.results = [] # clear results self.results = [] # clear results
...@@ -127,20 +127,20 @@ class DetFCEMetric(object): ...@@ -127,20 +127,20 @@ class DetFCEMetric(object):
'thr 0.9':'precision: 0 recall: 0 hmean: 0', 'thr 0.9':'precision: 0 recall: 0 hmean: 0',
} }
""" """
metircs = {} metrics = {}
hmean = 0 hmean = 0
for score_thr in self.results.keys(): for score_thr in self.results.keys():
metirc = self.evaluator.combine_results(self.results[score_thr]) metric = self.evaluator.combine_results(self.results[score_thr])
# for key, value in metirc.items(): # for key, value in metric.items():
# metircs['{}_{}'.format(key, score_thr)] = value # metrics['{}_{}'.format(key, score_thr)] = value
metirc_str = 'precision:{:.5f} recall:{:.5f} hmean:{:.5f}'.format( metric_str = 'precision:{:.5f} recall:{:.5f} hmean:{:.5f}'.format(
metirc['precision'], metirc['recall'], metirc['hmean']) metric['precision'], metric['recall'], metric['hmean'])
metircs['thr {}'.format(score_thr)] = metirc_str metrics['thr {}'.format(score_thr)] = metric_str
hmean = max(hmean, metirc['hmean']) hmean = max(hmean, metric['hmean'])
metircs['hmean'] = hmean metrics['hmean'] = hmean
self.reset() self.reset()
return metircs return metrics
def reset(self): def reset(self):
self.results = { self.results = {
......
...@@ -78,9 +78,9 @@ class E2EMetric(object): ...@@ -78,9 +78,9 @@ class E2EMetric(object):
self.results.append(result) self.results.append(result)
def get_metric(self): def get_metric(self):
metircs = combine_results(self.results) metrics = combine_results(self.results)
self.reset() self.reset()
return metircs return metrics
def reset(self): def reset(self):
self.results = [] # clear results self.results = [] # clear results
...@@ -61,9 +61,9 @@ class KIEMetric(object): ...@@ -61,9 +61,9 @@ class KIEMetric(object):
def get_metric(self): def get_metric(self):
metircs = self.combine_results(self.results) metrics = self.combine_results(self.results)
self.reset() self.reset()
return metircs return metrics
def reset(self): def reset(self):
self.results = [] # clear results self.results = [] # clear results
......
...@@ -34,13 +34,13 @@ class VQASerTokenMetric(object): ...@@ -34,13 +34,13 @@ class VQASerTokenMetric(object):
def get_metric(self): def get_metric(self):
from seqeval.metrics import f1_score, precision_score, recall_score from seqeval.metrics import f1_score, precision_score, recall_score
metircs = { metrics = {
"precision": precision_score(self.gt_list, self.pred_list), "precision": precision_score(self.gt_list, self.pred_list),
"recall": recall_score(self.gt_list, self.pred_list), "recall": recall_score(self.gt_list, self.pred_list),
"hmean": f1_score(self.gt_list, self.pred_list), "hmean": f1_score(self.gt_list, self.pred_list),
} }
self.reset() self.reset()
return metircs return metrics
def reset(self): def reset(self):
self.pred_list = [] self.pred_list = []
......
# Jeston端基础训练预测功能测试 # Jetson端基础训练预测功能测试
Jeston端基础训练预测功能测试的主程序为`test_inference_inference.sh`,由于Jeston端CPU较差,Jeston只需要测试TIPC关于GPU和TensorRT预测推理的部分即可。 Jetson端基础训练预测功能测试的主程序为`test_inference_inference.sh`,由于Jetson端CPU较差,Jetson只需要测试TIPC关于GPU和TensorRT预测推理的部分即可。
## 1. 测试结论汇总 ## 1. 测试结论汇总
...@@ -42,7 +42,7 @@ Jeston端基础训练预测功能测试的主程序为`test_inference_inference. ...@@ -42,7 +42,7 @@ Jeston端基础训练预测功能测试的主程序为`test_inference_inference.
先运行`prepare.sh`准备数据和模型,然后运行`test_inference_inference.sh`进行测试,最终在```test_tipc/output```目录下生成`python_infer_*.log`格式的日志文件。 先运行`prepare.sh`准备数据和模型,然后运行`test_inference_inference.sh`进行测试,最终在```test_tipc/output```目录下生成`python_infer_*.log`格式的日志文件。
`test_inference_inference.sh`仅有一个模式`whole_infer`,在Jeston端,仅需要测试预测推理的模式即可: `test_inference_inference.sh`仅有一个模式`whole_infer`,在Jetson端,仅需要测试预测推理的模式即可:
``` ```
- 模式3:whole_infer,不训练,全量数据预测,走通开源模型评估、动转静,检查inference model预测时间和精度; - 模式3:whole_infer,不训练,全量数据预测,走通开源模型评估、动转静,检查inference model预测时间和精度;
...@@ -51,7 +51,7 @@ bash test_tipc/prepare.sh ./test_tipc/configs/ch_ppocr_mobile_v2.0_det/model_lin ...@@ -51,7 +51,7 @@ bash test_tipc/prepare.sh ./test_tipc/configs/ch_ppocr_mobile_v2.0_det/model_lin
# 用法1: # 用法1:
bash test_tipc/test_inference_inference.sh ./test_tipc/configs/ch_ppocr_mobile_v2.0_det/model_linux_gpu_normal_normal_infer_python_jetson.txt 'whole_infer' bash test_tipc/test_inference_inference.sh ./test_tipc/configs/ch_ppocr_mobile_v2.0_det/model_linux_gpu_normal_normal_infer_python_jetson.txt 'whole_infer'
# 用法2: 指定GPU卡预测,第三个传入参数为GPU卡号 # 用法2: 指定GPU卡预测,第三个传入参数为GPU卡号
bash test_tipc/test_inference_jeston.sh ./test_tipc/configs/ch_ppocr_mobile_v2.0_det/model_linux_gpu_normal_normal_infer_python_jetson.txt 'whole_infer' '1' bash test_tipc/test_inference_jetson.sh ./test_tipc/configs/ch_ppocr_mobile_v2.0_det/model_linux_gpu_normal_normal_infer_python_jetson.txt 'whole_infer' '1'
``` ```
运行相应指令后,在`test_tipc/output`文件夹下自动会保存运行日志。如`whole_infer`模式下,会运行训练+inference的链条,因此,在`test_tipc/output`文件夹有以下文件: 运行相应指令后,在`test_tipc/output`文件夹下自动会保存运行日志。如`whole_infer`模式下,会运行训练+inference的链条,因此,在`test_tipc/output`文件夹有以下文件:
......
...@@ -193,7 +193,7 @@ def create_predictor(args, mode, logger): ...@@ -193,7 +193,7 @@ def create_predictor(args, mode, logger):
gpu_id = get_infer_gpuid() gpu_id = get_infer_gpuid()
if gpu_id is None: if gpu_id is None:
logger.warning( logger.warning(
"GPU is not found in current device by nvidia-smi. Please check your device or ignore it if run on jeston." "GPU is not found in current device by nvidia-smi. Please check your device or ignore it if run on jetson."
) )
config.enable_use_gpu(args.gpu_mem, 0) config.enable_use_gpu(args.gpu_mem, 0)
if args.use_tensorrt: if args.use_tensorrt:
......
...@@ -104,7 +104,7 @@ def main(): ...@@ -104,7 +104,7 @@ def main():
preds = model(images) preds = model(images)
post_result = post_process_class(preds, shape_list) post_result = post_process_class(preds, shape_list)
points, strs = post_result['points'], post_result['texts'] points, strs = post_result['points'], post_result['texts']
# write resule # write result
dt_boxes_json = [] dt_boxes_json = []
for poly, str in zip(points, strs): for poly, str in zip(points, strs):
tmp_json = {"transcription": str} tmp_json = {"transcription": str}
......
...@@ -193,7 +193,7 @@ if __name__ == '__main__': ...@@ -193,7 +193,7 @@ if __name__ == '__main__':
result = result[0] result = result[0]
fout.write(img_path + "\t" + json.dumps( fout.write(img_path + "\t" + json.dumps(
{ {
"ser_resule": result, "ser_result": result,
}, ensure_ascii=False) + "\n") }, ensure_ascii=False) + "\n")
img_res = draw_re_results(img_path, result) img_res = draw_re_results(img_path, result)
cv2.imwrite(save_img_path, img_res) cv2.imwrite(save_img_path, img_res)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册