Getting a TypeError: Required argument 'rec' (pos 2) not found

Getting a TypeError: Required argument 'rec' (pos 2) not found

我的代码是

sample = images[0].permute(1, 2, 0).cpu().numpy()
    boxes = outputs[0]['boxes'].data.cpu().numpy()
    scores = outputs[0]['scores'].data.cpu().numpy()
    boxes = boxes[scores >= detection_threshold].astype(np.int32)
    fig, ax = plt.subplots(1, 1, figsize=(32, 16))
    for box in boxes:
        cv2.rectangle(img=sample,
                      pt1=(box[0], box[1]),
                      pt2=(box[2], box[3]),
                      color=(220, 0, 0))

ax.set_axis_off()
img = np.array(img)
st.image(cv2.UMat.get(sample), clamp=True)
st.write("# Results")
st.dataframe(pd.DataFrame(results))

BUt 得到错误为

TypeError: Required argument 'rec' (pos 2) not found
Traceback:
File "/home/stark/anaconda3/envs/mark/lib/python3.6/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)
File "/home/stark/streamlit/streamlit.py", line 129, in <module>
    color=(220, 0, 0))

我正在尝试在 streamlit 中部署我的模型,这是我最后停留的地方

嗯,我确实解决了

fig, ax = plt.subplots(1, 1, figsize=(16, 8))
sample = sample.copy()
for box in boxes:
    x1, y1, x2, y2 = box
    cv2.rectangle(sample,
                  (x1, y1),
                  (x2, y2),
                  (220, 0, 0), 2)


ax.set_axis_off()

谢谢,@christoph,你的想法奏效了