在 detectron2 中,如何在对象检测中仅绘制没有标签(class 名称)的图像边界?

In detectron2, how could I plot only bounding on images without label (class name) in object detection?

我正在学习 detectron2 并使用 pokemonster 数据进行练习。 所以,我遵循了 detectron2 教程(此处:https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5

并且还开发了检测器,可以检测到下图。

但是,在此图像中,红色圆圈是 class 名称。我只想绘制边界框(绿色),红色圆圈(class 名称)除外。 下面是我的可视化代码。应该修改什么代码? 谢谢。

import glob
for imageName in sorted(glob.glob(os.path.join(test_path, '*.jpg'))):
  im = cv2.imread(imageName)
  outputs = predictor(im)
  v = Visualizer(im[:, :, ::-1],
                metadata=train_metadata,
                scale=0.8
                 )
  out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
  boxes = v._convert_boxes(outputs["instances"].pred_boxes.to('cpu'))
  for box in boxes:
    box = (round(box[0]), round(box[1]), round(box[2]) - round(box[0]), round(box[3] - box[1]))
    out = v.draw_text(f"{box[2:4]}", (box[0], box[1]))
  cv2_imshow(out.get_image()[:, :, ::-1])

class Visualizer contains all the methods inlcuding draw_box()。您想将所有框绘制到 Visualizer 对象,最后 return 一个 VisImage

v = Visualizer(
        im[:, :, ::-1], 
        metadata=train_metadata, 
        scale=0.8,
        )
for box in outputs["instances"].pred_boxes.to('cpu'):
    v.draw_box(box)
    v.draw_text(str(box[:2].numpy()), tuple(box[:2].numpy()))
v = v.get_output()
img =  v.get_image()[:, :, ::-1]
cv2_imshow(img)

有绘制二值mask的函数,但是没有在彩色图像上绘制mask的函数。如何在原始输入彩色图像上绘制遮罩。

output = predictor(input_image)        
V = Visualizer(input_image[:, :, ::-1], 
MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale = 1.2)
mask=output["instances"].get("pred_masks")
mask=mask.to("cpu")
V.draw_instance_predictions(output["instances"].to("cpu"))
for m in mask:
    V.draw_mask(m)

V = V.get_output()
cv2.imwrite("frame%d.jpg" % count, V.get_image()[:, :, ::-1]) 

谢谢