zhreshold commented on a change in pull request #9784: Fix for the case where there are no detections URL: https://github.com/apache/incubator-mxnet/pull/9784#discussion_r167951698
########## File path: example/ssd/detect/detector.py ########## @@ -136,31 +133,52 @@ class names height = img.shape[0] width = img.shape[1] colors = dict() - for i in range(dets.shape[0]): - cls_id = int(dets[i, 0]) - if cls_id >= 0: - score = dets[i, 1] - if score > thresh: - if cls_id not in colors: - colors[cls_id] = (random.random(), random.random(), random.random()) - xmin = int(dets[i, 2] * width) - ymin = int(dets[i, 3] * height) - xmax = int(dets[i, 4] * width) - ymax = int(dets[i, 5] * height) - rect = plt.Rectangle((xmin, ymin), xmax - xmin, - ymax - ymin, fill=False, - edgecolor=colors[cls_id], - linewidth=3.5) - plt.gca().add_patch(rect) - class_name = str(cls_id) - if classes and len(classes) > cls_id: - class_name = classes[cls_id] - plt.gca().text(xmin, ymin - 2, - '{:s} {:.3f}'.format(class_name, score), - bbox=dict(facecolor=colors[cls_id], alpha=0.5), + for det in dets: + (klass, score, x0, y0, x1, y1) = det + if score < thresh: + continue + cls_id = int(klass) + if cls_id not in colors: + colors[cls_id] = (random.random(), random.random(), random.random()) + xmin = int(x0 * width) + ymin = int(y0 * height) + xmax = int(x1 * width) + ymax = int(y1 * height) + rect = plt.Rectangle((xmin, ymin), xmax - xmin, + ymax - ymin, fill=False, + edgecolor=colors[cls_id], + linewidth=3.5) + plt.gca().add_patch(rect) + class_name = str(cls_id) + if classes and len(classes) > cls_id: + class_name = classes[cls_id] + plt.gca().text(xmin, ymin - 2, + '{:s} {:.3f}'.format(class_name, score), + bbox=dict(facecolor=colors[cls_id], alpha=0.5), fontsize=12, color='white') plt.show() + @staticmethod + def filter_positive_detections(detections): + """ + First column (class id) is -1 for negative detections + :param detections: + :return: + """ + print(type(detections)) Review comment: remove print? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services