From d4978b8a4a2f60727e2005b715045ef23d1c7084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=B7=E5=AE=87=E4=BD=B3?= Date: Wed, 19 Feb 2025 16:23:43 +0800 Subject: [PATCH] =?UTF-8?q?PERF=20=E4=BF=AE=E6=94=B9=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=88=87=E7=89=87=E9=95=BF=E5=BA=A6=E4=B8=BA=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 2 +- test_single_image.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 5ad79cf..f9b0f90 100644 --- a/__init__.py +++ b/__init__.py @@ -54,7 +54,7 @@ class FaceDetect: config = {"start": start, "end": end} else: raise RuntimeError("未找到符合要求的视频片段") - return (image, image_selected, cls, prob, nums, str(period), json.dumps(config), start, end - start) + return (image, image_selected, cls, prob, nums, str(period), json.dumps(config), start, end - start+1) class FaceExtract: diff --git a/test_single_image.py b/test_single_image.py index cb18d47..b533de0 100644 --- a/test_single_image.py +++ b/test_single_image.py @@ -96,7 +96,13 @@ def test_node(image:torch.Tensor,length=10,thres=95,model_name="convnext_tiny"): end = nums[idx] if end - start + 1 >= length: period.append([start, end]) - return (image.permute(0,2,3,1), image.permute(0,2,3,1)[nums,:,:,:], str(preds), str(probs), str(nums), period) + temp_period = [] + for i in period: + a = i[0] + while a+length-1 <= i[1]: + temp_period.append([a,a+length-1]) + a = a+length + return (image.permute(0,2,3,1), image.permute(0,2,3,1)[nums,:,:,:], str(preds), str(probs), str(nums), temp_period)