Detectron2: Threshold for object detection

Created on 13 Oct 2019  路  2Comments  路  Source: facebookresearch/detectron2

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:

image

Am I doing something wrong? Thanks.

Most helpful comment

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

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aminekechaou picture aminekechaou  路  3Comments

kl720 picture kl720  路  3Comments

invisprints picture invisprints  路  4Comments

wytcsuch picture wytcsuch  路  4Comments

RomRoc picture RomRoc  路  4Comments