csuhan / ReDet

Official code of the paper "ReDet: A Rotation-Equivariant Detector for Aerial Object Detection" (CVPR 2021)

Home Page:https://redet.csuhan.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

max() arg is an empty sequence

bigFatCatTom opened this issue · comments

我在训练自己数据集的时候,
出现:
.../ReDet/mmdet/core/bbox/transforms_rbbox.py", line 567, in mask2poly_single
max_contour = max(contours, key=len)
ValueError: max() arg is an empty sequence。
这是我在制作数据局的过程中有什么忽视掉的地方么。

可能存在尺寸比较小的object,可以在dataset中加入尺寸判断:

if ann['area'] <= 80 or max(w, h) < 10:
continue
bbox = [x1, y1, x1 + w - 1, y1 + h - 1]

或者在dataset中判断mask_to_counter是否成功,对无法生成contour的object进行过滤,参考:

def mask2poly_single(binary_mask):
"""
:param binary_mask:
:return:
"""
# try:
contours, hierarchy = cv2.findContours(binary_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
# contour_lens = np.array(list(map(len, contours)))
# max_id = contour_lens.argmax()
# max_contour = contours[max_id]
max_contour = max(contours, key=len)
rect = cv2.minAreaRect(max_contour)
poly = cv2.boxPoints(rect)
# poly = TuplePoly2Poly(poly)
# except:
# import pdb
# pdb.set_trace()
return poly

Hai @bigFatCatTom , I am getting the same error while trying to train ReDet on VisDrone dataset. Did you solve this issue? Please let me know.

Hai @bigFatCatTom , I am getting the same error while trying to train ReDet on VisDrone dataset. Did you solve this issue? Please let me know.

You can refer to the author's answer above