From e2198fb57de565ade84166fe4a969b8fcfd1c48d Mon Sep 17 00:00:00 2001 From: Vladimir Iglovikov Date: Mon, 24 Jan 2022 11:30:18 -0800 Subject: [PATCH 1/4] bugfixes --- .pre-commit-config.yaml | 4 ++-- requirements_dev.txt | 43 ++++++------------------------------ retinaface/box_utils.py | 2 +- retinaface/predict_single.py | 2 +- 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7eb2083..458ecf3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,11 +10,11 @@ repos: - id: isort args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 21.6b0 + rev: 21.12b0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 + rev: 4.0.1 hooks: - id: flake8 language_version: python3 diff --git a/requirements_dev.txt b/requirements_dev.txt index f9669bd..59954e9 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,42 +1,13 @@ -black==21.6b0 -flake8==3.9.2 -flake8-bandit==2.1.2 -flake8-breakpoint==1.1.0 -flake8-bugbear==21.3.1 -flake8-builtins==1.5.3 -flake8-colors==0.1.9 -flake8-comprehensions==3.3.1 -flake8-debugger==4.0.0 -flake8-docstrings==1.5.0 -flake8-eradicate==1.0.0 -flake8-executable==2.1.1 -flake8-fixme==1.1.1 -flake8-graphql==0.2.5 -flake8-implicit-str-concat==0.2.0 -flake8-logging-format==0.6.0 -flake8-mock==0.3 -flake8-pathlib==0.1.3 -flake8-plugin-utils==1.3.1 -flake8-polyfill==1.0.2 -flake8-print==4.0.0 -flake8-printf-formatting==1.1.2 -flake8-pytest==1.3 -flake8-pytest-style==1.3.0 -flake8-raise==0.0.5 -flake8-requests==0.4.0 -flake8-requirements==1.3.3 -flake8-string-format==0.3.0 -flake8-tidy-imports==4.2.1 -flake8-todo==0.7 -flake8-tuple==0.4.1 +black==21.12b0 +flake8==4.0.1 iglovikov-helper-functions==0.0.53 -isort==5.8.0 -mypy==0.910 +isort==5.10.1 +mypy==0.931 onnx==1.9.0 pep8-naming==0.11.1 -pip==21.1.3 -pre-commit==2.13.0 -pylint==2.8.2 +pip==21.3.1 +pre_commit==2.17.0 +pylint==2.12.2 pytest==6.2.4 pytest-asyncio==0.15.1 pytest-clarity==0.3.0a0 diff --git a/retinaface/box_utils.py b/retinaface/box_utils.py index e7db45c..18ab437 100644 --- a/retinaface/box_utils.py +++ b/retinaface/box_utils.py @@ -196,7 +196,7 @@ def encode_landm( priors = torch.cat([priors_cx, priors_cy, priors_w, priors_h], dim=2) g_cxcy = matched[:, :, :2] - priors[:, :, :2] # encode variance - g_cxcy = g_cxcy // variances[0] * priors[:, :, 2:] + g_cxcy /= variances[0] * priors[:, :, 2:] # return target for smooth_l1_loss return g_cxcy.reshape(g_cxcy.size(0), -1) diff --git a/retinaface/predict_single.py b/retinaface/predict_single.py index 8a029eb..6f3f230 100644 --- a/retinaface/predict_single.py +++ b/retinaface/predict_single.py @@ -94,7 +94,7 @@ def predict_jsons( landmarks_np = landmarks.cpu().numpy() resize_coeff = original_height / transformed_height - boxes *= resize_coeff + boxes_np *= resize_coeff landmarks_np = landmarks_np.reshape(-1, 10) * resize_coeff for box_id, bbox in enumerate(boxes_np): From b7c35f1b14f437fc8f7fc8caadf3372ed64c82bf Mon Sep 17 00:00:00 2001 From: Vladimir Iglovikov Date: Mon, 24 Jan 2022 11:31:04 -0800 Subject: [PATCH 2/4] bugfixes --- retinaface/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retinaface/__init__.py b/retinaface/__init__.py index 6526deb..a73339b 100644 --- a/retinaface/__init__.py +++ b/retinaface/__init__.py @@ -1 +1 @@ -__version__ = "0.0.7" +__version__ = "0.0.8" From 852f9cd8613cee68860dd22852f32b6375b30b52 Mon Sep 17 00:00:00 2001 From: Vladimir Iglovikov Date: Mon, 24 Jan 2022 11:34:34 -0800 Subject: [PATCH 3/4] cleanup --- retinaface/train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retinaface/train.py b/retinaface/train.py index 30c9e8a..63b2933 100644 --- a/retinaface/train.py +++ b/retinaface/train.py @@ -49,7 +49,7 @@ def __init__(self, config: Adict[str, Any]) -> None: self.loss = object_from_dict(self.config.loss, priors=self.prior_box) - def setup(self, state=0) -> None: # type: ignore + def setup(self, stage=0) -> None: # type: ignore self.preproc = Preproc(img_dim=self.config.image_size[0]) def forward(self, batch: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]: # type: ignore From 5f0419319fe76097f5a144320219a7aa8442ee6a Mon Sep 17 00:00:00 2001 From: Vladimir Iglovikov Date: Mon, 24 Jan 2022 11:42:43 -0800 Subject: [PATCH 4/4] ignore mypy errors --- retinaface/inference.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retinaface/inference.py b/retinaface/inference.py index 9204e68..1c32350 100644 --- a/retinaface/inference.py +++ b/retinaface/inference.py @@ -90,9 +90,9 @@ def unnormalize(image: Union[np.ndarray, torch.Tensor]) -> Union[np.ndarray, tor std = [0.229, 0.224, 0.225] for c in range(image.shape[-1]): - image[:, :, c] *= std[c] - image[:, :, c] += mean[c] - image[:, :, c] *= 255 + image[:, :, c] *= std[c] # type: ignore + image[:, :, c] += mean[c] # type: ignore + image[:, :, c] *= 255 # type: ignore return image