From 0468ec4e5a84986ae091beb0560f03df508622b3 Mon Sep 17 00:00:00 2001 From: tangyunxiang <546783735@qq.com> Date: Mon, 10 Jul 2023 21:13:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9FPS=E7=9A=84Time=E7=9A=84?= =?UTF-8?q?=E5=8F=96=E5=80=BC=E4=B8=AA=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../built-in/cv/detection/DB_ID0706_for_PyTorch/test/eval.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/test/eval.sh b/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/test/eval.sh index 2be1e64ba7..2847075f31 100644 --- a/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/test/eval.sh +++ b/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/test/eval.sh @@ -98,7 +98,7 @@ e2e_time=$(( $end_time - $start_time )) # 结果打印,不需要修改 echo "------------------ Final result ------------------" # 输出性能FPS,需要模型审视修改 -FPS=`grep -a 'Time' ${test_path_dir}/output/${ASCEND_DEVICE_ID}/test_${ASCEND_DEVICE_ID}.log | tail -n 10 | awk '{print$2}' | awk '{sum+=$1} END {print ('$batch_size')/(sum/NR)}'` +FPS=`grep -a 'Time' ${test_path_dir}/output/${ASCEND_DEVICE_ID}/test_${ASCEND_DEVICE_ID}.log | tail -n 1 | awk '{print$2}' | awk '{sum+=$1} END {print ('$batch_size')/(sum/NR)}'` FPS=${FPS#* } # 去除前面的空格字符 # 打印,不需要修改 echo "Final Performance images/sec : $FPS" -- Gitee From 38f382bc1425ef1d9880c45a92acd85d229d5643 Mon Sep 17 00:00:00 2001 From: tangyunxiang <546783735@qq.com> Date: Mon, 10 Jul 2023 21:14:08 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A1=E7=AE=97FPS?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E9=97=B4=E6=89=93=E7=82=B9=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py b/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py index ac379e530c..e88c2dae41 100644 --- a/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py +++ b/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py @@ -192,6 +192,7 @@ class Eval: with torch.no_grad(): for _, data_loader in self.data_loaders.items(): raw_metrics = [] + time_cost = time.time() for i, batch in tqdm(enumerate(data_loader.train_loader), total=len(data_loader.train_loader)): if self.args['test_speed']: time_cost = self.report_speed(model, batch, times=50) @@ -202,7 +203,7 @@ class Eval: if not os.path.isdir(self.args['result_dir']): os.mkdir(self.args['result_dir']) self.format_output(batch, output) - time_cost = (time.time() - start) + time_cost = min((time.time() - start), time_cost) print("Time:",time_cost) raw_metric = self.structure.measurer.validate_measure(batch, output, is_output_polygon=self.args['polygon'], box_thresh=self.args['box_thresh']) raw_metrics.append(raw_metric) @@ -211,6 +212,8 @@ class Eval: vis_image = self.structure.visualizer.visualize(batch, output, pred) self.logger.save_image_dict(vis_image) vis_images.update(vis_image) + if i == len(data_loader.train_loader) - 1: + print("Time:", time_cost) metrics = self.structure.measurer.gather_measure(raw_metrics, self.logger) for key, metric in metrics.items(): self.logger.info('%s : %f (%d)' % (key, metric.avg, metric.count)) -- Gitee From 7b3d72ef65de8192b35fa980edb43c85a5f88f44 Mon Sep 17 00:00:00 2001 From: tangyunxiang <546783735@qq.com> Date: Mon, 10 Jul 2023 21:18:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A7=E7=9A=84?= =?UTF-8?q?=E8=80=97=E6=97=B6=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py | 1 - 1 file changed, 1 deletion(-) diff --git a/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py b/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py index e88c2dae41..32aa1fbde5 100644 --- a/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py +++ b/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py @@ -204,7 +204,6 @@ class Eval: os.mkdir(self.args['result_dir']) self.format_output(batch, output) time_cost = min((time.time() - start), time_cost) - print("Time:",time_cost) raw_metric = self.structure.measurer.validate_measure(batch, output, is_output_polygon=self.args['polygon'], box_thresh=self.args['box_thresh']) raw_metrics.append(raw_metric) -- Gitee From 29f53c1e3d7f0f07e7534c8e1107237052c14e2f Mon Sep 17 00:00:00 2001 From: tangyunxiang <546783735@qq.com> Date: Mon, 10 Jul 2023 22:11:55 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9time=5Fcost=E7=9A=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=8F=AF=E8=83=BD=E9=80=A0=E6=88=90=E7=9A=84?= =?UTF-8?q?=E6=AD=A7=E4=B9=89=EF=BC=8C=E5=B0=86=E5=85=B6=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=80=BC=E5=AE=9A=E4=B9=89=E4=B8=BAint32=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py b/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py index 32aa1fbde5..88ec8c8915 100644 --- a/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py +++ b/PyTorch/built-in/cv/detection/DB_ID0706_for_PyTorch/eval.py @@ -17,6 +17,7 @@ #!python3 import argparse import os +import sys import torch if torch.__version__ >= "1.8": import torch_npu @@ -192,7 +193,7 @@ class Eval: with torch.no_grad(): for _, data_loader in self.data_loaders.items(): raw_metrics = [] - time_cost = time.time() + time_cost = sys.maxsize for i, batch in tqdm(enumerate(data_loader.train_loader), total=len(data_loader.train_loader)): if self.args['test_speed']: time_cost = self.report_speed(model, batch, times=50) -- Gitee