From 8c90c6cc32bdc9c16801b0d2848467f5c9b42cd9 Mon Sep 17 00:00:00 2001 From: David Lin Date: Mon, 28 Sep 2020 13:36:37 +0800 Subject: [PATCH] Ignore previous prediction outputs Ignore files that ends with _mask and _result. This way previous prediction results won't be predicted again. The changes have passed my local checks. --- deploy/python/infer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deploy/python/infer.py b/deploy/python/infer.py index e1d885d2..b423f5c2 100644 --- a/deploy/python/infer.py +++ b/deploy/python/infer.py @@ -59,12 +59,16 @@ trt_precision_map = { } -# scan a directory and get all images with support extensions +# scan a directory and get all images with support extensions(will ignore *_mask.* and *_result.*) def get_images_from_dir(img_dir, support_ext=".jpg|.jpeg"): if (not os.path.exists(img_dir) or not os.path.isdir(img_dir)): raise Exception("Image Directory [%s] invalid" % img_dir) imgs = [] for item in os.listdir(img_dir): + name, ext = os.path.splitext(item) + ext = ext[1:].strip().lower() + if name.endswith("_mask") or name.endswith("_result"): + continue ext = os.path.splitext(item)[1][1:].strip().lower() if (len(ext) > 0 and ext in support_ext): item_path = os.path.join(img_dir, item) -- GitLab