hpc203 / picodet-onnxruntime

使用ONNXRuntime部署PicoDet目标检测,包含C++和Python两个版本的程序
27 stars 5 forks source link

fix a bug when nothing detect #1

Closed chenjunnn closed 2 years ago

chenjunnn commented 2 years ago

When nothing detected, cv2.dnn.NMSBoxes would return an empty tuple which has no attribute 'flatten'. Thus it would cause an AttributeError.

Traceback (most recent call last):
  File "main.py", line 158, in <module>
    srcimg = net.detect(srcimg)
  File "main.py", line 133, in detect
    det_bboxes, det_conf, det_classid = self.post_process(outs)
  File "main.py", line 69, in post_process
    det_bboxes, det_conf, det_classid = self.get_bboxes_single(cls_scores, bbox_preds, 1, rescale=False)
  File "main.py", line 107, in get_bboxes_single
    indices = cv2.dnn.NMSBoxes(bboxes_wh.tolist(), confidences.tolist(), self.prob_threshold, self.iou_threshold).flatten()
AttributeError: 'tuple' object has no attribute 'flatten'

So flatten() should be called after the check of indices' emptiness.

hpc203 commented 2 years ago

When nothing detected, cv2.dnn.NMSBoxes would return an empty tuple which has no attribute 'flatten'. Thus it would cause an AttributeError.

Traceback (most recent call last):
  File "main.py", line 158, in <module>
    srcimg = net.detect(srcimg)
  File "main.py", line 133, in detect
    det_bboxes, det_conf, det_classid = self.post_process(outs)
  File "main.py", line 69, in post_process
    det_bboxes, det_conf, det_classid = self.get_bboxes_single(cls_scores, bbox_preds, 1, rescale=False)
  File "main.py", line 107, in get_bboxes_single
    indices = cv2.dnn.NMSBoxes(bboxes_wh.tolist(), confidences.tolist(), self.prob_threshold, self.iou_threshold).flatten()
AttributeError: 'tuple' object has no attribute 'flatten'

So flatten() should be called after the check of indices' emptiness.

yes, you are right

chenjunnn commented 2 years ago

Would you consider to merge this PR?

hpc203 commented 2 years ago

yes

---Original--- From: @.> Date: Wed, Jan 5, 2022 18:41 PM To: @.>; Cc: @.**@.>; Subject: Re: [hpc203/picodet-onnxruntime] fix a bug when nothing detect (PR#1)

Would you consider to merge this PR?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

chenjunnn commented 2 years ago

这个PR很久没有动静了,请问您可以考虑合并一下吗 @hpc203