urllib.error.HTTPError: HTTP Error 403: Forbidden

Sangwon_Jake: <pre><code class="lang-auto">
def load_pretrained_weights(model, model_name, load_fc=True):
    """ Loads pretrained weights, and downloads if loading for the first time. """
    state_dict = model_zoo.load_url(url_map[model_name])
</code></pre>
<p>train.py:302: UserWarning: You have chosen to seed training. This will turn on the CUDNN deterministic setting, which can slow down your training considerably! You may see unexpected behavior when restarting from checkpoints.<br>
warnings.warn('You have chosen to seed training. ’<br>
Downloading: “<a href="http://storage.googleapis.com/public-models/efficientnet/efficientnet-b0-355c32eb.pth" rel="noopener nofollow ugc">http://storage.googleapis.com/public-models/efficientnet/efficientnet-b0-355c32eb.pth</a>” to /home/jake/.cache/torch/hub/checkpoints/efficientnet-b0-355c32eb.pth<br>
Traceback (most recent call last):<br>
File “train.py”, line 333, in <br>
main()<br>
File “train.py”, line 329, in main<br>
main_worker(args.gpu, ngpus_per_node, args)<br>
File “train.py”, line 232, in main_worker<br>
D_class=EFFICIENTDET[args.network][‘D_class’]<br>
File “/home/jake/Gits/EfficientDet.Pytorch/models/efficientdet.py”, line 33, in <strong>init</strong><br>
self.backbone = EfficientNet.from_pretrained(MODEL_MAP[network])<br>
File “/home/jake/Gits/EfficientDet.Pytorch/models/efficientnet.py”, line 243, in from_pretrained<br>
model, model_name, load_fc=(num_classes == 1000))<br>
File “/home/jake/Gits/EfficientDet.Pytorch/models/utils.py”, line 319, in load_pretrained_weights<br>
state_dict = model_zoo.load_url(url_map[model_name])<br>
File “/home/jake/venv/lib/python3.6/site-packages/torch/hub.py”, line 483, in load_state_dict_from_url<br>
download_url_to_file(url, cached_file, hash_prefix, progress=progress)<br>
File “/home/jake/venv/lib/python3.6/site-packages/torch/hub.py”, line 381, in download_url_to_file<br>
u = urlopen(req)<br>
File “/usr/lib/python3.6/urllib/request.py”, line 223, in urlopen<br>
return opener.open(url, data, timeout)<br>
File “/usr/lib/python3.6/urllib/request.py”, line 532, in open<br>
response = meth(req, response)<br>
File “/usr/lib/python3.6/urllib/request.py”, line 642, in http_response<br>
‘http’, request, response, code, msg, hdrs)<br>
File “/usr/lib/python3.6/urllib/request.py”, line 570, in error<br>
return self._call_chain(*args)<br>
File “/usr/lib/python3.6/urllib/request.py”, line 504, in _call_chain<br>
result = func(*args)<br>
File “/usr/lib/python3.6/urllib/request.py”, line 650, in http_error_default<br>
raise HTTPError(req.full_url, code, msg, hdrs, fp)<br>
urllib.error.HTTPError: HTTP Error 403: Forbidden</p>

ptrblck: <p>Could you post an executable code snippet to reproduce this issue and the repository you are using for the model implementation?</p>

Sangwon_Jake: <p>I think it problem when load the url.</p>
<pre><code class="lang-auto">url_map = {
    'efficientnet-b0': 'http://storage.googleapis.com/public-models/efficientnet/efficientnet-b0-355c32eb.pth',
    'efficientnet-b1': 'http://storage.googleapis.com/public-models/efficientnet/efficientnet-b1-f1951068.pth',
    'efficientnet-b2': 'http://storage.googleapis.com/public-models/efficientnet/efficientnet-b2-8bb594d6.pth',
    'efficientnet-b3': 'http://storage.googleapis.com/public-models/efficientnet/efficientnet-b3-5fb5a3c3.pth',
    'efficientnet-b4': 'http://storage.googleapis.com/public-models/efficientnet/efficientnet-b4-6ed6700e.pth',
    'efficientnet-b5': 'http://storage.googleapis.com/public-models/efficientnet/efficientnet-b5-b6417697.pth',
    'efficientnet-b6': 'http://storage.googleapis.com/public-models/efficientnet/efficientnet-b6-c76e70fd.pth',
    'efficientnet-b7': 'http://storage.googleapis.com/public-models/efficientnet/efficientnet-b7-dcc49843.pth',
}


def load_pretrained_weights(model, model_name, load_fc=True):
    """ Loads pretrained weights, and downloads if loading for the first time. """
    state_dict = model_zoo.load_url(url_map[model_name])
    if load_fc:
        model.load_state_dict(state_dict)
    else:
        state_dict.pop('_fc.weight')
        state_dict.pop('_fc.bias')
        res = model.load_state_dict(state_dict, strict=False)
        assert set(res.missing_keys) == set(
            ['_fc.weight', '_fc.bias']), 'issue loading pretrained weights'
    print('Loaded pretrained weights for {}'.format(model_name))
</code></pre>

warrensacko: <p>The HTTP error 403 - Forbidden indicates that the server understands the request made by the client, but is refusing to fulfill it. This error typically occurs when the server receives a request for a resource that the client is not authorized to access. The server denies access to the requested resource due to permissions, authentication, or other security-related reasons. The HTTP <a href="https://net-informations.com/q/mis/403.html" rel="noopener nofollow ugc">error 403</a> message serves as a notification to the client that they are not permitted to access the requested content or perform the requested action. To resolve this error, the client may need to authenticate themselves, adjust their permissions, or contact the server administrator for further assistance.</p>