I used Google Colab tutorial, changed instance segmentation model to object detection like this:
cfg = get_cfg()
cfg.merge_from_file("./detectron2_repo/configs/COCO-Detection/retinanet_R_101_FPN_3x.yaml")
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5 # set threshold for this model
# Find a model from detectron2's model zoo. You can either use the https://dl.fbaipublicfiles.... url, or use the following shorthand
cfg.MODEL.WEIGHTS = "detectron2://COCO-Detection/retinanet_R_101_FPN_3x/138363263/model_final_59f53c.pkl"
predictor = DefaultPredictor(cfg)
outputs = predictor(im)
As you can see cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5 but threshold doesn't work:

Am I doing something wrong? Thanks.
RetinaNet by its definition does not have ROI_HEADS. You need to use cfg.MODEL.RETINANET.SCORE_THRESH_TEST.
The official demo script handles this more properly:
https://github.com/facebookresearch/detectron2/blob/d250fcc1b66d5a3686c15144480441b7abe31dec/demo/demo.py#L23-L25
Hey,
how do I set the threshold for 'tensormask_R_50_FPN_6x.yaml' ?
I tried cfg.MODEL.RETINANET.SCORE_THRESH_TEST = 0.5 and / or cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5 with no luck. I can't find any documentation for that.
Thanks
UPDATE: after a closer look at the object returned by get_cfg(), I found out that cfg.MODEL.TENSOR_MASK.SCORE_THRESH_TEST = 0.5 did the job for me.
Most helpful comment
RetinaNet by its definition does not have
ROI_HEADS. You need to usecfg.MODEL.RETINANET.SCORE_THRESH_TEST.The official demo script handles this more properly:
https://github.com/facebookresearch/detectron2/blob/d250fcc1b66d5a3686c15144480441b7abe31dec/demo/demo.py#L23-L25