Open yeonsikch opened 3 years ago
Below is the code I tried to infer, and as a result, the following error occurred. (It is shown as a mismatch between the model architecture file yaml file and the weight file.)
I sincerely hope for any advice on this. Thanks :)
import torch, torchvision
# Some basic setup:
# Setup detectron2 logger
import detectron2
from detectron2.utils.logger import setup_logger
setup_logger()
# import some common libraries
import numpy as np
import os, json, random, cv2
# import some common detectron2 utilities
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, DatasetCatalog
def register():
from detectron2.data.datasets import register_coco_instances
register_coco_instances("coustom_train", {}, "{{coustom_train_path}}/instances_train.json", "{{coustom_train_path}}")
register_coco_instances("custom_val", {}, "{{custom_val_path}}/instances_val.json", "{{custom_val_path}}")
register()
cfg = get_cfg()
cfg.merge_from_file("./configs/Base-RCNN-FPN.yaml")
cfg.DATASETS.TEST = ("custom_val",)
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 17
cfg.MODEL.WEIGHTS = os.path.join("./output/ubteacher20-0623/model_0009999.pth")
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.50 # set the testing threshold for this model
cfg.DATASETS.TEST = ("custom_val", )
predictor = DefaultPredictor(cfg)
Some model parameters or buffers are not found in the checkpoint:
backbone.bottom_up.res2.0.conv1.norm.{bias, weight}
backbone.bottom_up.res2.0.conv1.weight
backbone.bottom_up.res2.0.conv2.norm.{bias, weight}
backbone.bottom_up.res2.0.conv2.weight
backbone.bottom_up.res2.0.conv3.norm.{bias, weight}
backbone.bottom_up.res2.0.conv3.weight
backbone.bottom_up.res2.0.shortcut.norm.{bias, weight}
backbone.bottom_up.res2.0.shortcut.weight
backbone.bottom_up.res2.1.conv1.norm.{bias, weight}
backbone.bottom_up.res2.1.conv1.weight
backbone.bottom_up.res2.1.conv2.norm.{bias, weight}
backbone.bottom_up.res2.1.conv2.weight
backbone.bottom_up.res2.1.conv3.norm.{bias, weight}
backbone.bottom_up.res2.1.conv3.weight
backbone.bottom_up.res2.2.conv1.norm.{bias, weight}
backbone.bottom_up.res2.2.conv1.weight
backbone.bottom_up.res2.2.conv2.norm.{bias, weight}
backbone.bottom_up.res2.2.conv2.weight
backbone.bottom_up.res2.2.conv3.norm.{bias, weight}
backbone.bottom_up.res2.2.conv3.weight
backbone.bottom_up.res3.0.conv1.norm.{bias, weight}
backbone.bottom_up.res3.0.conv1.weight
backbone.bottom_up.res3.0.conv2.norm.{bias, weight}
backbone.bottom_up.res3.0.conv2.weight
backbone.bottom_up.res3.0.conv3.norm.{bias, weight}
backbone.bottom_up.res3.0.conv3.weight
backbone.bottom_up.res3.0.shortcut.norm.{bias, weight}
backbone.bottom_up.res3.0.shortcut.weight
backbone.bottom_up.res3.1.conv1.norm.{bias, weight}
backbone.bottom_up.res3.1.conv1.weight
backbone.bottom_up.res3.1.conv2.norm.{bias, weight}
backbone.bottom_up.res3.1.conv2.weight
backbone.bottom_up.res3.1.conv3.norm.{bias, weight}
backbone.bottom_up.res3.1.conv3.weight
backbone.bottom_up.res3.2.conv1.norm.{bias, weight}
backbone.bottom_up.res3.2.conv1.weight
backbone.bottom_up.res3.2.conv2.norm.{bias, weight}
backbone.bottom_up.res3.2.conv2.weight
backbone.bottom_up.res3.2.conv3.norm.{bias, weight}
backbone.bottom_up.res3.2.conv3.weight
backbone.bottom_up.res3.3.conv1.norm.{bias, weight}
backbone.bottom_up.res3.3.conv1.weight
backbone.bottom_up.res3.3.conv2.norm.{bias, weight}
backbone.bottom_up.res3.3.conv2.weight
backbone.bottom_up.res3.3.conv3.norm.{bias, weight}
backbone.bottom_up.res3.3.conv3.weight
backbone.bottom_up.res4.0.conv1.norm.{bias, weight}
backbone.bottom_up.res4.0.conv1.weight
backbone.bottom_up.res4.0.conv2.norm.{bias, weight}
backbone.bottom_up.res4.0.conv2.weight
backbone.bottom_up.res4.0.conv3.norm.{bias, weight}
backbone.bottom_up.res4.0.conv3.weight
backbone.bottom_up.res4.0.shortcut.norm.{bias, weight}
backbone.bottom_up.res4.0.shortcut.weight
backbone.bottom_up.res4.1.conv1.norm.{bias, weight}
backbone.bottom_up.res4.1.conv1.weight
backbone.bottom_up.res4.1.conv2.norm.{bias, weight}
backbone.bottom_up.res4.1.conv2.weight
backbone.bottom_up.res4.1.conv3.norm.{bias, weight}
backbone.bottom_up.res4.1.conv3.weight
backbone.bottom_up.res4.2.conv1.norm.{bias, weight}
backbone.bottom_up.res4.2.conv1.weight
backbone.bottom_up.res4.2.conv2.norm.{bias, weight}
backbone.bottom_up.res4.2.conv2.weight
backbone.bottom_up.res4.2.conv3.norm.{bias, weight}
backbone.bottom_up.res4.2.conv3.weight
backbone.bottom_up.res4.3.conv1.norm.{bias, weight}
backbone.bottom_up.res4.3.conv1.weight
backbone.bottom_up.res4.3.conv2.norm.{bias, weight}
backbone.bottom_up.res4.3.conv2.weight
backbone.bottom_up.res4.3.conv3.norm.{bias, weight}
backbone.bottom_up.res4.3.conv3.weight
backbone.bottom_up.res4.4.conv1.norm.{bias, weight}
backbone.bottom_up.res4.4.conv1.weight
backbone.bottom_up.res4.4.conv2.norm.{bias, weight}
backbone.bottom_up.res4.4.conv2.weight
backbone.bottom_up.res4.4.conv3.norm.{bias, weight}
backbone.bottom_up.res4.4.conv3.weight
backbone.bottom_up.res4.5.conv1.norm.{bias, weight}
backbone.bottom_up.res4.5.conv1.weight
backbone.bottom_up.res4.5.conv2.norm.{bias, weight}
backbone.bottom_up.res4.5.conv2.weight
backbone.bottom_up.res4.5.conv3.norm.{bias, weight}
backbone.bottom_up.res4.5.conv3.weight
backbone.bottom_up.res5.0.conv1.norm.{bias, weight}
backbone.bottom_up.res5.0.conv1.weight
backbone.bottom_up.res5.0.conv2.norm.{bias, weight}
backbone.bottom_up.res5.0.conv2.weight
backbone.bottom_up.res5.0.conv3.norm.{bias, weight}
backbone.bottom_up.res5.0.conv3.weight
backbone.bottom_up.res5.0.shortcut.norm.{bias, weight}
backbone.bottom_up.res5.0.shortcut.weight
backbone.bottom_up.res5.1.conv1.norm.{bias, weight}
backbone.bottom_up.res5.1.conv1.weight
backbone.bottom_up.res5.1.conv2.norm.{bias, weight}
backbone.bottom_up.res5.1.conv2.weight
backbone.bottom_up.res5.1.conv3.norm.{bias, weight}
backbone.bottom_up.res5.1.conv3.weight
backbone.bottom_up.res5.2.conv1.norm.{bias, weight}
backbone.bottom_up.res5.2.conv1.weight
backbone.bottom_up.res5.2.conv2.norm.{bias, weight}
backbone.bottom_up.res5.2.conv2.weight
backbone.bottom_up.res5.2.conv3.norm.{bias, weight}
backbone.bottom_up.res5.2.conv3.weight
backbone.bottom_up.stem.conv1.norm.{bias, weight}
backbone.bottom_up.stem.conv1.weight
backbone.fpn_lateral2.{bias, weight}
backbone.fpn_lateral3.{bias, weight}
backbone.fpn_lateral4.{bias, weight}
backbone.fpn_lateral5.{bias, weight}
backbone.fpn_output2.{bias, weight}
backbone.fpn_output3.{bias, weight}
backbone.fpn_output4.{bias, weight}
backbone.fpn_output5.{bias, 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_head.fc1.{bias, weight}
roi_heads.box_head.fc2.{bias, weight}
roi_heads.box_predictor.bbox_pred.{bias, weight}
roi_heads.box_predictor.cls_score.{bias, weight}
The checkpoint state_dict contains keys that are not used by the model:
modelTeacher.backbone.fpn_lateral2.{bias, weight}
modelTeacher.backbone.fpn_output2.{bias, weight}
modelTeacher.backbone.fpn_lateral3.{bias, weight}
modelTeacher.backbone.fpn_output3.{bias, weight}
modelTeacher.backbone.fpn_lateral4.{bias, weight}
modelTeacher.backbone.fpn_output4.{bias, weight}
modelTeacher.backbone.fpn_lateral5.{bias, weight}
modelTeacher.backbone.fpn_output5.{bias, weight}
modelTeacher.backbone.bottom_up.stem.conv1.weight
modelTeacher.backbone.bottom_up.stem.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.0.shortcut.weight
modelTeacher.backbone.bottom_up.res2.0.shortcut.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.0.conv1.weight
modelTeacher.backbone.bottom_up.res2.0.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.0.conv2.weight
modelTeacher.backbone.bottom_up.res2.0.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.0.conv3.weight
modelTeacher.backbone.bottom_up.res2.0.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.1.conv1.weight
modelTeacher.backbone.bottom_up.res2.1.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.1.conv2.weight
modelTeacher.backbone.bottom_up.res2.1.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.1.conv3.weight
modelTeacher.backbone.bottom_up.res2.1.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.2.conv1.weight
modelTeacher.backbone.bottom_up.res2.2.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.2.conv2.weight
modelTeacher.backbone.bottom_up.res2.2.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res2.2.conv3.weight
modelTeacher.backbone.bottom_up.res2.2.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.0.shortcut.weight
modelTeacher.backbone.bottom_up.res3.0.shortcut.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.0.conv1.weight
modelTeacher.backbone.bottom_up.res3.0.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.0.conv2.weight
modelTeacher.backbone.bottom_up.res3.0.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.0.conv3.weight
modelTeacher.backbone.bottom_up.res3.0.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.1.conv1.weight
modelTeacher.backbone.bottom_up.res3.1.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.1.conv2.weight
modelTeacher.backbone.bottom_up.res3.1.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.1.conv3.weight
modelTeacher.backbone.bottom_up.res3.1.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.2.conv1.weight
modelTeacher.backbone.bottom_up.res3.2.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.2.conv2.weight
modelTeacher.backbone.bottom_up.res3.2.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.2.conv3.weight
modelTeacher.backbone.bottom_up.res3.2.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.3.conv1.weight
modelTeacher.backbone.bottom_up.res3.3.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.3.conv2.weight
modelTeacher.backbone.bottom_up.res3.3.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res3.3.conv3.weight
modelTeacher.backbone.bottom_up.res3.3.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.0.shortcut.weight
modelTeacher.backbone.bottom_up.res4.0.shortcut.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.0.conv1.weight
modelTeacher.backbone.bottom_up.res4.0.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.0.conv2.weight
modelTeacher.backbone.bottom_up.res4.0.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.0.conv3.weight
modelTeacher.backbone.bottom_up.res4.0.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.1.conv1.weight
modelTeacher.backbone.bottom_up.res4.1.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.1.conv2.weight
modelTeacher.backbone.bottom_up.res4.1.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.1.conv3.weight
modelTeacher.backbone.bottom_up.res4.1.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.2.conv1.weight
modelTeacher.backbone.bottom_up.res4.2.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.2.conv2.weight
modelTeacher.backbone.bottom_up.res4.2.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.2.conv3.weight
modelTeacher.backbone.bottom_up.res4.2.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.3.conv1.weight
modelTeacher.backbone.bottom_up.res4.3.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.3.conv2.weight
modelTeacher.backbone.bottom_up.res4.3.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.3.conv3.weight
modelTeacher.backbone.bottom_up.res4.3.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.4.conv1.weight
modelTeacher.backbone.bottom_up.res4.4.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.4.conv2.weight
modelTeacher.backbone.bottom_up.res4.4.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.4.conv3.weight
modelTeacher.backbone.bottom_up.res4.4.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.5.conv1.weight
modelTeacher.backbone.bottom_up.res4.5.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.5.conv2.weight
modelTeacher.backbone.bottom_up.res4.5.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res4.5.conv3.weight
modelTeacher.backbone.bottom_up.res4.5.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.0.shortcut.weight
modelTeacher.backbone.bottom_up.res5.0.shortcut.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.0.conv1.weight
modelTeacher.backbone.bottom_up.res5.0.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.0.conv2.weight
modelTeacher.backbone.bottom_up.res5.0.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.0.conv3.weight
modelTeacher.backbone.bottom_up.res5.0.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.1.conv1.weight
modelTeacher.backbone.bottom_up.res5.1.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.1.conv2.weight
modelTeacher.backbone.bottom_up.res5.1.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.1.conv3.weight
modelTeacher.backbone.bottom_up.res5.1.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.2.conv1.weight
modelTeacher.backbone.bottom_up.res5.2.conv1.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.2.conv2.weight
modelTeacher.backbone.bottom_up.res5.2.conv2.norm.{bias, running_mean, running_var, weight}
modelTeacher.backbone.bottom_up.res5.2.conv3.weight
modelTeacher.backbone.bottom_up.res5.2.conv3.norm.{bias, running_mean, running_var, weight}
modelTeacher.proposal_generator.rpn_head.conv.{bias, weight}
modelTeacher.proposal_generator.rpn_head.objectness_logits.{bias, weight}
modelTeacher.proposal_generator.rpn_head.anchor_deltas.{bias, weight}
modelTeacher.roi_heads.box_head.fc1.{bias, weight}
modelTeacher.roi_heads.box_head.fc2.{bias, weight}
modelTeacher.roi_heads.box_predictor.cls_score.{bias, weight}
modelTeacher.roi_heads.box_predictor.bbox_pred.{bias, weight}
modelStudent.backbone.fpn_lateral2.{bias, weight}
modelStudent.backbone.fpn_output2.{bias, weight}
modelStudent.backbone.fpn_lateral3.{bias, weight}
modelStudent.backbone.fpn_output3.{bias, weight}
modelStudent.backbone.fpn_lateral4.{bias, weight}
modelStudent.backbone.fpn_output4.{bias, weight}
modelStudent.backbone.fpn_lateral5.{bias, weight}
modelStudent.backbone.fpn_output5.{bias, weight}
modelStudent.backbone.bottom_up.stem.conv1.weight
modelStudent.backbone.bottom_up.stem.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.0.shortcut.weight
modelStudent.backbone.bottom_up.res2.0.shortcut.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.0.conv1.weight
modelStudent.backbone.bottom_up.res2.0.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.0.conv2.weight
modelStudent.backbone.bottom_up.res2.0.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.0.conv3.weight
modelStudent.backbone.bottom_up.res2.0.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.1.conv1.weight
modelStudent.backbone.bottom_up.res2.1.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.1.conv2.weight
modelStudent.backbone.bottom_up.res2.1.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.1.conv3.weight
modelStudent.backbone.bottom_up.res2.1.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.2.conv1.weight
modelStudent.backbone.bottom_up.res2.2.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.2.conv2.weight
modelStudent.backbone.bottom_up.res2.2.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res2.2.conv3.weight
modelStudent.backbone.bottom_up.res2.2.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.0.shortcut.weight
modelStudent.backbone.bottom_up.res3.0.shortcut.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.0.conv1.weight
modelStudent.backbone.bottom_up.res3.0.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.0.conv2.weight
modelStudent.backbone.bottom_up.res3.0.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.0.conv3.weight
modelStudent.backbone.bottom_up.res3.0.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.1.conv1.weight
modelStudent.backbone.bottom_up.res3.1.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.1.conv2.weight
modelStudent.backbone.bottom_up.res3.1.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.1.conv3.weight
modelStudent.backbone.bottom_up.res3.1.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.2.conv1.weight
modelStudent.backbone.bottom_up.res3.2.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.2.conv2.weight
modelStudent.backbone.bottom_up.res3.2.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.2.conv3.weight
modelStudent.backbone.bottom_up.res3.2.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.3.conv1.weight
modelStudent.backbone.bottom_up.res3.3.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.3.conv2.weight
modelStudent.backbone.bottom_up.res3.3.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res3.3.conv3.weight
modelStudent.backbone.bottom_up.res3.3.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.0.shortcut.weight
modelStudent.backbone.bottom_up.res4.0.shortcut.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.0.conv1.weight
modelStudent.backbone.bottom_up.res4.0.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.0.conv2.weight
modelStudent.backbone.bottom_up.res4.0.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.0.conv3.weight
modelStudent.backbone.bottom_up.res4.0.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.1.conv1.weight
modelStudent.backbone.bottom_up.res4.1.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.1.conv2.weight
modelStudent.backbone.bottom_up.res4.1.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.1.conv3.weight
modelStudent.backbone.bottom_up.res4.1.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.2.conv1.weight
modelStudent.backbone.bottom_up.res4.2.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.2.conv2.weight
modelStudent.backbone.bottom_up.res4.2.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.2.conv3.weight
modelStudent.backbone.bottom_up.res4.2.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.3.conv1.weight
modelStudent.backbone.bottom_up.res4.3.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.3.conv2.weight
modelStudent.backbone.bottom_up.res4.3.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.3.conv3.weight
modelStudent.backbone.bottom_up.res4.3.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.4.conv1.weight
modelStudent.backbone.bottom_up.res4.4.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.4.conv2.weight
modelStudent.backbone.bottom_up.res4.4.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.4.conv3.weight
modelStudent.backbone.bottom_up.res4.4.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.5.conv1.weight
modelStudent.backbone.bottom_up.res4.5.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.5.conv2.weight
modelStudent.backbone.bottom_up.res4.5.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res4.5.conv3.weight
modelStudent.backbone.bottom_up.res4.5.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.0.shortcut.weight
modelStudent.backbone.bottom_up.res5.0.shortcut.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.0.conv1.weight
modelStudent.backbone.bottom_up.res5.0.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.0.conv2.weight
modelStudent.backbone.bottom_up.res5.0.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.0.conv3.weight
modelStudent.backbone.bottom_up.res5.0.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.1.conv1.weight
modelStudent.backbone.bottom_up.res5.1.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.1.conv2.weight
modelStudent.backbone.bottom_up.res5.1.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.1.conv3.weight
modelStudent.backbone.bottom_up.res5.1.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.2.conv1.weight
modelStudent.backbone.bottom_up.res5.2.conv1.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.2.conv2.weight
modelStudent.backbone.bottom_up.res5.2.conv2.norm.{bias, running_mean, running_var, weight}
modelStudent.backbone.bottom_up.res5.2.conv3.weight
modelStudent.backbone.bottom_up.res5.2.conv3.norm.{bias, running_mean, running_var, weight}
modelStudent.proposal_generator.rpn_head.conv.{bias, weight}
modelStudent.proposal_generator.rpn_head.objectness_logits.{bias, weight}
modelStudent.proposal_generator.rpn_head.anchor_deltas.{bias, weight}
modelStudent.roi_heads.box_head.fc1.{bias, weight}
modelStudent.roi_heads.box_head.fc2.{bias, weight}
modelStudent.roi_heads.box_predictor.cls_score.{bias, weight}
modelStudent.roi_heads.box_predictor.bbox_pred.{bias, weight}
Hi, I tried various methods (such as inserting Unbiased Teacher code into Detectron2 code) and got the following result.
The learned weight is loaded and the result is displayed, but it continues to output a random value, and the Score value also outputs 1.
Can I get any further advice?
Thank you.
from ubteacher import add_ubteacher_config
from detectron2.engine import default_setup
cfg = get_cfg()
add_ubteacher_config(cfg)
cfg.merge_from_file("./ubteacher50-0626/output/test.yaml")
cfg.MODEL.WEIGHTS = os.path.join("./ubteacher10-0626-2nd/output/model_0009999.pth")
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.50 # set the testing threshold for this model
predictor = DefaultPredictor(cfg)
im = cv2.imread("./img.jpg")
outputs = predictor(im)
print(outputs)
v = Visualizer(im[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2)
v = v.draw_instance_predictions(outputs["instances"].to("cpu"))
im_pil = Image.fromarray(v.get_image()[:, :,])
im_pil.show()
<detectron2.checkpoint.detection_checkpoint.DetectionCheckpointer object at 0x7f0bb681c710>
{'instances': Instances(num_instances=24, image_height=404, image_width=720, fields=[pred_boxes: Boxes(tensor([[383.5005, 53.4141, 602.5138, 53.5077],
[ 45.2747, 262.1313, 126.0270, 262.1314],
[311.9602, 74.5043, 619.8218, 75.1169],
[323.2592, 211.2665, 606.3066, 211.2668],
[ 85.4316, 315.3679, 199.5453, 315.3680],
[565.6397, 403.4033, 696.3309, 403.4034],
[ 0.0000, 1.7313, 4.1201, 1.7314],
[250.9537, 207.2435, 538.6982, 207.2437],
[ 7.9435, 367.7731, 40.7374, 367.7739],
[ 90.8596, 128.5946, 301.6566, 128.9298],
[ 36.9307, 128.4760, 74.5749, 128.4821],
[ 92.5428, 148.0280, 341.9976, 148.0283],
[295.0145, 223.7837, 516.8199, 223.7840],
[ 0.0000, 388.1570, 720.0000, 388.1578],
[ 50.1934, 220.2142, 141.7849, 220.2230],
[ 19.7260, 147.7813, 527.6984, 147.7817],
[535.6547, 64.8633, 642.9875, 64.8642],
[236.0511, 35.1106, 294.6533, 35.1319],
[251.6348, 266.5087, 383.0826, 266.5090],
[ 0.0000, 121.2920, 70.5103, 121.2920],
[ 74.3605, 240.9675, 166.6259, 240.9684],
[ 0.0000, 147.9725, 94.6426, 147.9741],
[ 1.8571, 261.9756, 19.1602, 404.0000],
[687.1244, 0.0000, 720.0000, 272.4524]], device='cuda:0')), scores: tensor([1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000,
1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000,
1.0000, 1.0000, 1.0000, 0.9999, 0.9989, 0.9983], device='cuda:0'), pred_classes: tensor([1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
device='cuda:0')])}
Hi, I have got the exact same issue on my custom dataset... If you've found any clue about how to fix the problem, I am definitely interested! :)
I have solved the problem! Here is my diagnostic:
Among the configuration parameters, my parameter SEMISUPNET.BURN_UP_STEP was greater than SOLVER.MAX_ITER, meaning that only the 'burn-in stage' part of the training was happening. At the end of that stage, only the student model has been trained, and I guess the teacher model has random weights.
Thus, if you want to test your model at the end of this burn-in stage, you need to use the Student model (and not the teacher model, as it is encoded in the test function). Basically, when you call the test function of the Trainer (e.g. in train_net.py
), use:
Trainer.test(cfg, ensem_ts_model.modelStudent)
Hope that helped :)
Hi @yeonsikch and @megalinier ,
Sorry for the late reply. Thanks @megalinier for providing the solution!
Yes, DefaultPredictor
uses the default weight loading so it only loads the student model and remains the teacher model as original weight (i.e., random initialization). @megalinier provides a correct way to get the student model weight and do inference.
Another potential solution is to create a new Predictor class, inherit the DetectionCheckpointer
, and overwrite the __init__
function, especially the loading part as following
https://github.com/facebookresearch/detectron2/blob/f62c5492732f75edf5fbf3606bbd322251f909cf/detectron2/engine/defaults.py#L290-L291
And change it to this: https://github.com/facebookresearch/unbiased-teacher/blob/ba543ed2b87446c79eaf41f93320de246c8eedc2/ubteacher/engine/trainer.py#L256-L263
EnsembleTSModel
is a class containing both the student and teacher models, and DetectionTSCheckpointer
is the checkpointer to load them.
You could try to use @megalinier 's solution or try my suggestions above, I think both of them work. I will also push a new commit in these two weeks to address this. Thanks for pointing this out!
Hello,
Regarding @ycliu93 proposal:
Another potential solution is to create a new Predictor class, inherit the DetectionCheckpointer, and overwrite the init function, especially the loading part as following
It indeed works. I have implemented the code in my UB fork with a Google Colab example aswell.
In short what I did was:
class CustomPredictor:
def __init__(self, cfg):
self.cfg = cfg.clone()
Trainer = UBTeacherTrainer
model = Trainer.build_model(cfg)
model_teacher = Trainer.build_model(cfg)
ensem_ts_model = EnsembleTSModel(model_teacher, model)
DetectionCheckpointer(
ensem_ts_model,
save_dir=cfg.OUTPUT_DIR
).resume_or_load(cfg.MODEL.WEIGHTS, resume=True)
model = ensem_ts_model.modelTeacher
self.model = model
self.model.eval()
def __call__(self, original_image):
with torch.no_grad():
original_image = original_image[:, :, ::-1]
height, width = original_image.shape[:2]
image = original_image
image = torch.as_tensor(image.astype("float32").transpose(2, 0, 1))
inputs = {"image": image, "height": height, "width": width}
predictions = self.model([inputs])[0]
return predictions
from ubteacher.engine.trainer import CustomPredictor
dataset_dicts = DatasetCatalog.get(YOUR_DATASET) predictor = CustomPredictor(cfg) outputs = predictor(YOUR_IMAGE)
Hello,
Regarding @ycliu93 proposal:
Another potential solution is to create a new Predictor class, inherit the DetectionCheckpointer, and overwrite the init function, especially the loading part as following
It indeed works. I have implemented the code in my UB fork with a Google Colab example aswell.
In short what I did was:
- Create a class in trainer.py
class CustomPredictor: def __init__(self, cfg): self.cfg = cfg.clone() Trainer = UBTeacherTrainer model = Trainer.build_model(cfg) model_teacher = Trainer.build_model(cfg) ensem_ts_model = EnsembleTSModel(model_teacher, model) DetectionCheckpointer( ensem_ts_model, save_dir=cfg.OUTPUT_DIR ).resume_or_load(cfg.MODEL.WEIGHTS, resume=True) model = ensem_ts_model.modelTeacher self.model = model self.model.eval() def __call__(self, original_image): with torch.no_grad(): original_image = original_image[:, :, ::-1] height, width = original_image.shape[:2] image = original_image image = torch.as_tensor(image.astype("float32").transpose(2, 0, 1)) inputs = {"image": image, "height": height, "width": width} predictions = self.model([inputs])[0] return predictions
- Here is how you can use it afterwards:
from ubteacher.engine.trainer import CustomPredictor dataset_dicts = DatasetCatalog.get(*YOUR_DATASET*) predictor = CustomPredictor(cfg) outputs = predictor(*YOUR_IMAGE*)
Hi,I still get the error:No object named 'TwoStagePseudoLabGeneralizedRCNN' found in 'META_ARCH' registry! Can you help me?
Hi! Thanks to you, I was able to achieve very good AP for my custom dataset. Finally, I want to infer an actual image (or video) with the trained model, but it is not easy to see detectron2 or the this git code.
Do you have any good suggestions please?
Thanks!