Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed fcos demo score threshold bugs #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions adet/modeling/fcos/fcos_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,15 @@ def forward_for_single_feature_map(
# if self.thresh_with_ctr is True, we multiply the classification
# scores with centerness scores before applying the threshold.
if self.thresh_with_ctr:
box_cls = box_cls * ctrness[:, :, None]
# sqrt is used to calibrate the scores, which does not affect the COCO AP.
box_cls = torch.sqrt(box_cls * ctrness[:, :, None])
candidate_inds = box_cls > self.pre_nms_thresh
pre_nms_top_n = candidate_inds.view(N, -1).sum(1)
pre_nms_top_n = pre_nms_top_n.clamp(max=self.pre_nms_top_n)

if not self.thresh_with_ctr:
box_cls = box_cls * ctrness[:, :, None]
# sqrt is used to calibrate the scores, which does not affect the COCO AP.
box_cls = torch.sqrt(box_cls * ctrness[:, :, None])

results = []
for i in range(N):
Expand Down Expand Up @@ -473,7 +475,7 @@ def forward_for_single_feature_map(

boxlist = Instances(image_sizes[i])
boxlist.pred_boxes = Boxes(detections)
boxlist.scores = torch.sqrt(per_box_cls)
boxlist.scores = per_box_cls
boxlist.pred_classes = per_class
boxlist.locations = per_locations
if top_feat is not None:
Expand Down
1 change: 1 addition & 0 deletions demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def setup_cfg(args):
cfg.MODEL.RETINANET.SCORE_THRESH_TEST = args.confidence_threshold
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = args.confidence_threshold
cfg.MODEL.FCOS.INFERENCE_TH_TEST = args.confidence_threshold
cfg.MODEL.FCOS.THRESH_WITH_CTR = True
cfg.MODEL.PANOPTIC_FPN.COMBINE.INSTANCES_CONFIDENCE_THRESH = args.confidence_threshold
cfg.freeze()
return cfg
Expand Down