Non-max suppression is coded in Python as follows. We'll continue from step 14 in the previous recipe (The code file and corresponding recommended dataset link is available as Region_proposal_based_object_detectionn.ipynb in GitHub).
- Extract all the regions from an image where there is a high confidence of containing an object that is of a non-background class:
filename = jpegs + single_object_images[ix]img = cv2.imread(filename)img = cv2.resize(img,(224,224))img_area = img.shape[0]*img.shape[1]candidates = extract_candidates(img)plt.imshow(img)plt.grid('off')
The image that we are considering is as follows:
- Pre-process ...