show_boxes.py
Go to the documentation of this file.
00001 # --------------------------------------------------------
00002 # Deformable Convolutional Networks
00003 # Copyright (c) 2017 Microsoft
00004 # Licensed under The Apache-2.0 License [see LICENSE for details]
00005 # Written by Yi Li, Haocheng Zhang
00006 # --------------------------------------------------------
00007 
00008 import matplotlib.pyplot as plt
00009 from random import random as rand
00010 def show_boxes(im, dets, classes, scale = 1.0):
00011     plt.cla()
00012     plt.axis("off")
00013     plt.imshow(im)
00014     for cls_idx, cls_name in enumerate(classes):
00015         cls_dets = dets[cls_idx]
00016         for det in cls_dets:
00017             bbox = det[:4] * scale
00018             color = (rand(), rand(), rand())
00019             rect = plt.Rectangle((bbox[0], bbox[1]),
00020                                   bbox[2] - bbox[0],
00021                                   bbox[3] - bbox[1], fill=False,
00022                                   edgecolor=color, linewidth=2.5)
00023             plt.gca().add_patch(rect)
00024 
00025             if cls_dets.shape[1] == 5:
00026                 score = det[-1]
00027                 plt.gca().text(bbox[0], bbox[1],
00028                                '{:s} {:.3f}'.format(cls_name, score),
00029                                bbox=dict(facecolor=color, alpha=0.5), fontsize=9, color='white')
00030     plt.show()
00031     return im
00032 


rail_object_detector
Author(s):
autogenerated on Sat Jun 8 2019 20:26:30