RuntimeError: Index put requires the source and destination dtypes match, got Byte for the destination and Bool for the source.
TP[b, i] = (pconf > 0.5) & (iou_pred > 0.5) & (pcls == tc.cpu())
FP[b, i] = (pconf > 0.5) & (TP[b, i] == 0) # coordinates or class are wrong
FN[b, i] = pconf <= 0.5 # confidence score is too low (set to zero)
改为:
TP[b, i] = ((pconf > 0.5) & (iou_pred > 0.5) & (pcls == tc.cpu())).byte()
FP[b, i] = ((pconf > 0.5) & (TP[b, i] == 0)).byte() # coordinates or class are wrong
FN[b, i] = (pconf <= 0.5).byte() # confidence score is too low (set to zero)
python遇到IndexError: only integers, slices (:
), ellipsis (...
)……
经检查,错误之处在索引处使用了浮点数