1. 在使用yolov5统计预测框数量时,在将Tensor类型的值转换成Numpy过程中出现的错误:TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
2. 原因:将一个在GPU上的Tensor类型转换为Numpy类型,没有将其先移动到CPU上。
3. 解决:
# x最初是Tensor类型
x = x.cpu().numpy()