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

fix indexerror for retinanet in torch1.x #135

Open
wants to merge 1 commit into
base: torch1x
Choose a base branch
from
Open
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
fix indexerror for retinanet in torch1.x
`keep_ix / fg_probs.shape[1]` returns a float tensor  which can not be used as index with torch 1.x.
  • Loading branch information
alibool committed Mar 14, 2022
commit ad1c871bea02f3da5b4ed0955bb17983e58493ca
2 changes: 1 addition & 1 deletion models/retina_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def refine_detections(anchors, probs, deltas, batch_ixs, cf):
flat_probs, flat_probs_order = fg_probs.view(-1).sort(descending=True)
keep_ix = flat_probs_order[:cf.pre_nms_limit]
# reshape indices to 2D index array with shape like fg_probs.
keep_arr = torch.cat(((keep_ix / fg_probs.shape[1]).unsqueeze(1), (keep_ix % fg_probs.shape[1]).unsqueeze(1)), 1)
keep_arr = torch.cat(((keep_ix // fg_probs.shape[1]).unsqueeze(1), (keep_ix % fg_probs.shape[1]).unsqueeze(1)), 1)

pre_nms_scores = flat_probs[:cf.pre_nms_limit]
pre_nms_class_ids = keep_arr[:, 1] + 1 # add background again.
Expand Down