From 948de9d735b88d70114c0f5d7c217b1c02f4e669 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 31 May 2024 21:07:05 +0200 Subject: [PATCH 1/2] Replace `distutils` with `packaging` --- pyproject.toml | 1 + thop/profile.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 76dbb35..14ca824 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ classifiers = [ "Operating System :: Microsoft :: Windows", ] dependencies = [ + "packaging", "torch", ] diff --git a/thop/profile.py b/thop/profile.py index d8451a9..55f2f05 100644 --- a/thop/profile.py +++ b/thop/profile.py @@ -1,4 +1,4 @@ -from distutils.version import LooseVersion +from packaging.version import Version from thop.rnn_hooks import * from thop.vision.basic_hooks import * @@ -7,7 +7,7 @@ # logger.setLevel(logging.INFO) from .utils import prGreen, prRed, prYellow -if LooseVersion(torch.__version__) < LooseVersion("1.0.0"): +if Version(torch.__version__) < Version("1.0.0"): logging.warning( "You are using an old version PyTorch {version}, which THOP does NOT support.".format(version=torch.__version__) ) @@ -61,7 +61,7 @@ nn.PixelShuffle: zero_ops, } -if LooseVersion(torch.__version__) >= LooseVersion("1.1.0"): +if Version(torch.__version__) >= Version("1.1.0"): register_hooks.update({nn.SyncBatchNorm: count_normalization}) From d9c1decc4e3bfa2e41620c5998b6aa4292ab1b29 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 31 May 2024 21:07:27 +0200 Subject: [PATCH 2/2] Replace `distutils` with `packaging` --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 14ca824..5e77e85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ build-backend = "setuptools.build_meta" [project] name = "ultralytics-thop" -version = "0.0.2" # Placeholder version, needs to be dynamically set +version = "0.0.3" # Placeholder version, needs to be dynamically set description = "A tool to count the FLOPs of PyTorch model." readme = "README.md" requires-python = ">=3.8"