def post(self):
global detector
imstrjpg = self.get_argument('data', 'empty')
if imstrjpg == 'emtpy':
print 'EMPTY'
return ""
imstr = np.fromstring(imstrjpg, dtype=np.uint8)
im = cv2.imdecode(imstr, cv2.CV_LOAD_IMAGE_UNCHANGED)
scores, boxes = detector.detect(im)
CONF_THRESH = 0.15
NMS_THRESH = 0.08
results = {}
for cls_ind, cls in enumerate(CLASSES[1:]):
cls_ind += 1 # because we skipped background
cls_boxes = boxes[:, 4*cls_ind:4*(cls_ind + 1)]
cls_scores = scores[:, cls_ind]
dets = np.hstack((cls_boxes,
cls_scores[:, np.newaxis])).astype(np.float32)
keep = nms(dets, NMS_THRESH)
dets = dets[keep, :]
results[cls] = dets
self.write(cPickle.dumps(results))
self.finish()
评论列表
文章目录