diff --git a/examples/onnxrt/image_recognition/onnx_model_zoo/mnist/quantization/ptq_static/main.py b/examples/onnxrt/image_recognition/onnx_model_zoo/mnist/quantization/ptq_static/main.py index e8a24acab49..90af8a97c7a 100644 --- a/examples/onnxrt/image_recognition/onnx_model_zoo/mnist/quantization/ptq_static/main.py +++ b/examples/onnxrt/image_recognition/onnx_model_zoo/mnist/quantization/ptq_static/main.py @@ -153,6 +153,8 @@ def download_url(url, root, filename=None, md5=None): # pragma: no cover md5 (str): the md5 string. """ import urllib + import ssl + ssl._create_default_https_context = ssl._create_unverified_context root = os.path.expanduser(root) if not filename: filename = os.path.basename(url) diff --git a/examples/tensorflow/nlp/bert_base_mrpc/quantization/ptq/prepare_dataset.py b/examples/tensorflow/nlp/bert_base_mrpc/quantization/ptq/prepare_dataset.py index 1e5fa953519..621fde63e6c 100644 --- a/examples/tensorflow/nlp/bert_base_mrpc/quantization/ptq/prepare_dataset.py +++ b/examples/tensorflow/nlp/bert_base_mrpc/quantization/ptq/prepare_dataset.py @@ -39,18 +39,20 @@ import tempfile import urllib.request import zipfile +import ssl +ssl._create_default_https_context = ssl._create_unverified_context TASKS = ["CoLA", "SST", "MRPC", "QQP", "STS", "MNLI", "QNLI", "RTE", "WNLI", "diagnostic"] -TASK2PATH = {"CoLA":'https://dl.fbaipublicfiles.com/glue/data/CoLA.zip', - "SST":'https://dl.fbaipublicfiles.com/glue/data/SST-2.zip', - "QQP":'https://dl.fbaipublicfiles.com/glue/data/STS-B.zip', - "STS":'https://dl.fbaipublicfiles.com/glue/data/QQP-clean.zip', - "MNLI":'https://dl.fbaipublicfiles.com/glue/data/MNLI.zip', - "QNLI":'https://dl.fbaipublicfiles.com/glue/data/QNLIv2.zip', - "RTE":'https://dl.fbaipublicfiles.com/glue/data/RTE.zip', - "WNLI":'https://dl.fbaipublicfiles.com/glue/data/WNLI.zip', - "MRPC":"https://raw.githubusercontent.com/MegEngine/Models/master/official/nlp/bert/glue_data/MRPC/dev_ids.tsv", - "diagnostic":'https://dl.fbaipublicfiles.com/glue/data/AX.tsv'} +TASK2PATH = {"CoLA": 'https://dl.fbaipublicfiles.com/glue/data/CoLA.zip', + "SST": 'https://dl.fbaipublicfiles.com/glue/data/SST-2.zip', + "QQP": 'https://dl.fbaipublicfiles.com/glue/data/STS-B.zip', + "STS": 'https://dl.fbaipublicfiles.com/glue/data/QQP-clean.zip', + "MNLI": 'https://dl.fbaipublicfiles.com/glue/data/MNLI.zip', + "QNLI": 'https://dl.fbaipublicfiles.com/glue/data/QNLIv2.zip', + "RTE": 'https://dl.fbaipublicfiles.com/glue/data/RTE.zip', + "WNLI": 'https://dl.fbaipublicfiles.com/glue/data/WNLI.zip', + "MRPC": "https://raw.githubusercontent.com/MegEngine/Models/master/official/nlp/bert/glue_data/MRPC/dev_ids.tsv", + "diagnostic": 'https://dl.fbaipublicfiles.com/glue/data/AX.tsv'} MRPC_TRAIN = 'https://dl.fbaipublicfiles.com/senteval/senteval_data/msr_paraphrase_train.txt' MRPC_TEST = 'https://dl.fbaipublicfiles.com/senteval/senteval_data/msr_paraphrase_test.txt' diff --git a/neural_compressor/data/datasets/dataset.py b/neural_compressor/data/datasets/dataset.py index 49dcf044dbd..46cec9ba36a 100644 --- a/neural_compressor/data/datasets/dataset.py +++ b/neural_compressor/data/datasets/dataset.py @@ -299,8 +299,11 @@ def download_url(url, root, filename=None, md5=None): # pragma: no cover filename (str): the file name for saving. md5 (str): the md5 string. """ + import ssl import urllib + ssl._create_default_https_context = ssl._create_unverified_context + root = os.path.expanduser(root) if not filename: filename = os.path.basename(url) diff --git a/neural_compressor/experimental/data/datasets/dataset.py b/neural_compressor/experimental/data/datasets/dataset.py index c99d14ca8ab..832adcf5f73 100644 --- a/neural_compressor/experimental/data/datasets/dataset.py +++ b/neural_compressor/experimental/data/datasets/dataset.py @@ -299,8 +299,11 @@ def download_url(url, root, filename=None, md5=None): # pragma: no cover filename (str): the file name for saving. md5 (str): the md5 string. """ + import ssl import urllib + ssl._create_default_https_context = ssl._create_unverified_context + root = os.path.expanduser(root) if not filename: filename = os.path.basename(url) diff --git a/test/data/test_exp_transformers.py b/test/data/test_exp_transformers.py index 591b02051e6..6f5fd51f737 100644 --- a/test/data/test_exp_transformers.py +++ b/test/data/test_exp_transformers.py @@ -718,8 +718,11 @@ def testRandomResizedCrop(self): def testSquadV1(self): import json + import ssl import urllib + ssl._create_default_https_context = ssl._create_unverified_context + vocab_url = ( "https://raw.githubusercontent.com/microsoft/SDNet/master/bert_vocab_files/bert-large-uncased-vocab.txt" ) diff --git a/test/data/test_transform.py b/test/data/test_transform.py index aba4f25cc64..3550dd0faeb 100644 --- a/test/data/test_transform.py +++ b/test/data/test_transform.py @@ -718,8 +718,11 @@ def testRandomResizedCrop(self): def testSquadV1(self): import json + import ssl import urllib + ssl._create_default_https_context = ssl._create_unverified_context + vocab_url = ( "https://raw.githubusercontent.com/microsoft/SDNet/master/bert_vocab_files/bert-large-uncased-vocab.txt" )