2

我正在尝试从 coco 数据集中为一个类训练一个自定义模型 - 苹果。这是实例分割。我使用了一些开源程序来提取苹果图像和相应的带有边界框数据等的 json 文件。我用于训练的代码是

from detectron2.data.datasets import register_coco_instances
from detectron2.engine import DefaultTrainer
from detectron2.config import get_cfg
from detectron2.model_zoo import model_zoo
import os
from detectron2.data.datasets import register_coco_instances
from detectron2.data import MetadataCatalog
from detectron2.data import DatasetCatalog


register_coco_instances("train", {}, "segmentation/coco/my_custom_dataset/annotations/coco_annotation.json", "/home/segmentation/coco/my_custom_dataset/images")
register_coco_instances("val", {}, "/home/segmentation/coco/my_custom_dataset_validation/annotations/coco_annotation.json", "/home/segmentation/coco/my_custom_dataset_validation/images")

my_dataset_metadata = MetadataCatalog.get("train")
print(my_dataset_metadata)
dataset_dicts = DatasetCatalog.get("train")
print(dataset_dicts)

#register_coco_instances("my_dataset_validation", {}, "/home/akshay/segmentation/coco/my_custom_dataset/annotations/coco_annotation.json", "/home/akshay/segmentation/coco/my_custom_dataset/images")

cfg = get_cfg()
cfg.merge_from_file(
    "../detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml"
)
cfg.DATASETS.TRAIN = ("train",)
cfg.DATASETS.TEST = ()  # no metrics implemented for this dataset
cfg.DATALOADER.NUM_WORKERS = 2
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml")  # initialize from model zoo
cfg.SOLVER.IMS_PER_BATCH = 2
cfg.SOLVER.BASE_LR = 0.001
cfg.SOLVER.MAX_ITER = (
    1000
)  # 300 iterations seems good enough, but you can certainly train longer
cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = (
    128
)  # faster, and good enough for this toy dataset
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 1  # 3 classes (data, fig, hazelnut)

os.makedirs(cfg.OUTPUT_DIR, exist_ok=True)
trainer = DefaultTrainer(cfg)
trainer.resume_or_load(resume=False)
trainer.train()

然后我将相应的model_final.pth文件复制到detectron2文件夹,然后运行我的推理代码,如下所示

from detectron2.data import DatasetCatalog, MetadataCatalog, build_detection_test_loader
from detectron2.evaluation import COCOEvaluator, inference_on_dataset
from detectron2.engine import DefaultTrainer
from detectron2.evaluation import COCOEvaluator
import os
from detectron2 import model_zoo
from detectron2.engine import DefaultPredictor
from detectron2.config import get_cfg
from detectron2.utils.visualizer import Visualizer
from detectron2.data import MetadataCatalog
from detectron2.data.catalog import DatasetCatalog
import cv2


cfg = get_cfg()
cfg.MODEL.WEIGHTS = ("model_final.pth")
cfg.DATASETS.TEST = ("validation", )
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.2   # set the testing threshold for this model
predictor = DefaultPredictor(cfg)
test_metadata = MetadataCatalog.get("validation").set(thing_classes=["apple"])
from detectron2.utils.visualizer import ColorMode
import glob
im = cv2.imread("hi.jpg")
outputs = predictor(im)
v = Visualizer(im[:, :, ::-1],
                metadata=test_metadata, 
                scale=0.8
                 )
out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
cv2.imwrite("evaluate_output.jpg",out.get_image()[:, :, ::-1])

但是,我没有使用掩码获得所需的输出。我只是再次获得相同的输入图像。这是代码的输出

Skip loading parameter 'proposal_generator.rpn_head.conv.weight' to the model due to incompatible shapes: (256, 256, 3, 3) in the checkpoint but (1024, 1024, 3, 3) in the model! You might want to double check if this is expected.
Skip loading parameter 'proposal_generator.rpn_head.conv.bias' to the model due to incompatible shapes: (256,) in the checkpoint but (1024,) in the model! You might want to double check if this is expected.
Skip loading parameter 'proposal_generator.rpn_head.objectness_logits.weight' to the model due to incompatible shapes: (3, 256, 1, 1) in the checkpoint but (15, 1024, 1, 1) in the model! You might want to double check if this is expected.
Skip loading parameter 'proposal_generator.rpn_head.objectness_logits.bias' to the model due to incompatible shapes: (3,) in the checkpoint but (15,) in the model! You might want to double check if this is expected.
Skip loading parameter 'proposal_generator.rpn_head.anchor_deltas.weight' to the model due to incompatible shapes: (12, 256, 1, 1) in the checkpoint but (60, 1024, 1, 1) in the model! You might want to double check if this is expected.
Skip loading parameter 'proposal_generator.rpn_head.anchor_deltas.bias' to the model due to incompatible shapes: (12,) in the checkpoint but (60,) in the model! You might want to double check if this is expected.
Skip loading parameter 'roi_heads.box_predictor.cls_score.weight' to the model due to incompatible shapes: (2, 1024) in the checkpoint but (81, 2048) in the model! You might want to double check if this is expected.
Skip loading parameter 'roi_heads.box_predictor.cls_score.bias' to the model due to incompatible shapes: (2,) in the checkpoint but (81,) in the model! You might want to double check if this is expected.
Skip loading parameter 'roi_heads.box_predictor.bbox_pred.weight' to the model due to incompatible shapes: (4, 1024) in the checkpoint but (320, 2048) in the model! You might want to double check if this is expected.
Skip loading parameter 'roi_heads.box_predictor.bbox_pred.bias' to the model due to incompatible shapes: (4,) in the checkpoint but (320,) in the model! You might want to double check if this is expected.
Some model parameters or buffers are not found in the checkpoint:
backbone.res2.0.conv1.norm.{bias, weight}
backbone.res2.0.conv1.weight
backbone.res2.0.conv2.norm.{bias, weight}
backbone.res2.0.conv2.weight
backbone.res2.0.conv3.norm.{bias, weight}
backbone.res2.0.conv3.weight
backbone.res2.0.shortcut.norm.{bias, weight}
backbone.res2.0.shortcut.weight
backbone.res2.1.conv1.norm.{bias, weight}
backbone.res2.1.conv1.weight
backbone.res2.1.conv2.norm.{bias, weight}
backbone.res2.1.conv2.weight
backbone.res2.1.conv3.norm.{bias, weight}
backbone.res2.1.conv3.weight
backbone.res2.2.conv1.norm.{bias, weight}
backbone.res2.2.conv1.weight
backbone.res2.2.conv2.norm.{bias, weight}
backbone.res2.2.conv2.weight
backbone.res2.2.conv3.norm.{bias, weight}
backbone.res2.2.conv3.weight
backbone.res3.0.conv1.norm.{bias, weight}
backbone.res3.0.conv1.weight
backbone.res3.0.conv2.norm.{bias, weight}
backbone.res3.0.conv2.weight
backbone.res3.0.conv3.norm.{bias, weight}
backbone.res3.0.conv3.weight
backbone.res3.0.shortcut.norm.{bias, weight}
backbone.res3.0.shortcut.weight
backbone.res3.1.conv1.norm.{bias, weight}
backbone.res3.1.conv1.weight
backbone.res3.1.conv2.norm.{bias, weight}
backbone.res3.1.conv2.weight
backbone.res3.1.conv3.norm.{bias, weight}
backbone.res3.1.conv3.weight
backbone.res3.2.conv1.norm.{bias, weight}
backbone.res3.2.conv1.weight
backbone.res3.2.conv2.norm.{bias, weight}
backbone.res3.2.conv2.weight
backbone.res3.2.conv3.norm.{bias, weight}
backbone.res3.2.conv3.weight
backbone.res3.3.conv1.norm.{bias, weight}
backbone.res3.3.conv1.weight
backbone.res3.3.conv2.norm.{bias, weight}
backbone.res3.3.conv2.weight
backbone.res3.3.conv3.norm.{bias, weight}
backbone.res3.3.conv3.weight
backbone.res4.0.conv1.norm.{bias, weight}
backbone.res4.0.conv1.weight
backbone.res4.0.conv2.norm.{bias, weight}
backbone.res4.0.conv2.weight
backbone.res4.0.conv3.norm.{bias, weight}
backbone.res4.0.conv3.weight
backbone.res4.0.shortcut.norm.{bias, weight}
backbone.res4.0.shortcut.weight
backbone.res4.1.conv1.norm.{bias, weight}
backbone.res4.1.conv1.weight
backbone.res4.1.conv2.norm.{bias, weight}
backbone.res4.1.conv2.weight
backbone.res4.1.conv3.norm.{bias, weight}
backbone.res4.1.conv3.weight
backbone.res4.2.conv1.norm.{bias, weight}
backbone.res4.2.conv1.weight
backbone.res4.2.conv2.norm.{bias, weight}
backbone.res4.2.conv2.weight
backbone.res4.2.conv3.norm.{bias, weight}
backbone.res4.2.conv3.weight
backbone.res4.3.conv1.norm.{bias, weight}
backbone.res4.3.conv1.weight
backbone.res4.3.conv2.norm.{bias, weight}
backbone.res4.3.conv2.weight
backbone.res4.3.conv3.norm.{bias, weight}
backbone.res4.3.conv3.weight
backbone.res4.4.conv1.norm.{bias, weight}
backbone.res4.4.conv1.weight
backbone.res4.4.conv2.norm.{bias, weight}
backbone.res4.4.conv2.weight
backbone.res4.4.conv3.norm.{bias, weight}
backbone.res4.4.conv3.weight
backbone.res4.5.conv1.norm.{bias, weight}
backbone.res4.5.conv1.weight
backbone.res4.5.conv2.norm.{bias, weight}
backbone.res4.5.conv2.weight
backbone.res4.5.conv3.norm.{bias, weight}
backbone.res4.5.conv3.weight
backbone.stem.conv1.norm.{bias, weight}
backbone.stem.conv1.weight
proposal_generator.rpn_head.anchor_deltas.{bias, weight}
proposal_generator.rpn_head.conv.{bias, weight}
proposal_generator.rpn_head.objectness_logits.{bias, weight}
roi_heads.box_predictor.bbox_pred.{bias, weight}
roi_heads.box_predictor.cls_score.{bias, weight}
roi_heads.res5.0.conv1.norm.{bias, weight}
roi_heads.res5.0.conv1.weight
roi_heads.res5.0.conv2.norm.{bias, weight}
roi_heads.res5.0.conv2.weight
roi_heads.res5.0.conv3.norm.{bias, weight}
roi_heads.res5.0.conv3.weight
roi_heads.res5.0.shortcut.norm.{bias, weight}
roi_heads.res5.0.shortcut.weight
roi_heads.res5.1.conv1.norm.{bias, weight}
roi_heads.res5.1.conv1.weight
roi_heads.res5.1.conv2.norm.{bias, weight}
roi_heads.res5.1.conv2.weight
roi_heads.res5.1.conv3.norm.{bias, weight}
roi_heads.res5.1.conv3.weight
roi_heads.res5.2.conv1.norm.{bias, weight}
roi_heads.res5.2.conv1.weight
roi_heads.res5.2.conv2.norm.{bias, weight}
roi_heads.res5.2.conv2.weight
roi_heads.res5.2.conv3.norm.{bias, weight}
roi_heads.res5.2.conv3.weight
The checkpoint state_dict contains keys that are not used by the model:
  backbone.fpn_lateral2.{bias, weight}
  backbone.fpn_output2.{bias, weight}
  backbone.fpn_lateral3.{bias, weight}
  backbone.fpn_output3.{bias, weight}
  backbone.fpn_lateral4.{bias, weight}
  backbone.fpn_output4.{bias, weight}
  backbone.fpn_lateral5.{bias, weight}
  backbone.fpn_output5.{bias, weight}
  backbone.bottom_up.stem.conv1.weight
  backbone.bottom_up.stem.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.0.shortcut.weight
  backbone.bottom_up.res2.0.shortcut.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.0.conv1.weight
  backbone.bottom_up.res2.0.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.0.conv2.weight
  backbone.bottom_up.res2.0.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.0.conv3.weight
  backbone.bottom_up.res2.0.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.1.conv1.weight
  backbone.bottom_up.res2.1.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.1.conv2.weight
  backbone.bottom_up.res2.1.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.1.conv3.weight
  backbone.bottom_up.res2.1.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.2.conv1.weight
  backbone.bottom_up.res2.2.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.2.conv2.weight
  backbone.bottom_up.res2.2.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.2.conv3.weight
  backbone.bottom_up.res2.2.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.0.shortcut.weight
  backbone.bottom_up.res3.0.shortcut.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.0.conv1.weight
  backbone.bottom_up.res3.0.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.0.conv2.weight
  backbone.bottom_up.res3.0.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.0.conv3.weight
  backbone.bottom_up.res3.0.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.1.conv1.weight
  backbone.bottom_up.res3.1.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.1.conv2.weight
  backbone.bottom_up.res3.1.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.1.conv3.weight
  backbone.bottom_up.res3.1.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.2.conv1.weight
  backbone.bottom_up.res3.2.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.2.conv2.weight
  backbone.bottom_up.res3.2.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.2.conv3.weight
  backbone.bottom_up.res3.2.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.3.conv1.weight
  backbone.bottom_up.res3.3.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.3.conv2.weight
  backbone.bottom_up.res3.3.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.3.conv3.weight
  backbone.bottom_up.res3.3.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.0.shortcut.weight
  backbone.bottom_up.res4.0.shortcut.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.0.conv1.weight
  backbone.bottom_up.res4.0.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.0.conv2.weight
  backbone.bottom_up.res4.0.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.0.conv3.weight
  backbone.bottom_up.res4.0.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.1.conv1.weight
  backbone.bottom_up.res4.1.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.1.conv2.weight
  backbone.bottom_up.res4.1.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.1.conv3.weight
  backbone.bottom_up.res4.1.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.2.conv1.weight
  backbone.bottom_up.res4.2.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.2.conv2.weight
  backbone.bottom_up.res4.2.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.2.conv3.weight
  backbone.bottom_up.res4.2.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.3.conv1.weight
  backbone.bottom_up.res4.3.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.3.conv2.weight
  backbone.bottom_up.res4.3.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.3.conv3.weight
  backbone.bottom_up.res4.3.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.4.conv1.weight
  backbone.bottom_up.res4.4.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.4.conv2.weight
  backbone.bottom_up.res4.4.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.4.conv3.weight
  backbone.bottom_up.res4.4.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.5.conv1.weight
  backbone.bottom_up.res4.5.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.5.conv2.weight
  backbone.bottom_up.res4.5.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.5.conv3.weight
  backbone.bottom_up.res4.5.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.6.conv1.weight
  backbone.bottom_up.res4.6.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.6.conv2.weight
  backbone.bottom_up.res4.6.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.6.conv3.weight
  backbone.bottom_up.res4.6.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.7.conv1.weight
  backbone.bottom_up.res4.7.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.7.conv2.weight
  backbone.bottom_up.res4.7.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.7.conv3.weight
  backbone.bottom_up.res4.7.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.8.conv1.weight
  backbone.bottom_up.res4.8.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.8.conv2.weight
  backbone.bottom_up.res4.8.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.8.conv3.weight
  backbone.bottom_up.res4.8.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.9.conv1.weight
  backbone.bottom_up.res4.9.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.9.conv2.weight
  backbone.bottom_up.res4.9.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.9.conv3.weight
  backbone.bottom_up.res4.9.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.10.conv1.weight
  backbone.bottom_up.res4.10.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.10.conv2.weight
  backbone.bottom_up.res4.10.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.10.conv3.weight
  backbone.bottom_up.res4.10.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.11.conv1.weight
  backbone.bottom_up.res4.11.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.11.conv2.weight
  backbone.bottom_up.res4.11.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.11.conv3.weight
  backbone.bottom_up.res4.11.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.12.conv1.weight
  backbone.bottom_up.res4.12.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.12.conv2.weight
  backbone.bottom_up.res4.12.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.12.conv3.weight
  backbone.bottom_up.res4.12.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.13.conv1.weight
  backbone.bottom_up.res4.13.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.13.conv2.weight
  backbone.bottom_up.res4.13.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.13.conv3.weight
  backbone.bottom_up.res4.13.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.14.conv1.weight
  backbone.bottom_up.res4.14.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.14.conv2.weight
  backbone.bottom_up.res4.14.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.14.conv3.weight
  backbone.bottom_up.res4.14.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.15.conv1.weight
  backbone.bottom_up.res4.15.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.15.conv2.weight
  backbone.bottom_up.res4.15.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.15.conv3.weight
  backbone.bottom_up.res4.15.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.16.conv1.weight
  backbone.bottom_up.res4.16.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.16.conv2.weight
  backbone.bottom_up.res4.16.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.16.conv3.weight
  backbone.bottom_up.res4.16.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.17.conv1.weight
  backbone.bottom_up.res4.17.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.17.conv2.weight
  backbone.bottom_up.res4.17.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.17.conv3.weight
  backbone.bottom_up.res4.17.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.18.conv1.weight
  backbone.bottom_up.res4.18.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.18.conv2.weight
  backbone.bottom_up.res4.18.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.18.conv3.weight
  backbone.bottom_up.res4.18.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.19.conv1.weight
  backbone.bottom_up.res4.19.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.19.conv2.weight
  backbone.bottom_up.res4.19.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.19.conv3.weight
  backbone.bottom_up.res4.19.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.20.conv1.weight
  backbone.bottom_up.res4.20.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.20.conv2.weight
  backbone.bottom_up.res4.20.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.20.conv3.weight
  backbone.bottom_up.res4.20.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.21.conv1.weight
  backbone.bottom_up.res4.21.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.21.conv2.weight
  backbone.bottom_up.res4.21.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.21.conv3.weight
  backbone.bottom_up.res4.21.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.22.conv1.weight
  backbone.bottom_up.res4.22.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.22.conv2.weight
  backbone.bottom_up.res4.22.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.22.conv3.weight
  backbone.bottom_up.res4.22.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.0.shortcut.weight
  backbone.bottom_up.res5.0.shortcut.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.0.conv1.weight
  backbone.bottom_up.res5.0.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.0.conv2.weight
  backbone.bottom_up.res5.0.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.0.conv3.weight
  backbone.bottom_up.res5.0.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.1.conv1.weight
  backbone.bottom_up.res5.1.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.1.conv2.weight
  backbone.bottom_up.res5.1.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.1.conv3.weight
  backbone.bottom_up.res5.1.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.2.conv1.weight
  backbone.bottom_up.res5.2.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.2.conv2.weight
  backbone.bottom_up.res5.2.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.2.conv3.weight
  backbone.bottom_up.res5.2.conv3.norm.{bias, running_mean, running_var, weight}
  roi_heads.box_head.fc1.{bias, weight}
  roi_heads.box_head.fc2.{bias, weight}
  roi_heads.mask_head.mask_fcn1.{bias, weight}
  roi_heads.mask_head.mask_fcn2.{bias, weight}
  roi_heads.mask_head.mask_fcn3.{bias, weight}
  roi_heads.mask_head.mask_fcn4.{bias, weight}
  roi_heads.mask_head.deconv.{bias, weight}
  roi_heads.mask_head.predictor.{bias, weight}
/home/akshay/segmentation/detectron2/detectron2/modeling/roi_heads/fast_rcnn.py:154: UserWarning: This overload of nonzero is deprecated:
    nonzero()
Consider using one of the following signatures instead:
    nonzero(*, bool as_tuple) (Triggered internally at  /pytorch/torch/csrc/utils/python_arg_parser.cpp:882.)
  filter_inds = filter_mask.nonzero()

我的模型没有正确训练吗?我不确定这只是一个警告还是存在实际错误。这仅适用于一个自定义类。

4

1 回答 1

1

我找到了解决方案。

我需要在定义配置文件设置时添加类的数量

cfg.MODEL.ROI_HEADS.NUM_CLASSES = num_of_classes

这解决了问题

于 2021-09-07T07:36:33.217 回答