From 4a8fe0e57d750a38021b664634a3c1e563a27539 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Tue, 11 Feb 2020 08:56:23 +0100 Subject: [PATCH 1/3] add assert for min image size as segmentation does not work well if images are too low resolution. --- yolact.py | 1 + 1 file changed, 1 insertion(+) diff --git a/yolact.py b/yolact.py index d83703bb7..835a39b49 100644 --- a/yolact.py +++ b/yolact.py @@ -215,6 +215,7 @@ def make_priors(self, conv_h, conv_w, device): """ Note that priors are [x,y,width,height] where (x,y) is the center of the box. """ global prior_cache size = (conv_h, conv_w) + assert(cfg.max_size > 350),"Segmentation does not work with too low-res images. Try providing input images with size atleast 350pix." with timer.env('makepriors'): if self.last_img_size != (cfg._tmp_img_w, cfg._tmp_img_h): From cb43e4c685dc85048b747a726979188dd7a87eb7 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Sat, 16 May 2020 22:54:14 +0200 Subject: [PATCH 2/3] Revert "add assert for min image size" This reverts commit 4a8fe0e57d750a38021b664634a3c1e563a27539. --- yolact.py | 1 - 1 file changed, 1 deletion(-) diff --git a/yolact.py b/yolact.py index 835a39b49..d83703bb7 100644 --- a/yolact.py +++ b/yolact.py @@ -215,7 +215,6 @@ def make_priors(self, conv_h, conv_w, device): """ Note that priors are [x,y,width,height] where (x,y) is the center of the box. """ global prior_cache size = (conv_h, conv_w) - assert(cfg.max_size > 350),"Segmentation does not work with too low-res images. Try providing input images with size atleast 350pix." with timer.env('makepriors'): if self.last_img_size != (cfg._tmp_img_w, cfg._tmp_img_h): From 7a39a6031481f487a2015d63dd979b4af0fa3390 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Sat, 16 May 2020 22:58:39 +0200 Subject: [PATCH 3/3] move low-res warning to init make it a warning, checked in Yolact init() review feedback, thank you --- yolact.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yolact.py b/yolact.py index d83703bb7..f85eec520 100644 --- a/yolact.py +++ b/yolact.py @@ -470,6 +470,10 @@ def __init__(self): self.detect = Detect(cfg.num_classes, bkg_label=0, top_k=cfg.nms_top_k, conf_thresh=cfg.nms_conf_thresh, nms_thresh=cfg.nms_thresh) + # Warn on inappropriate parameters + if cfg.max_size < 350: + print("Segmentation does not work with too low-res images. Try providing input images with size atleast 350pix.") + def save_weights(self, path): """ Saves the model's weights using compression because the file sizes were getting too big. """ torch.save(self.state_dict(), path)