maskdino_R50_bs16_50ep_4s_dowsample1_2048.yaml & maskdino_swinl_50ep_300q_hid2048_3sd1_instance_maskenhanced_mask52.3ap_box59.0ap.pth
There is an issue with maskdino_R50_bs16_50ep_4s_dowsample1_2048.yaml & maskdino_swinl_50ep_300q_hid2048_3sd1_instance_maskenhanced_mask52.3ap_box59.0ap.pth which causes incorrect detections/masks. Basically the code below shows no masks at all.
However, the same code correctly detects and masks with maskdino_R50_bs16_50ep_3s.yaml & maskdino_r50_50ep_300q_hid1024_3sd1_instance_maskenhanced_mask46.1ap_box51.5ap.pth.
Is it possible you could check if there is a problem with the yaml or pth file?
def setup_cfg():
cfg = get_cfg()
add_deeplab_config(cfg)
add_maskdino_config(cfg)
#cfg.merge_from_file("../configs/coco/instance-segmentation/maskdino_R50_bs16_50ep_3s.yaml")
#cfg.MODEL.WEIGHTS = "maskdino_r50_50ep_300q_hid1024_3sd1_instance_maskenhanced_mask46.1ap_box51.5ap.pth"
cfg.merge_from_file("../configs/coco/instance-segmentation/maskdino_R50_bs16_50ep_4s_dowsample1_2048.yaml")
cfg.MODEL.WEIGHTS = "maskdino_swinl_50ep_300q_hid2048_3sd1_instance_maskenhanced_mask52.3ap_box59.0ap.pth"
cfg.freeze()
return cfg
cfg = setup_cfg()
image = read_image("000000000785.jpg", format="BGR")
predictor = DefaultPredictor(cfg)
predictions = predictor(image)
image = image[:, :, ::-1]
metadata = MetadataCatalog.get("__unused")
instance_mode = ColorMode.IMAGE
visualizer = Visualizer(image, metadata, instance_mode=instance_mode)
if "instances" in predictions:
instances = predictions["instances"].to(torch.device("cpu"))
scores = instances.scores
selected_indices = scores > 0.3
selected_instances = instances[selected_indices]
vis_output = visualizer.draw_instance_predictions(predictions=selected_instances)
else:
vis_output = visualizer.draw_instance_predictions(predictions=None)
out_filename = './output/pred.jpg'
vis_output.save(out_filename)
I also faced this issue. Turns out I made a mistake when typing the config path.
Config file(s) with same name is available under configs/coco/instance-segmentation/ and configs/coco/instance-segmentation/swin. The one in the swin folder is the correct one.
You seem to have made the same mistake judging from the code snippet you shared.