From 69aceaa33afaa9e3461e8dcb19bedb29ebfb275c Mon Sep 17 00:00:00 2001 From: Arnesh1411 <86571275+Arnesh1411@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:18:31 +0530 Subject: [PATCH] Update detectron2.py I have added these two lines which helps load the added new keys in the config.yaml file. Without this line some error may arise like " KeyError: 'Non-existent config key: MODEL.SCORE_THRESH_TEST' " . For more details read here https://github.com/facebookresearch/detectron2/issues/5111 --- sahi/models/detectron2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sahi/models/detectron2.py b/sahi/models/detectron2.py index e8ce35d98..c79940f03 100644 --- a/sahi/models/detectron2.py +++ b/sahi/models/detectron2.py @@ -28,11 +28,13 @@ def load_model(self): try: # try to load from model zoo config_file = model_zoo.get_config_file(self.config_path) + cfg.set_new_allowed(True) cfg.merge_from_file(config_file) cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url(self.config_path) except Exception as e: # try to load from local print(e) if self.config_path is not None: + cfg.set_new_allowed(True) cfg.merge_from_file(self.config_path) cfg.MODEL.WEIGHTS = self.model_path