Wednesday, 18 October 2023

Configure python to use same SSL certificates as wget?

While using detectron2 I've ran into SSL issues. However, it seems the SSL issues are related to python as they don't appear while using wget.

I can't use detectron2 to download the weights file https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl:

from detectron2.config import get_cfg
from detectron2.engine import DefaultTrainer

cfg = get_cfg()
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")

default_trainer = DefaultTrainer(cfg)

The above detectron2 code gives the following error:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1091)>

I tried using requests which also didn't work:

import requests
response = requests.get('https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl')

I can use wget to download the file:

wget https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl

How can I setup python to use the same SSL certificates that wget is using?



from Configure python to use same SSL certificates as wget?

No comments:

Post a Comment