问题遇到的现象和发生背景
#获取设备
device = select_device(device)
# 载入模型
model = DetectMultiBackend(weights, device=device, dnn=False, data=data)
print(model.pt)
img = grab_screen(region=(0, 0, x, y))
img = cv2.resize(img, (re_x, re_y))
#img0 = cv2.imread(img, cv2.COLOR_RGB2BGR)
# Padded resize
img = letterbox(img, imgsz, stride, auto=pt)[0]
# Convert
img = img.transpose((2, 0, 1))[::-1] # HWC to CHW, BGR to RGB
img = np.ascontiguousarray(img).astype(np.float32)
img /= 255.0 # 0 - 255 to 0.0 - 1.0
if len(img.shape) == 3:
im = img[None] # expand for batch dim
pred = model(img, augment=False, visualize=False)
pred = non_max_suppression(pred, conf_thres, iou_thres, classes, agnostic_nms) #max_det=max_det
print(pred)
运行结果及报错内容
