From 33b89576b819561bfe651553a6d98e8afe60bdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=9E=AB=EF=BC=88=E5=AE=9E=E4=B9=A0=EF=BC=89?= Date: Tue, 20 Oct 2020 15:52:09 +0800 Subject: [PATCH 1/3] feat(models): update ci --- .github/workflows/ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de1c5189..79a6b060 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,7 @@ name: CI # events but only for the master branch on: push: - branches: [ master ] pull_request: - branches: [ master ] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -37,13 +35,23 @@ jobs: pip install megengine -f https://megengine.org.cn/whl/mge.html # Runs a set of commands using the runners shell - - name: Pylint check + - name: Format check run: | export PYTHONPATH=$PWD:$PYTHONPATH + + CHECK_DIR=official/vision/detection pip install pylint==2.5.2 - pylint official/vision --rcfile=.pylintrc || pylint_ret=$? + pylint $CHECK_DIR --rcfile=.pylintrc || pylint_ret=$? echo test, and deploy your project. if [ "$pylint_ret" ]; then exit $pylint_ret fi echo "All lint steps passed!" + + pip3 install flake8==3.7.9 + flake8 $CHECK_DIR + echo "All flake check passed!" + + pip3 install isort==4.3.21 + isort --check-only -rc $CHECK_DIR + echo "All isort check passed!" From 97b913aca4e5603a7ac66d70e604d1128a4e92cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=9E=AB=EF=BC=88=E5=AE=9E=E4=B9=A0=EF=BC=89?= Date: Tue, 20 Oct 2020 17:36:25 +0800 Subject: [PATCH 2/3] fix(models): fix flake8 and isort in vision --- official/vision/classification/resnet/model.py | 11 +++++++---- .../vision/classification/shufflenet/model.py | 15 +++++++++++---- .../vision/classification/shufflenet/train.py | 2 +- official/vision/detection/configs/__init__.py | 12 ++++++------ .../vision/detection/layers/basic/functional.py | 6 ++++-- official/vision/detection/layers/det/sampling.py | 4 ++-- official/vision/detection/models/atss.py | 4 ++-- official/vision/detection/models/fcos.py | 3 ++- official/vision/detection/tools/test.py | 6 +----- official/vision/detection/tools/test_random.py | 2 +- official/vision/detection/tools/utils.py | 5 +++-- .../deeplabv3plus_res101_cityscapes_768size.py | 3 ++- .../configs/deeplabv3plus_res101_voc_512size.py | 3 ++- official/vision/segmentation/tools/test.py | 8 +++++--- official/vision/segmentation/tools/utils.py | 2 +- .isort.cfg => setup.cfg | 9 +++++++++ 16 files changed, 59 insertions(+), 36 deletions(-) rename .isort.cfg => setup.cfg (73%) diff --git a/official/vision/classification/resnet/model.py b/official/vision/classification/resnet/model.py index b9afb68a..6a953348 100644 --- a/official/vision/classification/resnet/model.py +++ b/official/vision/classification/resnet/model.py @@ -229,8 +229,9 @@ def __init__( M.init.uniform_(m.bias, -bound, bound) # Zero-initialize the last BN in each residual branch, - # so that the residual branch starts with zeros, and each residual block behaves like an identity. - # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677 + # so that the residual branch starts with zeros, and each residual block + # behaves like an identity. According to https://arxiv.org/abs/1706.02677 + # This improves the model by 0.2~0.3%. if zero_init_residual: for m in self.modules(): if isinstance(m, Bottleneck): @@ -356,7 +357,8 @@ def resnet152(**kwargs): ) def resnext50_32x4d(**kwargs): r"""ResNeXt-50 32x4d model from - `"Aggregated Residual Transformation for Deep Neural Networks" `_ + `"Aggregated Residual Transformation for Deep Neural Networks" + `_ Args: pretrained (bool): If True, returns a model pre-trained on ImageNet @@ -372,7 +374,8 @@ def resnext50_32x4d(**kwargs): ) def resnext101_32x8d(**kwargs): r"""ResNeXt-101 32x8d model from - `"Aggregated Residual Transformation for Deep Neural Networks" `_ + `"Aggregated Residual Transformation for Deep Neural Networks" + `_ Args: pretrained (bool): If True, returns a model pre-trained on ImageNet diff --git a/official/vision/classification/shufflenet/model.py b/official/vision/classification/shufflenet/model.py index 3d971eaf..1a3c2345 100644 --- a/official/vision/classification/shufflenet/model.py +++ b/official/vision/classification/shufflenet/model.py @@ -58,7 +58,10 @@ def __init__(self, inp, oup, mid_channels, *, ksize, stride): M.BatchNorm2d(mid_channels), M.ReLU(), # dw - M.Conv2d(mid_channels, mid_channels, ksize, stride, pad, groups=mid_channels, bias=False,), + M.Conv2d( + mid_channels, mid_channels, ksize, stride, pad, + groups=mid_channels, bias=False, + ), M.BatchNorm2d(mid_channels), # pw-linear M.Conv2d(mid_channels, outputs, 1, 1, 0, bias=False), @@ -135,13 +138,15 @@ def __init__(self, num_classes=1000, model_size="1.5x"): if i == 0: self.features.append( ShuffleV2Block( - input_channel, output_channel, mid_channels=output_channel // 2, ksize=3, stride=2, + input_channel, output_channel, + mid_channels=output_channel // 2, ksize=3, stride=2, ) ) else: self.features.append( ShuffleV2Block( - input_channel // 2, output_channel, mid_channels=output_channel // 2, ksize=3, stride=1, + input_channel // 2, output_channel, + mid_channels=output_channel // 2, ksize=3, stride=1, ) ) @@ -157,7 +162,9 @@ def __init__(self, num_classes=1000, model_size="1.5x"): self.globalpool = M.AvgPool2d(7) if self.model_size == "2.0x": self.dropout = M.Dropout(0.2) - self.classifier = M.Sequential(M.Linear(self.stage_out_channels[-1], num_classes, bias=False)) + self.classifier = M.Sequential( + M.Linear(self.stage_out_channels[-1], num_classes, bias=False) + ) self._initialize_weights() def forward(self, x): diff --git a/official/vision/classification/shufflenet/train.py b/official/vision/classification/shufflenet/train.py index cfe8fb98..648ba2f0 100644 --- a/official/vision/classification/shufflenet/train.py +++ b/official/vision/classification/shufflenet/train.py @@ -162,7 +162,7 @@ def worker(rank, world_size, ngpus_per_node, args): print("NOT include ", n, p.shape) params_nwd.append(p) opt = optim.SGD( - [{"params": params_wd}, {"params": params_nwd, "weight_decay": 0},], + [{"params": params_wd}, {"params": params_nwd, "weight_decay": 0}, ], lr=args.lr, momentum=args.momentum, weight_decay=args.weight_decay * world_size, # scale weight decay in "SUM" mode diff --git a/official/vision/detection/configs/__init__.py b/official/vision/detection/configs/__init__.py index 023fa844..792d7fe0 100644 --- a/official/vision/detection/configs/__init__.py +++ b/official/vision/detection/configs/__init__.py @@ -1,15 +1,15 @@ +from .atss_res50_coco_1x_800size import atss_res50_coco_1x_800size +from .atss_res101_coco_2x_800size import atss_res101_coco_2x_800size +from .atss_resx101_coco_2x_800size import atss_resx101_coco_2x_800size from .faster_rcnn_res50_coco_1x_800size import faster_rcnn_res50_coco_1x_800size from .faster_rcnn_res101_coco_2x_800size import faster_rcnn_res101_coco_2x_800size from .faster_rcnn_resx101_coco_2x_800size import faster_rcnn_resx101_coco_2x_800size -from .retinanet_res50_coco_1x_800size import retinanet_res50_coco_1x_800size -from .retinanet_res101_coco_2x_800size import retinanet_res101_coco_2x_800size -from .retinanet_resx101_coco_2x_800size import retinanet_resx101_coco_2x_800size from .fcos_res50_coco_1x_800size import fcos_res50_coco_1x_800size from .fcos_res101_coco_2x_800size import fcos_res101_coco_2x_800size from .fcos_resx101_coco_2x_800size import fcos_resx101_coco_2x_800size -from .atss_res50_coco_1x_800size import atss_res50_coco_1x_800size -from .atss_res101_coco_2x_800size import atss_res101_coco_2x_800size -from .atss_resx101_coco_2x_800size import atss_resx101_coco_2x_800size +from .retinanet_res50_coco_1x_800size import retinanet_res50_coco_1x_800size +from .retinanet_res101_coco_2x_800size import retinanet_res101_coco_2x_800size +from .retinanet_resx101_coco_2x_800size import retinanet_resx101_coco_2x_800size _EXCLUDE = {} __all__ = [k for k in globals().keys() if k not in _EXCLUDE and not k.startswith("_")] diff --git a/official/vision/detection/layers/basic/functional.py b/official/vision/detection/layers/basic/functional.py index 0d99c536..2cb9321d 100644 --- a/official/vision/detection/layers/basic/functional.py +++ b/official/vision/detection/layers/basic/functional.py @@ -52,9 +52,11 @@ def batched_nms( boxes: Tensor, scores: Tensor, idxs: Tensor, iou_thresh: float, max_output: Optional[int] = None ) -> Tensor: r""" - Performs non-maximum suppression (NMS) on the boxes according to their intersection-over-union (IoU). + Performs non-maximum suppression (NMS) on the boxes according to + their intersection-over-union (IoU). - :param boxes: tensor of shape `(N, 4)`; the boxes to perform nms on; each box is expected to be in `(x1, y1, x2, y2)` format. + :param boxes: tensor of shape `(N, 4)`; the boxes to perform nms on; + each box is expected to be in `(x1, y1, x2, y2)` format. :param iou_thresh: ``IoU`` threshold for overlapping. :param idxs: tensor of shape `(N,)`, the class indexs of boxes in the batch. :param scores: tensor of shape `(N,)`, the score of boxes. diff --git a/official/vision/detection/layers/det/sampling.py b/official/vision/detection/layers/det/sampling.py index 595d55a1..9d1de9d8 100644 --- a/official/vision/detection/layers/det/sampling.py +++ b/official/vision/detection/layers/det/sampling.py @@ -29,7 +29,7 @@ def sample_labels(labels, num_samples, label_value, ignore_label=-1): topk_tensor = F.zeros_like(labels).astype("float32") topk_tensor[mask] = uniform(size=num_class) - _, select_inds = F.topk(topk_tensor, k=num_samples-num_class) + _, select_inds = F.topk(topk_tensor, k=num_samples - num_class) labels[select_inds] = ignore_label return labels @@ -54,7 +54,7 @@ def sample_mask_from_labels(labels, num_sample, sample_value): return sample_mask random_tensor = sample_mask * uniform(size=labels.shape) - _, sampled_idx = F.topk(random_tensor, k=num_sample-num_mask) + _, sampled_idx = F.topk(random_tensor, k=num_sample - num_mask) sample_mask[sampled_idx] = F.zeros(sampled_idx.shape) return sample_mask diff --git a/official/vision/detection/models/atss.py b/official/vision/detection/models/atss.py index a26b77ff..d324fcc9 100644 --- a/official/vision/detection/models/atss.py +++ b/official/vision/detection/models/atss.py @@ -196,8 +196,8 @@ def get_ground_truth(self, anchors_list, batched_gt_boxes, batched_num_gts): candidate_idxs = F.concat(candidate_idxs, axis=1) candidate_ious = F.gather(ious, 1, candidate_idxs) - ious_thr = F.mean(candidate_ious, axis=1, keepdims=True) + \ - F.std(candidate_ious, axis=1, keepdims=True) + ious_thr = (F.mean(candidate_ious, axis=1, keepdims=True) + + F.std(candidate_ious, axis=1, keepdims=True)) is_foreground = F.scatter( F.zeros(ious.shape), 1, candidate_idxs, F.ones(candidate_idxs.shape) ).astype(bool) & (ious >= ious_thr) diff --git a/official/vision/detection/models/fcos.py b/official/vision/detection/models/fcos.py index ad77f8b0..1f182d08 100644 --- a/official/vision/detection/models/fcos.py +++ b/official/vision/detection/models/fcos.py @@ -210,7 +210,8 @@ def get_ground_truth(self, anchors_list, batched_gt_boxes, batched_num_gts): is_in_boxes = F.min(offsets, axis=2) > 0 gt_area = (gt_boxes[:, 2] - gt_boxes[:, 0]) * (gt_boxes[:, 3] - gt_boxes[:, 1]) - areas = F.broadcast_to(F.expand_dims(gt_area, axis=1), offsets.shape[:2]) # FIXME: repeat + # FIXME: use repeat instead of broadcast_to + areas = F.broadcast_to(F.expand_dims(gt_area, axis=1), offsets.shape[:2]) areas[~is_cared_in_the_level] = float("inf") areas[~is_in_boxes] = float("inf") diff --git a/official/vision/detection/tools/test.py b/official/vision/detection/tools/test.py index f6f0c61a..a43afdb8 100644 --- a/official/vision/detection/tools/test.py +++ b/official/vision/detection/tools/test.py @@ -17,11 +17,7 @@ from megengine.data import DataLoader from official.vision.detection.tools.data_mapper import data_mapper -from official.vision.detection.tools.utils import ( - InferenceSampler, - DetEvaluator, - import_from_file -) +from official.vision.detection.tools.utils import DetEvaluator, InferenceSampler, import_from_file logger = mge.get_logger(__name__) logger.setLevel("INFO") diff --git a/official/vision/detection/tools/test_random.py b/official/vision/detection/tools/test_random.py index 82cc0808..13df1c68 100644 --- a/official/vision/detection/tools/test_random.py +++ b/official/vision/detection/tools/test_random.py @@ -17,9 +17,9 @@ from megengine.data import DataLoader from official.vision.detection.tools.utils import ( + DetEvaluator, InferenceSampler, PseudoDetectionDataset, - DetEvaluator, import_from_file ) diff --git a/official/vision/detection/tools/utils.py b/official/vision/detection/tools/utils.py index d9b18f6a..930e6b68 100644 --- a/official/vision/detection/tools/utils.py +++ b/official/vision/detection/tools/utils.py @@ -18,11 +18,12 @@ from megengine.data import Collator, RandomSampler, Sampler from megengine.data.dataset import VisionDataset -# from megengine.jit import trace from official.vision.detection.tools.data_mapper import data_mapper from official.vision.detection.tools.nms import py_cpu_nms +# from megengine.jit import trace + class AverageMeter: """Computes and stores the average and current value""" @@ -116,7 +117,7 @@ def sample(self): def batch(self): step, length = self.batch_size, len(self.indices) - batch_index = [self.indices[i : i + step] for i in range(0, length, step)] + batch_index = [self.indices[i: i + step] for i in range(0, length, step)] return iter(batch_index) def __len__(self): diff --git a/official/vision/segmentation/configs/deeplabv3plus_res101_cityscapes_768size.py b/official/vision/segmentation/configs/deeplabv3plus_res101_cityscapes_768size.py index 8f559060..76d6a530 100644 --- a/official/vision/segmentation/configs/deeplabv3plus_res101_cityscapes_768size.py +++ b/official/vision/segmentation/configs/deeplabv3plus_res101_cityscapes_768size.py @@ -47,7 +47,8 @@ def __init__(self): ) def deeplabv3plus_res101_cityscapes_768size(**kwargs): r"""DeepLab v3+ model from - `"Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation" `_ + `"Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation" + `_ """ return models.DeepLabV3Plus(**kwargs) diff --git a/official/vision/segmentation/configs/deeplabv3plus_res101_voc_512size.py b/official/vision/segmentation/configs/deeplabv3plus_res101_voc_512size.py index f54c9136..29cd5aea 100644 --- a/official/vision/segmentation/configs/deeplabv3plus_res101_voc_512size.py +++ b/official/vision/segmentation/configs/deeplabv3plus_res101_voc_512size.py @@ -48,7 +48,8 @@ def __init__(self): ) def deeplabv3plus_res101_voc_512size(**kwargs): r"""DeepLab v3+ model from - `"Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation" `_ + `"Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation" + `_ """ return models.DeepLabV3Plus(**kwargs) diff --git a/official/vision/segmentation/tools/test.py b/official/vision/segmentation/tools/test.py index a35e201a..856365fc 100644 --- a/official/vision/segmentation/tools/test.py +++ b/official/vision/segmentation/tools/test.py @@ -18,7 +18,6 @@ import megengine.distributed as dist from megengine.data import DataLoader, dataset from megengine.data import transform as T -# from megengine.jit import trace from official.vision.segmentation.tools.utils import ( InferenceSampler, @@ -26,6 +25,9 @@ import_from_file ) +# from megengine.jit import trace + + logger = mge.get_logger(__name__) logger.setLevel("INFO") @@ -88,7 +90,6 @@ def main(): None, None, 1, 0, result_list ) - if cfg.val_save_path is not None: save_results(result_list, cfg.val_save_path, cfg) logger.info("Start evaluation!") @@ -141,7 +142,7 @@ def pred_func(data): result_list.append(result) -## inference one image +# inference one image def pad_image_to_shape(img, shape, border_mode, value): margin = np.zeros(4, np.uint32) pad_height = shape[0] - img.shape[0] if shape[0] - img.shape[0] > 0 else 0 @@ -303,6 +304,7 @@ def _trans_mask(self, mask): ] = i return label.astype(np.uint8) + def build_dataloader(rank, world_size, dataset_dir, cfg): if cfg.dataset == "VOC2012": val_dataset = EvalPascalVOC( diff --git a/official/vision/segmentation/tools/utils.py b/official/vision/segmentation/tools/utils.py index 20d2ae64..680e83bf 100644 --- a/official/vision/segmentation/tools/utils.py +++ b/official/vision/segmentation/tools/utils.py @@ -69,7 +69,7 @@ def sample(self): def batch(self): step, length = self.batch_size, len(self.indices) - batch_index = [self.indices[i : i + step] for i in range(0, length, step)] + batch_index = [self.indices[i: i + step] for i in range(0, length, step)] return iter(batch_index) def __len__(self): diff --git a/.isort.cfg b/setup.cfg similarity index 73% rename from .isort.cfg rename to setup.cfg index 26dd42c4..5ed2827c 100644 --- a/.isort.cfg +++ b/setup.cfg @@ -10,3 +10,12 @@ known_deeplearning = megengine sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,data_processing,datasets,deeplearning,myself,LOCALFOLDER no_lines_before=STDLIB,THIRDPARTY,datasets default_section = FIRSTPARTY + +[flake8] +ignore = W503 +max-line-length = 100 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 +exclude = build +per-file-ignores = + **/__init__.py:F401,F403 From c63a6654edbbbf95f4b077c4873e2eeac4d03b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=9E=AB=EF=BC=88=E5=AE=9E=E4=B9=A0=EF=BC=89?= Date: Tue, 20 Oct 2020 17:54:14 +0800 Subject: [PATCH 3/3] fix(models): fix pylint error and refine gitignore --- .github/workflows/ci.yml | 7 ++--- .gitignore | 29 ++++++++++++++++++- .../vision/classification/resnet/inference.py | 3 +- official/vision/classification/resnet/test.py | 3 +- .../vision/classification/resnet/train.py | 4 ++- .../classification/shufflenet/inference.py | 3 +- .../vision/classification/shufflenet/test.py | 3 +- .../vision/classification/shufflenet/train.py | 4 ++- official/vision/detection/__init__.py | 2 ++ official/vision/detection/tools/train.py | 1 - official/vision/detection/tools/utils.py | 2 -- official/vision/segmentation/tools/test.py | 3 -- official/vision/segmentation/tools/train.py | 1 - setup.cfg | 3 +- 14 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 official/vision/detection/__init__.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79a6b060..5f110d4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,14 +32,13 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install megengine -f https://megengine.org.cn/whl/mge.html # Runs a set of commands using the runners shell - name: Format check run: | export PYTHONPATH=$PWD:$PYTHONPATH - CHECK_DIR=official/vision/detection + CHECK_DIR=official/vision/ pip install pylint==2.5.2 pylint $CHECK_DIR --rcfile=.pylintrc || pylint_ret=$? echo test, and deploy your project. @@ -49,9 +48,9 @@ jobs: echo "All lint steps passed!" pip3 install flake8==3.7.9 - flake8 $CHECK_DIR + flake8 official echo "All flake check passed!" pip3 install isort==4.3.21 - isort --check-only -rc $CHECK_DIR + isort --check-only -rc official echo "All isort check passed!" diff --git a/.gitignore b/.gitignore index f1339d86..43a92391 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,31 @@ -__pycache__/ *log*/ +*.jpg +*.png +*.txt + +# compilation and distribution +__pycache__ +_ext +*.pyc *.so +build/ +dist/ +wheels/ + +# pytorch/python/numpy formats +*.pth *.pkl +*.npy + +# ipython/jupyter notebooks +*.ipynb +**/.ipynb_checkpoints/ + +# Editor temporaries +*.swn +*.swo +*.swp +*~ + +# Pycharm editor settings +.idea diff --git a/official/vision/classification/resnet/inference.py b/official/vision/classification/resnet/inference.py index 3a8d6104..89bfe57c 100644 --- a/official/vision/classification/resnet/inference.py +++ b/official/vision/classification/resnet/inference.py @@ -9,7 +9,8 @@ import argparse import json -import model as resnet_model # pylint-disable=import-error +# pylint: disable=import-error +import model as resnet_model import cv2 import numpy as np diff --git a/official/vision/classification/resnet/test.py b/official/vision/classification/resnet/test.py index d1878d06..e3335bde 100644 --- a/official/vision/classification/resnet/test.py +++ b/official/vision/classification/resnet/test.py @@ -10,7 +10,8 @@ import multiprocessing import time -import model as resnet_model # pylint-disable=import-error +# pylint: disable=import-error +import model as resnet_model import megengine import megengine.data as data diff --git a/official/vision/classification/resnet/train.py b/official/vision/classification/resnet/train.py index c8d7b7d2..41b80086 100644 --- a/official/vision/classification/resnet/train.py +++ b/official/vision/classification/resnet/train.py @@ -12,7 +12,8 @@ import os import time -import model as resnet_model # pylint-disable=import-error +# pylint: disable=import-error +import model as resnet_model import megengine import megengine.autodiff as autodiff @@ -117,6 +118,7 @@ def main(): def worker(rank, world_size, ngpus_per_node, args): + # pylint: disable=too-many-statements if rank == 0: os.makedirs(os.path.join(args.save, args.arch), exist_ok=True) megengine.logger.set_log_file(os.path.join(args.save, args.arch, "log.txt")) diff --git a/official/vision/classification/shufflenet/inference.py b/official/vision/classification/shufflenet/inference.py index 7d598daa..6709c5ef 100644 --- a/official/vision/classification/shufflenet/inference.py +++ b/official/vision/classification/shufflenet/inference.py @@ -9,7 +9,8 @@ import argparse import json -import model as snet_model # pylint-disable=import-error +# pylint: disable=import-error +import model as snet_model import cv2 import numpy as np diff --git a/official/vision/classification/shufflenet/test.py b/official/vision/classification/shufflenet/test.py index 8a2a428e..a5942882 100644 --- a/official/vision/classification/shufflenet/test.py +++ b/official/vision/classification/shufflenet/test.py @@ -10,7 +10,8 @@ import multiprocessing import time -import model as snet_model # pylint-disable=import-error +# pylint: disable=import-error +import model as snet_model import megengine import megengine.data as data diff --git a/official/vision/classification/shufflenet/train.py b/official/vision/classification/shufflenet/train.py index 648ba2f0..7f40ff00 100644 --- a/official/vision/classification/shufflenet/train.py +++ b/official/vision/classification/shufflenet/train.py @@ -11,7 +11,8 @@ import os import time -import model as snet_model # pylint-disable=import-error +# pylint: disable=import-error +import model as snet_model import megengine import megengine.autodiff as autodiff @@ -116,6 +117,7 @@ def main(): def worker(rank, world_size, ngpus_per_node, args): + # pylint: disable=too-many-statements if rank == 0: os.makedirs(os.path.join(args.save, args.arch), exist_ok=True) megengine.logger.set_log_file(os.path.join(args.save, args.arch, "log.txt")) diff --git a/official/vision/detection/__init__.py b/official/vision/detection/__init__.py new file mode 100644 index 00000000..b470e3a9 --- /dev/null +++ b/official/vision/detection/__init__.py @@ -0,0 +1,2 @@ +#!/usr/bin/python3 +# -*- coding:utf-8 -*- diff --git a/official/vision/detection/tools/train.py b/official/vision/detection/tools/train.py index 9ca6a8f7..4cbc713b 100644 --- a/official/vision/detection/tools/train.py +++ b/official/vision/detection/tools/train.py @@ -18,7 +18,6 @@ from megengine.autodiff import GradManager from megengine.data import DataLoader, Infinite, RandomSampler from megengine.data import transform as T -# from megengine.jit import trace from megengine.optimizer import SGD from official.vision.detection.tools.data_mapper import data_mapper diff --git a/official/vision/detection/tools/utils.py b/official/vision/detection/tools/utils.py index 930e6b68..a60ab6d9 100644 --- a/official/vision/detection/tools/utils.py +++ b/official/vision/detection/tools/utils.py @@ -22,8 +22,6 @@ from official.vision.detection.tools.data_mapper import data_mapper from official.vision.detection.tools.nms import py_cpu_nms -# from megengine.jit import trace - class AverageMeter: """Computes and stores the average and current value""" diff --git a/official/vision/segmentation/tools/test.py b/official/vision/segmentation/tools/test.py index 856365fc..6a6ab50e 100644 --- a/official/vision/segmentation/tools/test.py +++ b/official/vision/segmentation/tools/test.py @@ -25,9 +25,6 @@ import_from_file ) -# from megengine.jit import trace - - logger = mge.get_logger(__name__) logger.setLevel("INFO") diff --git a/official/vision/segmentation/tools/train.py b/official/vision/segmentation/tools/train.py index ff588943..8e335358 100644 --- a/official/vision/segmentation/tools/train.py +++ b/official/vision/segmentation/tools/train.py @@ -19,7 +19,6 @@ from megengine.autodiff import GradManager from megengine.data import DataLoader, Infinite, RandomSampler, dataset from megengine.data import transform as T -# from megengine.jit import trace from megengine.optimizer import SGD from official.vision.segmentation.tools.utils import AverageMeter, get_config_info, import_from_file diff --git a/setup.cfg b/setup.cfg index 5ed2827c..e36eeb0d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,6 @@ [isort] line_length = 100 +skip=official/quantization,official/vision/gan,official/vision/keypoints,official/nlp multi_line_output = 3 balanced_wrapping = True known_standard_library = setuptools @@ -16,6 +17,6 @@ ignore = W503 max-line-length = 100 max-complexity = 18 select = B,C,E,F,W,T4,B9 -exclude = build +exclude = official/quantization,official/vision/gan,official/vision/keypoints,official/nlp per-file-ignores = **/__init__.py:F401,F403