这两天在跑DETR代码的时候,跑到image = Image.fromarray(np)的时候报错
......
for i in range(boxes.shape[0]):
class_id = scores[i].argmax()
label = CLASSES[class_id]
confidence = scores[i].max()
text = f"{label} {confidence:.3f}"
image = np.array(image)
plot_one_box(boxes[i], image, label=text)
# cv2.imshow("images", image)
# cv2.waitKey(1)
image = Image.fromarray(image)
image.save(os.path.join(args.output_dir, image_item))
参考这篇文章:https://blog.csdn.net/qq_44824148/article/details/121094400
改一下倒数第二行代码就运行成功了
image = Image.fromarray(np.uint8(image ))