I was intrigued by how easy it is to write a simple image recognition app in Python in so few lines of code, so I managed to cobble 10 lines of code together to do just that.

import cv2
import matplotlib.pyplot as plt
import cvlib as cv from cvlib.object_detection 
import draw_bbox

im = cv2.imread('cats.png')
bbox, label, conf = cv.detect_common_objects(im)
output_image = draw_bbox(im, bbox, label, conf)
plt.figure(figsize = (20,20))
plt.imshow(output_image, interpolation='nearest')
plt.show()

I think you will be amazed by the results!

Just in case you can’t see the labels on the image above, the cats in purple boxes have been identified as dogs…. So, I guess the moral of the story is that image recognition is actually more work than just throwing a few lines of code together!

Categories: python

0 Comments

Leave a Reply