Skip to content

object-detector/object-detector/nms.py #22

@thomberg1

Description

@thomberg1
for index, detection in enumerate(detections):
        for new_detection in new_detections:
            if overlapping_area(detection, new_detection) > threshold:
                del detections[index]
                break
        else:
            new_detections.append(detection)
            del detections[index]

changes to iterator will not work - nms produces:

detections = [[10, 10, .12, 10, 10], [50, 50, .8,10, 10], [100, 100, 0.9, 10, 10]]
print ("Detections before NMS = {}".format(detections))
print ("Detections after NMS = {}".format(nms(detections)))

Detections before NMS = [[10, 10, 0.12, 10, 10], [50, 50, 0.8, 10, 10], [100, 100, 0.9, 10, 10]]
Detections after NMS = [[100, 100, 0.9, 10, 10], [50, 50, 0.8, 10, 10]]

e.g. change to:

while len(detections) > 0:
    detection = detections.pop()
    for new_detection in new_detections:
        if overlapping_area(detection, new_detection) > threshold:
            break
    else:
        new_detections.append(detection)
detections = [[10, 10, .12, 10, 10], [50, 50, .8,10, 10], [100, 100, 0.9, 10, 10]]
print ("Detections before NMS = {}".format(detections))
print ("Detections after NMS = {}".format(nms(detections)))

Detections before NMS = [[10, 10, 0.12, 10, 10], [50, 50, 0.8, 10, 10], [100, 100, 0.9, 10, 10]]
Detections after NMS = [[100, 100, 0.9, 10, 10], [10, 10, 0.12, 10, 10], [50, 50, 0.8, 10, 10]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions