From ec79a4af7b571419e7f2fed80cc3e9e9de12064c Mon Sep 17 00:00:00 2001 From: LokeZhou Date: Tue, 14 Feb 2023 15:55:30 +0800 Subject: [PATCH] [Pipeline] fix import Sequence for python 3.10 (#7739) (#7756) --- deploy/pipeline/docs/tutorials/ppvehicle_retrograde.md | 5 +++-- deploy/pipeline/docs/tutorials/ppvehicle_retrograde_en.md | 5 +++-- deploy/pipeline/pipeline.py | 6 +++++- deploy/pipeline/pphuman/action_infer.py | 5 ++++- deploy/pipeline/pphuman/video_action_infer.py | 5 ++++- deploy/pipeline/pphuman/video_action_preprocess.py | 5 ++++- deploy/pipeline/ppvehicle/vehicle_attr.py | 5 ++++- 7 files changed, 27 insertions(+), 9 deletions(-) diff --git a/deploy/pipeline/docs/tutorials/ppvehicle_retrograde.md b/deploy/pipeline/docs/tutorials/ppvehicle_retrograde.md index 57ba922ff..8f229d16a 100644 --- a/deploy/pipeline/docs/tutorials/ppvehicle_retrograde.md +++ b/deploy/pipeline/docs/tutorials/ppvehicle_retrograde.md @@ -72,7 +72,7 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppv #预测包含一个或多个视频的文件夹 python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppvehicle.yml \ -o VEHICLE_RETROGRADE.enable=true \ - --video_dir=test_video.mp4\ + --video_dir=test_video \ --device=gpu ``` @@ -97,7 +97,8 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppv **注意:** - 车道线中间线自动判断条件:在采样的视频段内同时有两个相反方向的车辆,且判断一次后固定,不再更新; - - 因摄像头角度以及2d视角问题,车道线中间线判断存在不准确情况,可在配置文件手动输入中间线坐标 + - 因摄像头角度以及2d视角问题,车道线中间线判断存在不准确情况; + - 可在配置文件手动输入中间线坐标.参考[车辆违章配置文件](../../config/examples/infer_cfg_vehicle_violation.yml) ## 方案说明 diff --git a/deploy/pipeline/docs/tutorials/ppvehicle_retrograde_en.md b/deploy/pipeline/docs/tutorials/ppvehicle_retrograde_en.md index 457f84bfa..650efe199 100644 --- a/deploy/pipeline/docs/tutorials/ppvehicle_retrograde_en.md +++ b/deploy/pipeline/docs/tutorials/ppvehicle_retrograde_en.md @@ -70,7 +70,7 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppv #For folder contains one or multiple videos python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppvehicle.yml \ -o VEHICLE_RETROGRADE.enable=true \ - --video_dir=test_video.mp4\ + --video_dir=test_video \ --device=gpu ``` @@ -95,7 +95,8 @@ The result is shown as follow: **Note:** - Automatic judgment condition of lane line middle line: there are two vehicles in opposite directions in the sampled video segment, and the judgment is fixed after one time and will not be updated; - - Due to camera angle and 2d visual angle problems, the judgment of lane line middle line is inaccurate. You can manually enter the middle line coordinates in the configuration file + - Due to camera angle and 2d visual angle problems, the judgment of lane line middle line is inaccurate. + - You can manually enter the middle line coordinates in the configuration file.Example as [infer_cfg_vehicle_violation.yml](../../config/examples/infer_cfg_vehicle_violation.yml) ## Features to the Solution diff --git a/deploy/pipeline/pipeline.py b/deploy/pipeline/pipeline.py index 04fcfc28b..3407f479e 100644 --- a/deploy/pipeline/pipeline.py +++ b/deploy/pipeline/pipeline.py @@ -24,8 +24,12 @@ import copy import threading import queue import time -from collections import Sequence, defaultdict +from collections import defaultdict from datacollector import DataCollector, Result +try: + from collections.abc import Sequence +except Exception: + from collections import Sequence # add deploy path of PaddleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) diff --git a/deploy/pipeline/pphuman/action_infer.py b/deploy/pipeline/pphuman/action_infer.py index b04bd3f88..45c04ad51 100644 --- a/deploy/pipeline/pphuman/action_infer.py +++ b/deploy/pipeline/pphuman/action_infer.py @@ -21,7 +21,10 @@ import numpy as np import math import paddle import sys -from collections import Sequence +try: + from collections.abc import Sequence +except Exception: + from collections import Sequence # add deploy path of PaddleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) diff --git a/deploy/pipeline/pphuman/video_action_infer.py b/deploy/pipeline/pphuman/video_action_infer.py index e5e6c10ec..6a10355f3 100644 --- a/deploy/pipeline/pphuman/video_action_infer.py +++ b/deploy/pipeline/pphuman/video_action_infer.py @@ -21,8 +21,11 @@ import numpy as np import math import paddle import sys -from collections import Sequence import paddle.nn.functional as F +try: + from collections.abc import Sequence +except Exception: + from collections import Sequence # add deploy path of PaddleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) diff --git a/deploy/pipeline/pphuman/video_action_preprocess.py b/deploy/pipeline/pphuman/video_action_preprocess.py index f6f9f11f7..eccec048d 100644 --- a/deploy/pipeline/pphuman/video_action_preprocess.py +++ b/deploy/pipeline/pphuman/video_action_preprocess.py @@ -14,9 +14,12 @@ import cv2 import numpy as np -from collections.abc import Sequence from PIL import Image import paddle +try: + from collections.abc import Sequence +except Exception: + from collections import Sequence class Sampler(object): diff --git a/deploy/pipeline/ppvehicle/vehicle_attr.py b/deploy/pipeline/ppvehicle/vehicle_attr.py index 4f7923f61..eb1b9423b 100644 --- a/deploy/pipeline/ppvehicle/vehicle_attr.py +++ b/deploy/pipeline/ppvehicle/vehicle_attr.py @@ -21,7 +21,10 @@ import numpy as np import math import paddle import sys -from collections import Sequence +try: + from collections.abc import Sequence +except Exception: + from collections import Sequence # add deploy path of PaddleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) -- GitLab