From 3f7c2e84f0aa4f52a312dad5da50f995089b2d7e Mon Sep 17 00:00:00 2001 From: Viet Anh Nguyen Date: Tue, 2 May 2023 00:14:31 +0700 Subject: [PATCH] Temporarily disable ssl verification for model download --- .flake8 | 2 +- anylabeling/app_info.py | 2 +- anylabeling/services/auto_labeling/model.py | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.flake8 b/.flake8 index 1b54d64..5cf1698 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = E203, E266, E501, W503, F403, F401, B905 +ignore = E203, E266, E501, W503, F403, F401, B905, E402 max-line-length = 79 max-complexity = 18 select = B,C,E,F,W,T4,B9 diff --git a/anylabeling/app_info.py b/anylabeling/app_info.py index 13859b9..613db20 100644 --- a/anylabeling/app_info.py +++ b/anylabeling/app_info.py @@ -1,3 +1,3 @@ __appname__ = "AnyLabeling" __appdescription__ = "Effortless data labeling with AI support" -__version__ = "0.2.15" +__version__ = "0.2.16" diff --git a/anylabeling/services/auto_labeling/model.py b/anylabeling/services/auto_labeling/model.py index 233419a..2d2264b 100644 --- a/anylabeling/services/auto_labeling/model.py +++ b/anylabeling/services/auto_labeling/model.py @@ -1,11 +1,17 @@ import logging import os import pathlib +import yaml +import onnx import urllib.request + +# Temporarily disable SSL verification +import ssl + +ssl._create_default_https_context = ssl._create_unverified_context + from abc import abstractmethod -import yaml -import onnx from PyQt5.QtCore import QFile, QObject from PyQt5.QtGui import QImage @@ -100,8 +106,8 @@ def get_model_abs_path(self, model_path, model_folder_name): try: onnx.checker.check_model(model_abs_path) except onnx.checker.ValidationError as e: - print("The model is invalid: %s" % e) - print("Action: Delete and redownload...") + logging.warning("The model is invalid: %s", str(e)) + logging.warning("Action: Delete and redownload...") os.remove(model_abs_path) else: return model_abs_path @@ -116,7 +122,7 @@ def get_model_abs_path(self, model_path, model_folder_name): download_url[:20] + "..." + download_url[-20:] ) logging.info( - f"Downloading {ellipsis_download_url} to {model_abs_path}" + "Downloading %s to %s", ellipsis_download_url, model_abs_path ) try: # Download and show progress