%matplotlib inline import gluonbook as gb from mxnet import image import sys gb.set_figsize() img = image.imread('./catdog.jpg').asnumpy() gb.plt.imshow(img) dog_bbox,cat_bbox = [60,45,378,516],[400,112,655,493] def bbox_to_rect(bbox,color): return gb.plt.Rectangle( xy=(bbox[0], bbox[1]), width=bbox[2]-bbox[0], height=bbox[3]-bbox[1], fill=False, edgecolor=color, linewidth=2) fig = gb.plt.imshow(img) fig.axes.add_patch(bbox_to_rect(dog_bbox,'blue')) fig.axes.add_patch(bbox_to_rect(cat_bbox,'red'))