How to do it...

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).

  1. 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:

  1. Pre-process ...

Get Neural Networks with Keras Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.