From 7b39dd5ca036ad3277224024472bab48aca11649 Mon Sep 17 00:00:00 2001 From: Ycr Date: Mon, 9 Nov 2020 16:01:01 +0800 Subject: [PATCH 1/3] SImplified chained-comparison. --- mmpose/datasets/pipelines/bottom_up_transform.py | 4 ++-- mmpose/models/backbones/regnet.py | 2 +- mmpose/models/backbones/resnet.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mmpose/datasets/pipelines/bottom_up_transform.py b/mmpose/datasets/pipelines/bottom_up_transform.py index 2cec1be4d3..86bf6ad212 100644 --- a/mmpose/datasets/pipelines/bottom_up_transform.py +++ b/mmpose/datasets/pipelines/bottom_up_transform.py @@ -165,8 +165,8 @@ def __call__(self, joints): tot = 0 for idx, pt in enumerate(joints[i]): x, y = int(pt[0]), int(pt[1]) - if (pt[2] > 0 and x >= 0 and y >= 0 and x < self.output_res - and y < self.output_res): + if (pt[2] > 0 and self.output_res > y >= 0 + and self.output_res > x >= 0): if self.tag_per_joint: visible_kpts[i][tot] = \ (idx * output_res**2 + y * output_res + x, 1) diff --git a/mmpose/models/backbones/regnet.py b/mmpose/models/backbones/regnet.py index 24825bcd41..8c93600491 100644 --- a/mmpose/models/backbones/regnet.py +++ b/mmpose/models/backbones/regnet.py @@ -132,7 +132,7 @@ def __init__(self, self.stem_channels = stem_channels self.base_channels = base_channels self.num_stages = num_stages - assert num_stages >= 1 and num_stages <= 4 + assert 4 >= num_stages >= 1 self.strides = strides self.dilations = dilations assert len(strides) == len(dilations) == num_stages diff --git a/mmpose/models/backbones/resnet.py b/mmpose/models/backbones/resnet.py index 14f2e80cc1..de929b5e1d 100644 --- a/mmpose/models/backbones/resnet.py +++ b/mmpose/models/backbones/resnet.py @@ -500,7 +500,7 @@ def __init__(self, self.stem_channels = stem_channels self.base_channels = base_channels self.num_stages = num_stages - assert num_stages >= 1 and num_stages <= 4 + assert 4 >= num_stages >= 1 self.strides = strides self.dilations = dilations assert len(strides) == len(dilations) == num_stages From e33481f9a8fddb72de0fe5713698a12113cfce58 Mon Sep 17 00:00:00 2001 From: Ycr Date: Wed, 11 Nov 2020 13:02:21 +0800 Subject: [PATCH 2/3] Modified following mentor's convention. --- mmpose/datasets/pipelines/bottom_up_transform.py | 4 ++-- mmpose/models/backbones/regnet.py | 2 +- mmpose/models/backbones/resnet.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mmpose/datasets/pipelines/bottom_up_transform.py b/mmpose/datasets/pipelines/bottom_up_transform.py index 86bf6ad212..c3585b214e 100644 --- a/mmpose/datasets/pipelines/bottom_up_transform.py +++ b/mmpose/datasets/pipelines/bottom_up_transform.py @@ -165,8 +165,8 @@ def __call__(self, joints): tot = 0 for idx, pt in enumerate(joints[i]): x, y = int(pt[0]), int(pt[1]) - if (pt[2] > 0 and self.output_res > y >= 0 - and self.output_res > x >= 0): + if (pt[2] > 0 and 0 <= y < self.output_res + and 0 <= x < self.output_res): if self.tag_per_joint: visible_kpts[i][tot] = \ (idx * output_res**2 + y * output_res + x, 1) diff --git a/mmpose/models/backbones/regnet.py b/mmpose/models/backbones/regnet.py index 8c93600491..f5fcf74de0 100644 --- a/mmpose/models/backbones/regnet.py +++ b/mmpose/models/backbones/regnet.py @@ -132,7 +132,7 @@ def __init__(self, self.stem_channels = stem_channels self.base_channels = base_channels self.num_stages = num_stages - assert 4 >= num_stages >= 1 + assert 1 <= num_stages <= 4 self.strides = strides self.dilations = dilations assert len(strides) == len(dilations) == num_stages diff --git a/mmpose/models/backbones/resnet.py b/mmpose/models/backbones/resnet.py index de929b5e1d..f6a5bb74c6 100644 --- a/mmpose/models/backbones/resnet.py +++ b/mmpose/models/backbones/resnet.py @@ -500,7 +500,7 @@ def __init__(self, self.stem_channels = stem_channels self.base_channels = base_channels self.num_stages = num_stages - assert 4 >= num_stages >= 1 + assert 1 <= num_stages <= 4 self.strides = strides self.dilations = dilations assert len(strides) == len(dilations) == num_stages From 38c9f102ab064017053406e47497facce110d85d Mon Sep 17 00:00:00 2001 From: Ycr Date: Wed, 11 Nov 2020 13:07:35 +0800 Subject: [PATCH 3/3] Pre-commit. --- mmpose/datasets/pipelines/bottom_up_transform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmpose/datasets/pipelines/bottom_up_transform.py b/mmpose/datasets/pipelines/bottom_up_transform.py index c3585b214e..89e31a8397 100644 --- a/mmpose/datasets/pipelines/bottom_up_transform.py +++ b/mmpose/datasets/pipelines/bottom_up_transform.py @@ -166,7 +166,7 @@ def __call__(self, joints): for idx, pt in enumerate(joints[i]): x, y = int(pt[0]), int(pt[1]) if (pt[2] > 0 and 0 <= y < self.output_res - and 0 <= x < self.output_res): + and 0 <= x < self.output_res): if self.tag_per_joint: visible_kpts[i][tot] = \ (idx * output_res**2 + y * output_res + x, 1)