From 5f1415723565358a1ad6a053942e2ae85b927df9 Mon Sep 17 00:00:00 2001 From: LokeZhou Date: Mon, 16 Jan 2023 19:58:28 +0800 Subject: [PATCH] pr develop (#5703) * fix PP-HumanV2 PP-Vehicle Single choice bug * add PP-TinyPose model file * modified PP-TinyPose auto download model * del modelcenter/PP-TinyPose/APP/output_inference/ * add PP-TinyPose PP-HumanV2 PP-Vehicle video format checks * fix PP-HumanV2 PP-TinyPose PP-Vehicle video adaptive code --- modelcenter/PP-HumanV2/APP/pipeline/pipeline.py | 9 ++++----- .../PP-TinyPose/APP/det_keypoint_unite_infer.py | 12 ++++++------ modelcenter/PP-Vehicle/APP/pipeline/pipeline.py | 9 ++++----- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/modelcenter/PP-HumanV2/APP/pipeline/pipeline.py b/modelcenter/PP-HumanV2/APP/pipeline/pipeline.py index 2aa69c8f..cdb28a92 100644 --- a/modelcenter/PP-HumanV2/APP/pipeline/pipeline.py +++ b/modelcenter/PP-HumanV2/APP/pipeline/pipeline.py @@ -389,8 +389,7 @@ class PipePredictor(object): def set_file_name(self, path): if path is not None: - if "." in path: - self.file_name = path.split(".")[-2] + self.file_name = path else: # use camera id self.file_name = None @@ -446,9 +445,9 @@ class PipePredictor(object): frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT)) print("video fps: %d, frame_count: %d" % (fps, frame_count)) - video_out_name = 'output' if self.file_name is None else self.file_name - out_path = video_out_name + "_output.mp4" - fourcc = cv2.VideoWriter_fourcc(*'mp4v') + video_name,suffix = os.path.splitext(self.file_name) + out_path = video_name + "_output"+suffix + fourcc = int(capture.get(cv2.CAP_PROP_FOURCC)) writer = cv2.VideoWriter(out_path, fourcc, fps, (width, height)) frame_id = 0 diff --git a/modelcenter/PP-TinyPose/APP/det_keypoint_unite_infer.py b/modelcenter/PP-TinyPose/APP/det_keypoint_unite_infer.py index a5178cce..9e058e86 100644 --- a/modelcenter/PP-TinyPose/APP/det_keypoint_unite_infer.py +++ b/modelcenter/PP-TinyPose/APP/det_keypoint_unite_infer.py @@ -107,18 +107,18 @@ def topdown_unite_predict_video(FLAGS, capture = cv2.VideoCapture(camera_id) else: capture = cv2.VideoCapture(FLAGS.video_file) - video_name,suffix = FLAGS.video_file.split('.') - video_name = video_name+"_output."+suffix + video_name,suffix = os.path.splitext(FLAGS.video_file) + video_name = video_name+"_output"+suffix + # Get Video info : resolution, fps, frame count width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) fps = int(capture.get(cv2.CAP_PROP_FPS)) frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT)) print("fps: %d, frame_count: %d" % (fps, frame_count)) - - - fourcc = cv2.VideoWriter_fourcc(* 'mp4v') - writer = cv2.VideoWriter(video_name, fourcc, fps, (width, height)) + + codec = int(capture.get(cv2.CAP_PROP_FOURCC)) + writer = cv2.VideoWriter(video_name, codec, fps, (width, height)) index = 0 store_res = [] keypoint_smoothing = KeypointSmoothing( diff --git a/modelcenter/PP-Vehicle/APP/pipeline/pipeline.py b/modelcenter/PP-Vehicle/APP/pipeline/pipeline.py index 124a8a6d..eb568175 100644 --- a/modelcenter/PP-Vehicle/APP/pipeline/pipeline.py +++ b/modelcenter/PP-Vehicle/APP/pipeline/pipeline.py @@ -329,8 +329,7 @@ class PipePredictor(object): def set_file_name(self, path): if path is not None: - if "." in path: - self.file_name = path.split(".")[-2] + self.file_name = path else: # use camera id self.file_name = None @@ -397,9 +396,9 @@ class PipePredictor(object): frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT)) print("video fps: %d, frame_count: %d" % (fps, frame_count)) - video_out_name = 'output' if self.file_name is None else self.file_name - out_path = video_out_name + "_output.mp4" - fourcc = cv2.VideoWriter_fourcc(*'mp4v') + video_name,suffix = os.path.splitext(self.file_name) + out_path = video_name + "_output"+suffix + fourcc = int(capture.get(cv2.CAP_PROP_FOURCC)) writer = cv2.VideoWriter(out_path, fourcc, fps, (width, height)) frame_id = 0 -- GitLab