remydubois / lsnms

Large Scale Non maximum Suppression. This project implements a O(nlog(n)) approach for non max suppression, useful for object detection ran on very large images such as satellite or histology, when the number of instances to prune becomes very large.
65 stars 6 forks source link

Parallelize intra-leaf IoU computations #5

Closed rdbs-oss closed 2 years ago

rdbs-oss commented 2 years ago

When inside a leaf, IoU computations could be parallelized: Instead of:

for i, y in zip(node.indices, node.data):
    inter = intersection(X, y)
    if inter > min_area:
        indices_buffer.append(i)
        intersections_buffer.append(inter)

=> Rather have:

# Prepare placeholder
intersections = np.empty(len(node.data), dtype=np.float64)
n = len(node.data)
# Compute in parallel
for i in prange(n):
    this_inter = intersection(X, node.data[i])
    intersections[i] = this_inter

# Then append sequentially to the intersection and indices buffers
for pointer in range(n):
    this_inter = intersections[pointer]
    if this_inter > min_area:
        indices_buffer.append(node.indices[pointer])
        intersections_buffer.append(this_inter)