I want to use pretrain faster rcnn of resnet101 FPN to train with my own dataset.
But, it fails to download pretrain faster-rcnn model of resnet101 FPN.
This is my code of model part:
backbone =torchvision.models.detection.backbone_utils.resnet_fpn_backbone('resnet101','False')
model_urls ={'resnet101_fpn':'https://download.pytorch.org/models/fasterrcnn_resnet101_fpn_coco-258fb6c6.pth'}
state_dict = load_state_dict_from_url(model_urls['resnet101_fpn'])
model = FasterRCNN(backbone,num_classes=2)
The error looks like this:
Downloading: "https://download.pytorch.org/models/resnet101-5d3b4d8f.pth" to /home/user/.cache/torch/checkpoints/resnet101-5d3b4d8f.pth
100%|###############################################################| 178728960/178728960 [00:07<00:00, 23374182.30it/s]
Downloading: "https://download.pytorch.org/models/fasterrcnn_resnet101_fpn_coco-258fb6c6.pth" to /home/user/.cache/torch/checkpoints/fasterrcnn_resnet101_fpn_coco-258fb6c6.pth
Traceback (most recent call last):
File "detect.py", line 59, in
state_dict = load_state_dict_from_url(model_urls['resnet101_fpn'])
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/hub.py", line 433, in load_state_dict_from_url
_download_url_to_file(url, cached_file, hash_prefix, progress=progress)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/hub.py", line 349, in _download_url_to_file
u = urlopen(url)
File "/home/user/miniconda/envs/py36/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/home/user/miniconda/envs/py36/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/home/user/miniconda/envs/py36/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/home/user/miniconda/envs/py36/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(args)
File "/home/user/miniconda/envs/py36/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(args)
File "/home/user/miniconda/envs/py36/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
We don't yet provide pre-trained detection models with resnet101 as a backbone, so this error is expected.
@icesohelrana, I trained the faster_rcnn model with the resnet101 backbone on the COCO dataset. You can see the performance here.
@fmassa, let me know if this is useful in any way.
Can I use torchvision.models.detection.backbone_utils.resnet_fpn_backbone('resnet101',pretrained=True) to load the pretrained resnet101 backbone? Following the same tutorial, should I also remove the last 2 layers with something like modules = list(resnet_net.children())[:-2]? Thanks
@tazu786 I can confirm that I've been using this to get around the absence of pretrained resnet101 backbone, and it's working :ok_hand:
Most helpful comment
We don't yet provide pre-trained detection models with
resnet101as a backbone, so this error is expected.