facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
29.32k stars 7.32k forks source link

Issue in loading pre-trained model #5163

Open hapyty opened 7 months ago

hapyty commented 7 months ago

Hello! The pre-trained model I load was trained by "epoch", so detectron2 can't recognize it. Then I met following error:

ValueError: Unsupported type found in checkpoint! epoch: <class 'int'>

Anyone met this error? Enviroment info:


sys.platform linux Python 3.7.13 (default, Mar 29 2022, 02:18:16) [GCC 7.5.0] numpy 1.21.5 detectron2 0.5 @/data/wrz/transfiner/detectron2 Compiler GCC 7.3 CUDA compiler CUDA 10.2 detectron2 arch flags 7.0 DETECTRON2_ENV_MODULE PyTorch 1.7.1 @/home/asc005/anaconda3/envs/transfiner/lib/python3.7/site-packages/torch PyTorch debug build False GPU available Yes GPU 0,1 Tesla V100-PCIE-32GB (arch=7.0) Driver version 440.64.00 CUDA_HOME /usr/local/cuda-10.2 Pillow 9.0.1 torchvision 0.8.2 @/home/asc005/anaconda3/envs/transfiner/lib/python3.7/site-packages/torchvision torchvision arch flags 3.5, 5.0, 6.0, 7.0, 7.5 fvcore 0.1.5.post20221221 iopath 0.1.9 cv2 4.4.0


PyTorch built with:

github-actions[bot] commented 7 months ago

You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template. The following information is missing: "Instructions To Reproduce the Issue and Full Logs"; "Your Environment";

Prayag22 commented 7 months ago

Looks like you have a problem loading pre-trained models firstly load the correct yaml file depending upon which pretrained model to use you cannot have mask_rcnn_R_50_FPN_3x.yaml and use different models weight both should be same you can either define like this or give direct path to pretrained weights using cfg.MODEL.WEIGHTS = ("pretrained_model_path")

cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")) cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")

FurkanGozukara commented 7 months ago

Looks like you have a problem loading pre-trained models firstly load the correct yaml file depending upon which pretrained model to use you cannot have mask_rcnn_R_50_FPN_3x.yaml and use different models weight both should be same you can either define like this or give direct path to pretrained weights using cfg.MODEL.WEIGHTS = ("pretrained_model_path")

cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")) cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")

thank you for reply

can you also checkout this? https://github.com/facebookresearch/detectron2/issues/5170