0

我运行detectron2进行对象检测。

在 origina 中,在 trining 之后,我运行以下代码:

v = Visualizer(im[:, :, ::-1],
            metadata=MetadataCatalog.get("name"), 
            scale=1, 
            instance_mode=ColorMode.SEGMENTATION)
v = v.draw_instance_predictions(outputs["instances"].to("cpu"))
cv2_imshow(v.get_image()[:, :, ::-1])
cv2_imshow(resized)

它工作得很好。

现在,在过滤了一些分段对象之后,我尝试运行代码并只显示一些段,所以我构建了一个数组arr_in,其中仅包含我想要呈现的实例数,我尝试附加它到 v.draw_instance_prediction。

v = Visualizer(im[:, :, ::-1],
            metadata=MetadataCatalog.get("name"), 
            scale=1, 
            instance_mode=ColorMode.SEGMENTATION   
     )
for i in range(len(arr_in)):
  num= np.int(arr_in[i])
  np.append(v, v.draw_instance_predictions(outputs["instances"].to("cpu")[num]))

cv2_imshow(v.get_image()[:, :, ::-1])
cv2_imshow(resized)

但它不起作用。我要问的是如何从类型预测中附加变量?

谢谢

4

1 回答 1

0

解决,

v = Visualizer(im[:, :, ::-1],
            metadata=MetadataCatalog.get("name"), 
            scale=1, 
            instance_mode=ColorMode.SEGMENTATION   
)
for i in range(len(arr_in)):
  num= np.int(arr_in[i])
  #print(num)
  np.append(v.draw_instance_predictions(outputs["instances"].to("cpu")), 
     v.draw_instance_predictions(outputs["instances"].to("cpu")[num]))

v = v.draw_instance_predictions(outputs["instances"].to("cpu"))
cv2_imshow(v.get_image()[:, :, ::-1])
cv2_imshow(resized)
于 2020-08-03T10:34:02.807 回答