From cf7b3d4b5adcb2ce1773b424f65dd452eae68aeb Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 1 Nov 2024 19:53:17 -0400 Subject: [PATCH] fix detailer min/max calculations Signed-off-by: Vladimir Mandic --- modules/postprocess/yolo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/postprocess/yolo.py b/modules/postprocess/yolo.py index 44c7db20c..cabb4468f 100644 --- a/modules/postprocess/yolo.py +++ b/modules/postprocess/yolo.py @@ -128,9 +128,9 @@ class YoloRestorer(Detailer): mask_image = None w, h = box[2] - box[0], box[3] - box[1] size = w * h / (image.width * image.height) - min_size = (shared.opts.detailer_min_size if shared.opts.detailer_min_size > 0 else 0) * min(w, h) - max_size = (shared.opts.detailer_max_size if shared.opts.detailer_max_size > 0 else 1) * max(w, h) - if (min(w, h) > min_size) and (max(w, h) < max_size): + min_size = (shared.opts.detailer_min_size if shared.opts.detailer_min_size > 0 and shared.opts.detailer_min_size < 1 else 0) * min(w, h) + max_size = (shared.opts.detailer_max_size if shared.opts.detailer_max_size > 0 and shared.opts.detailer_min_size < 1 else 1) * max(w, h) + if (min(w, h) >= int(min_size)) and (max(w, h) <= int(max_size)): if mask: mask_image = image.copy() mask_image = Image.new('L', image.size, 0)