openai / CLIP

CLIP (Contrastive Language-Image Pretraining), Predict the most relevant text snippet given an image
MIT License
24.55k stars 3.2k forks source link

SSL certificate error when downloading model weights #413

Open linminhtoo opened 8 months ago

linminhtoo commented 8 months ago

I'm getting the below error when downloading model weights

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

Specifically I'm calling CLIP via llama-index and this is the full stack trace: https://gist.github.com/linminhtoo/b613ffc916e5e96329169e8b4601eff5

Any ideas? I'm on Mac and I could download other pretrained weights from HuggingFace etc without issues

CharlesNord commented 7 months ago

In file /Path/to/your/virtualenvs/envs/inpainting/lib/python3.8/site-packages/clip/clip.py temporarily modify the following lines:

with urllib.request.urlopen(url) as source, open(download_target, "wb") as output:

to

import ssl 
context = ssl._create_unverified_context()
with urllib.request.urlopen(url, context=context) as source, open(download_target, "wb") as output:
zyqhnu commented 6 months ago

In file /Path/to/your/virtualenvs/envs/inpainting/lib/python3.8/site-packages/clip/clip.py temporarily modify the following lines:

with urllib.request.urlopen(url) as source, open(download_target, "wb") as output:

to

import ssl 
context = ssl._create_unverified_context()
with urllib.request.urlopen(url, context=context) as source, open(download_target, "wb") as output:

Cool, that works. Because the 'clip' is installed from source code, I changed the source code /clip/clip.py@line59 before I install it