Skip to content

Instantly share code, notes, and snippets.

@arunm8489
Last active June 5, 2020 05:28
Show Gist options
  • Select an option

  • Save arunm8489/af81a9cf8e6ecabba6b8bf45ca968384 to your computer and use it in GitHub Desktop.

Select an option

Save arunm8489/af81a9cf8e6ecabba6b8bf45ca968384 to your computer and use it in GitHub Desktop.
for i in range(idx):
#Get the IOUs of all boxes that come after the one we are looking at the loop
try:
ious = bounding_box_iou(image_pred_class[i].unsqueeze(0), image_pred_class[i+1:])
except ValueError:
break
except IndexError:
break
#Zero out all the detections that have IoU > treshhold
iou_mask = (ious < nms_conf).float().unsqueeze(1)
image_pred_class[i+1:] *= iou_mask
#Remove the non-zero entries
non_zero_ind = torch.nonzero(image_pred_class[:,4]).squeeze()
image_pred_class = image_pred_class[non_zero_ind].view(-1,7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment