From 25edf6b92a50a54488bc15c9ed82e58f2b6b4091 Mon Sep 17 00:00:00 2001 From: Carsten L Date: Thu, 26 Oct 2023 21:16:33 +0200 Subject: [PATCH] Prevent incompatibility with nighly build / dev versions of torch Prevent incompatibility with nighly build / dev versions of torch which is a requirement on MacOS to get MPS (metal performance shader) support. This way the custom node works also on MacOS. --- facelib/detection/yolov5face/face_detector.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/facelib/detection/yolov5face/face_detector.py b/facelib/detection/yolov5face/face_detector.py index 693e345..f926ee4 100644 --- a/facelib/detection/yolov5face/face_detector.py +++ b/facelib/detection/yolov5face/face_detector.py @@ -17,8 +17,13 @@ from custom_nodes.facerestore_cf.facelib.detection.yolov5face.utils.general impo scale_coords_landmarks, ) -IS_HIGH_VERSION = tuple(map(int, torch.__version__.split('+')[0].split('.'))) >= (1, 9, 0) - +try: + version_str = torch.__version__.split('+')[0] + major, minor, patch = map(int, version_str.split('.')) + IS_HIGH_VERSION = (major, minor, patch) >= (1, 9, 0) +except ValueError: + # Handle the case of a development version here + IS_HIGH_VERSION = False def isListempty(inList): if isinstance(inList, list): # Is a list