From c70f8bb39a1c101c4de62a8efd3536774a258afb Mon Sep 17 00:00:00 2001 From: myd510 <1186325309@qq.com> Date: Mon, 30 Dec 2024 20:39:51 +0800 Subject: [PATCH 1/3] Replace disutils.version.LooseVersion with packaging.version.Version --- basicsr/archs/arch_util.py | 4 ++-- requirements.txt | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/basicsr/archs/arch_util.py b/basicsr/archs/arch_util.py index fec513a..3c68323 100644 --- a/basicsr/archs/arch_util.py +++ b/basicsr/archs/arch_util.py @@ -3,7 +3,7 @@ import math import torch import torchvision import warnings -from distutils.version import LooseVersion +from packaging.version import Version from itertools import repeat from torch import nn as nn from torch.nn import functional as F @@ -228,7 +228,7 @@ class DCNv2Pack(ModulatedDeformConvPack): logger = get_root_logger() logger.warning(f'Offset abs mean is {offset_absmean}, larger than 50.') - if LooseVersion(torchvision.__version__) >= LooseVersion('0.9.0'): + if Version(torchvision.__version__) >= Version('0.9.0'): return torchvision.ops.deform_conv2d(x, offset, self.weight, self.bias, self.stride, self.padding, self.dilation, mask) else: diff --git a/requirements.txt b/requirements.txt index 538354d..cc29c1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,5 @@ lpips gdown # supports downloading the large file from Google Drive # cmake # dlib -# conda install -c conda-forge dlib \ No newline at end of file +# conda install -c conda-forge dlib +packaging \ No newline at end of file From e173d94b0310241d7f84d5b0fed34c243ab21b2d Mon Sep 17 00:00:00 2001 From: myd510 <1186325309@qq.com> Date: Tue, 31 Dec 2024 19:34:47 +0800 Subject: [PATCH 2/3] Only in higher versions, Replace disutils.version.LooseVersion with packaging.version.Version --- basicsr/archs/arch_util.py | 11 ++++++++--- readme.md | 3 ++- requirements.txt | 3 +-- requirements_312.txt | 21 +++++++++++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 requirements_312.txt diff --git a/basicsr/archs/arch_util.py b/basicsr/archs/arch_util.py index 3c68323..6bb7cb2 100644 --- a/basicsr/archs/arch_util.py +++ b/basicsr/archs/arch_util.py @@ -3,7 +3,12 @@ import math import torch import torchvision import warnings -from packaging.version import Version +import sys +if sys.version_info >= (3, 12): + from packaging.version import Version + LooseVersion = Version +else: + from distutils.version import LooseVersion from itertools import repeat from torch import nn as nn from torch.nn import functional as F @@ -228,7 +233,7 @@ class DCNv2Pack(ModulatedDeformConvPack): logger = get_root_logger() logger.warning(f'Offset abs mean is {offset_absmean}, larger than 50.') - if Version(torchvision.__version__) >= Version('0.9.0'): + if LooseVersion(torchvision.__version__) >= LooseVersion('0.9.0'): return torchvision.ops.deform_conv2d(x, offset, self.weight, self.bias, self.stride, self.padding, self.dilation, mask) else: @@ -315,4 +320,4 @@ to_1tuple = _ntuple(1) to_2tuple = _ntuple(2) to_3tuple = _ntuple(3) to_4tuple = _ntuple(4) -to_ntuple = _ntuple \ No newline at end of file +to_ntuple = _ntuple diff --git a/readme.md b/readme.md index 3ab1e53..21a542b 100644 --- a/readme.md +++ b/readme.md @@ -19,7 +19,8 @@ git clone https://github.com/mav-rik/facerestore_cf.git If running the portable windows version of ComfyUI, run embedded_install.bat Windows users not running the portable version can run install.bat. Linux and mac users can run install.sh. -If the install fails for whatever reason, you'll need to work out how to install opencv-python yourself (you'll get a cv2 not found error otherwise) +If the install fails for whatever reason, you'll need to work out how to install opencv-python yourself (you'll get a cv2 not found error otherwise). +If you are using Python3.12 or higher version, please use `requirements_312.txt`. diff --git a/requirements.txt b/requirements.txt index cc29c1d..538354d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,5 +17,4 @@ lpips gdown # supports downloading the large file from Google Drive # cmake # dlib -# conda install -c conda-forge dlib -packaging \ No newline at end of file +# conda install -c conda-forge dlib \ No newline at end of file diff --git a/requirements_312.txt b/requirements_312.txt new file mode 100644 index 0000000..4933b62 --- /dev/null +++ b/requirements_312.txt @@ -0,0 +1,21 @@ +opencv-python +numpy +torch +torchvision +addict +future +lmdb +Pillow +pyyaml +requests +scikit-image +scipy +tb-nightly +tqdm +yapf +lpips +gdown # supports downloading the large file from Google Drive +# cmake +# dlib +# conda install -c conda-forge dlib +requirements.txt \ No newline at end of file From 68044fd380e09ba60b6a93cb07d25d50d2b1058e Mon Sep 17 00:00:00 2001 From: myd510 <57065583+myd510@users.noreply.github.com> Date: Tue, 31 Dec 2024 19:49:25 +0800 Subject: [PATCH 3/3] Update requirements_312.txt --- requirements_312.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_312.txt b/requirements_312.txt index 4933b62..cc41849 100644 --- a/requirements_312.txt +++ b/requirements_312.txt @@ -18,4 +18,4 @@ gdown # supports downloading the large file from Google Drive # cmake # dlib # conda install -c conda-forge dlib -requirements.txt \ No newline at end of file +packaging