From aa5d9c8f35fc3fac68280feb7f019b57d61c2543 Mon Sep 17 00:00:00 2001 From: Jiamin Date: Mon, 20 Jul 2020 21:42:43 +0800 Subject: [PATCH] style: update first party import (#115) --- demo/generation_demo.py | 1 + demo/inpainting_demo.py | 1 + demo/matting_demo.py | 1 + demo/restoration_demo.py | 1 + mmedit/apis/generation_inference.py | 1 + mmedit/apis/inpainting_inference.py | 1 + mmedit/apis/matting_inference.py | 1 + mmedit/apis/restoration_inference.py | 1 + mmedit/apis/train.py | 1 + mmedit/datasets/pipelines/loading.py | 2 +- .../backbones/encoder_decoders/decoders/deepfill_decoder.py | 1 + .../models/backbones/encoder_decoders/decoders/gl_decoder.py | 1 + .../backbones/encoder_decoders/decoders/indexnet_decoder.py | 1 + .../backbones/encoder_decoders/decoders/pconv_decoder.py | 1 + .../backbones/encoder_decoders/decoders/plain_decoder.py | 1 + .../models/backbones/encoder_decoders/decoders/resnet_dec.py | 2 +- .../backbones/encoder_decoders/encoders/deepfill_encoder.py | 1 + .../models/backbones/encoder_decoders/encoders/gl_encoder.py | 1 + .../backbones/encoder_decoders/encoders/indexnet_encoder.py | 1 + .../backbones/encoder_decoders/encoders/pconv_encoder.py | 1 + .../models/backbones/encoder_decoders/encoders/resnet_enc.py | 1 + mmedit/models/backbones/encoder_decoders/encoders/vgg.py | 1 + mmedit/models/backbones/encoder_decoders/gl_encoder_decoder.py | 1 + .../encoder_decoders/necks/contextual_attention_neck.py | 1 + mmedit/models/backbones/encoder_decoders/necks/gl_dilation.py | 1 + .../models/backbones/encoder_decoders/pconv_encoder_decoder.py | 1 + .../backbones/encoder_decoders/simple_encoder_decoder.py | 1 + .../backbones/encoder_decoders/two_stage_encoder_decoder.py | 1 + .../models/backbones/generation_backbones/resnet_generator.py | 1 + mmedit/models/backbones/generation_backbones/unet_generator.py | 1 + mmedit/models/backbones/sr_backbones/edsr.py | 1 + mmedit/models/backbones/sr_backbones/edvr_net.py | 3 ++- mmedit/models/backbones/sr_backbones/rrdb_net.py | 1 + mmedit/models/backbones/sr_backbones/sr_resnet.py | 1 + mmedit/models/backbones/sr_backbones/srcnn.py | 1 + mmedit/models/backbones/sr_backbones/tof.py | 1 + mmedit/models/components/discriminators/deepfill_disc.py | 1 + mmedit/models/components/discriminators/gl_disc.py | 2 +- mmedit/models/components/discriminators/modified_vgg.py | 1 + mmedit/models/components/discriminators/multi_layer_disc.py | 1 + mmedit/models/components/discriminators/patch_disc.py | 1 + mmedit/models/components/refiners/deepfill_refiner.py | 1 + mmedit/models/components/refiners/plain_refiner.py | 1 + mmedit/models/inpaintors/one_stage.py | 2 +- mmedit/models/inpaintors/pconv_inpaintor.py | 2 +- mmedit/models/inpaintors/two_stage.py | 2 +- mmedit/models/losses/perceptual_loss.py | 2 +- mmedit/models/mattors/base_mattor.py | 2 +- mmedit/models/restorers/basic_restorer.py | 2 +- mmedit/models/restorers/edvr.py | 2 +- mmedit/models/synthesizers/cycle_gan.py | 2 +- mmedit/models/synthesizers/pix2pix.py | 2 +- setup.cfg | 2 +- tests/test_augmentation.py | 1 + tests/test_base_model.py | 1 + tests/test_basic_restorer.py | 1 + tests/test_common_module.py | 1 + tests/test_compose.py | 1 + tests/test_crop.py | 1 + tests/test_cyclegan.py | 1 + tests/test_dataset_builder.py | 3 ++- tests/test_datasets.py | 3 ++- tests/test_decoders.py | 1 + tests/test_deepfill_decoder.py | 1 + tests/test_deepfill_disc.py | 1 + tests/test_deepfill_encdec.py | 1 + tests/test_deepfill_encoder.py | 1 + tests/test_deepfill_inpaintor.py | 1 + tests/test_deepfill_refiner.py | 1 + tests/test_discriminators.py | 1 + tests/test_duf.py | 1 + tests/test_edvr_model.py | 1 + tests/test_edvr_net.py | 1 + tests/test_encoder_decoder.py | 1 + tests/test_encoders.py | 1 + tests/test_esrgan.py | 1 + tests/test_eval_hook.py | 3 ++- tests/test_flow_warp.py | 1 + tests/test_formating.py | 1 + tests/test_generators.py | 1 + tests/test_gl_inpaintor.py | 1 + tests/test_gl_model.py | 1 + tests/test_loading.py | 1 + tests/test_losses.py | 1 + tests/test_mask_generation.py | 1 + tests/test_matting_refiners.py | 1 + tests/test_mattors.py | 1 + tests/test_metrics.py | 1 + tests/test_model_utils.py | 1 + tests/test_multi_layer_disc.py | 1 + tests/test_normalization.py | 1 + tests/test_one_stage_inpaintor.py | 1 + tests/test_optimizer.py | 1 + tests/test_pconv_encdec.py | 1 + tests/test_pconv_inpaintor.py | 1 + tests/test_pipeline_utils.py | 1 + tests/test_pix2pix.py | 1 + tests/test_sr_backbones.py | 1 + tests/test_srgan.py | 1 + tests/test_tensor2img.py | 3 ++- tests/test_tof.py | 1 + tests/test_trimap.py | 1 + tests/test_two_stage_inpaintor.py | 1 + tests/test_visual_hook.py | 3 ++- tools/evaluate_comp1k.py | 1 + tools/get_flops.py | 1 + tools/test.py | 1 + tools/train.py | 1 + 108 files changed, 114 insertions(+), 19 deletions(-) diff --git a/demo/generation_demo.py b/demo/generation_demo.py index 7684a2ef0c..738d2b0b61 100644 --- a/demo/generation_demo.py +++ b/demo/generation_demo.py @@ -2,6 +2,7 @@ import mmcv import torch + from mmedit.apis import generation_inference, init_model diff --git a/demo/inpainting_demo.py b/demo/inpainting_demo.py index 169246f3fc..8db2e7a46d 100644 --- a/demo/inpainting_demo.py +++ b/demo/inpainting_demo.py @@ -2,6 +2,7 @@ import mmcv import torch + from mmedit.apis import init_model, inpainting_inference from mmedit.core import tensor2img diff --git a/demo/matting_demo.py b/demo/matting_demo.py index da9137bc2d..5c020de8f8 100644 --- a/demo/matting_demo.py +++ b/demo/matting_demo.py @@ -2,6 +2,7 @@ import mmcv import torch + from mmedit.apis import init_model, matting_inference diff --git a/demo/restoration_demo.py b/demo/restoration_demo.py index e97dc39c30..0bc26c0bb7 100644 --- a/demo/restoration_demo.py +++ b/demo/restoration_demo.py @@ -2,6 +2,7 @@ import mmcv import torch + from mmedit.apis import init_model, restoration_inference from mmedit.core import tensor2img diff --git a/mmedit/apis/generation_inference.py b/mmedit/apis/generation_inference.py index 9e0b727263..2e9facde2b 100644 --- a/mmedit/apis/generation_inference.py +++ b/mmedit/apis/generation_inference.py @@ -1,6 +1,7 @@ import numpy as np import torch from mmcv.parallel import collate, scatter + from mmedit.core import tensor2img from mmedit.datasets.pipelines import Compose diff --git a/mmedit/apis/inpainting_inference.py b/mmedit/apis/inpainting_inference.py index 865bb5d28d..0c6bfbc7be 100644 --- a/mmedit/apis/inpainting_inference.py +++ b/mmedit/apis/inpainting_inference.py @@ -1,5 +1,6 @@ import torch from mmcv.parallel import collate, scatter + from mmedit.datasets.pipelines import Compose diff --git a/mmedit/apis/matting_inference.py b/mmedit/apis/matting_inference.py index c1b5b96a2c..e669716d00 100644 --- a/mmedit/apis/matting_inference.py +++ b/mmedit/apis/matting_inference.py @@ -2,6 +2,7 @@ import torch from mmcv.parallel import collate, scatter from mmcv.runner import load_checkpoint + from mmedit.datasets.pipelines import Compose from mmedit.models import build_model diff --git a/mmedit/apis/restoration_inference.py b/mmedit/apis/restoration_inference.py index b56a603d44..0f4b5ad104 100644 --- a/mmedit/apis/restoration_inference.py +++ b/mmedit/apis/restoration_inference.py @@ -1,5 +1,6 @@ import torch from mmcv.parallel import collate, scatter + from mmedit.datasets.pipelines import Compose diff --git a/mmedit/apis/train.py b/mmedit/apis/train.py index c955b7aa6f..72df80c53b 100644 --- a/mmedit/apis/train.py +++ b/mmedit/apis/train.py @@ -7,6 +7,7 @@ import torch from mmcv.parallel import MMDataParallel from mmcv.runner import HOOKS, IterBasedRunner + from mmedit.core import DistEvalIterHook, EvalIterHook, build_optimizers from mmedit.core.distributed_wrapper import DistributedDataParallelWrapper from mmedit.datasets.builder import build_dataloader, build_dataset diff --git a/mmedit/datasets/pipelines/loading.py b/mmedit/datasets/pipelines/loading.py index 4f94124c2c..504c471ac5 100644 --- a/mmedit/datasets/pipelines/loading.py +++ b/mmedit/datasets/pipelines/loading.py @@ -3,9 +3,9 @@ import mmcv import numpy as np from mmcv.fileio import FileClient + from mmedit.core.mask import (bbox2mask, brush_stroke_mask, get_irregular_mask, random_bbox) - from ..registry import PIPELINES diff --git a/mmedit/models/backbones/encoder_decoders/decoders/deepfill_decoder.py b/mmedit/models/backbones/encoder_decoders/decoders/deepfill_decoder.py index 9afe76e2f3..ece212a6be 100644 --- a/mmedit/models/backbones/encoder_decoders/decoders/deepfill_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/decoders/deepfill_decoder.py @@ -5,6 +5,7 @@ import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule, build_activation_layer + from mmedit.models.common import SimpleGatedConvModule from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/decoders/gl_decoder.py b/mmedit/models/backbones/encoder_decoders/decoders/gl_decoder.py index c7cb674653..f27e2e6782 100644 --- a/mmedit/models/backbones/encoder_decoders/decoders/gl_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/decoders/gl_decoder.py @@ -3,6 +3,7 @@ import torch import torch.nn as nn from mmcv.cnn import ConvModule + from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/decoders/indexnet_decoder.py b/mmedit/models/backbones/encoder_decoders/decoders/indexnet_decoder.py index 0339f56e1d..ebd8593ed4 100644 --- a/mmedit/models/backbones/encoder_decoders/decoders/indexnet_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/decoders/indexnet_decoder.py @@ -4,6 +4,7 @@ import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule, kaiming_init, normal_init + from mmedit.models.common import DepthwiseSeparableConvModule from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/decoders/pconv_decoder.py b/mmedit/models/backbones/encoder_decoders/decoders/pconv_decoder.py index 415bb444f3..c61413c052 100644 --- a/mmedit/models/backbones/encoder_decoders/decoders/pconv_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/decoders/pconv_decoder.py @@ -1,6 +1,7 @@ import torch import torch.nn as nn import torch.nn.functional as F + from mmedit.models.common import MaskConvModule from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/decoders/plain_decoder.py b/mmedit/models/backbones/encoder_decoders/decoders/plain_decoder.py index 54d451429f..181c1182f8 100644 --- a/mmedit/models/backbones/encoder_decoders/decoders/plain_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/decoders/plain_decoder.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.cnn.utils.weight_init import xavier_init + from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/decoders/resnet_dec.py b/mmedit/models/backbones/encoder_decoders/decoders/resnet_dec.py index a43c0db19b..1db268d945 100644 --- a/mmedit/models/backbones/encoder_decoders/decoders/resnet_dec.py +++ b/mmedit/models/backbones/encoder_decoders/decoders/resnet_dec.py @@ -1,8 +1,8 @@ import torch.nn as nn from mmcv.cnn import ConvModule, constant_init + from mmedit.models.common import GCAModule from mmedit.models.registry import COMPONENTS - from ..encoders.resnet_enc import BasicBlock diff --git a/mmedit/models/backbones/encoder_decoders/encoders/deepfill_encoder.py b/mmedit/models/backbones/encoder_decoders/encoders/deepfill_encoder.py index 7cfd67ca60..5aa61aebb4 100644 --- a/mmedit/models/backbones/encoder_decoders/encoders/deepfill_encoder.py +++ b/mmedit/models/backbones/encoder_decoders/encoders/deepfill_encoder.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.cnn import ConvModule + from mmedit.models.common import SimpleGatedConvModule from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/encoders/gl_encoder.py b/mmedit/models/backbones/encoder_decoders/encoders/gl_encoder.py index 8b3b96031e..57fdbb6a62 100644 --- a/mmedit/models/backbones/encoder_decoders/encoders/gl_encoder.py +++ b/mmedit/models/backbones/encoder_decoders/encoders/gl_encoder.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.cnn import ConvModule + from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/encoders/indexnet_encoder.py b/mmedit/models/backbones/encoder_decoders/encoders/indexnet_encoder.py index 63784e3370..3d8caf3c78 100644 --- a/mmedit/models/backbones/encoder_decoders/encoders/indexnet_encoder.py +++ b/mmedit/models/backbones/encoder_decoders/encoders/indexnet_encoder.py @@ -6,6 +6,7 @@ from mmcv.cnn import ConvModule, constant_init, xavier_init from mmcv.runner import load_checkpoint from mmcv.utils.parrots_wrapper import SyncBatchNorm + from mmedit.models.common import ASPP, DepthwiseSeparableConvModule from mmedit.models.registry import COMPONENTS from mmedit.utils import get_root_logger diff --git a/mmedit/models/backbones/encoder_decoders/encoders/pconv_encoder.py b/mmedit/models/backbones/encoder_decoders/encoders/pconv_encoder.py index 52f3c2c16e..d612c1600d 100644 --- a/mmedit/models/backbones/encoder_decoders/encoders/pconv_encoder.py +++ b/mmedit/models/backbones/encoder_decoders/encoders/pconv_encoder.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.utils.parrots_wrapper import _BatchNorm + from mmedit.models.common import MaskConvModule from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/encoders/resnet_enc.py b/mmedit/models/backbones/encoder_decoders/encoders/resnet_enc.py index 6909d7ad49..dc5aa4cee5 100644 --- a/mmedit/models/backbones/encoder_decoders/encoders/resnet_enc.py +++ b/mmedit/models/backbones/encoder_decoders/encoders/resnet_enc.py @@ -2,6 +2,7 @@ import torch.nn.functional as F from mmcv.cnn import ConvModule, build_activation_layer, constant_init from mmcv.runner import load_checkpoint + from mmedit.models.common import GCAModule from mmedit.models.registry import COMPONENTS from mmedit.utils.logger import get_root_logger diff --git a/mmedit/models/backbones/encoder_decoders/encoders/vgg.py b/mmedit/models/backbones/encoder_decoders/encoders/vgg.py index 17cc9a5c45..b14f03d131 100644 --- a/mmedit/models/backbones/encoder_decoders/encoders/vgg.py +++ b/mmedit/models/backbones/encoder_decoders/encoders/vgg.py @@ -1,6 +1,7 @@ import torch.nn as nn from mmcv.cnn.utils.weight_init import constant_init, xavier_init from mmcv.runner import load_checkpoint + from mmedit.models.common import ASPP from mmedit.models.registry import COMPONENTS from mmedit.utils import get_root_logger diff --git a/mmedit/models/backbones/encoder_decoders/gl_encoder_decoder.py b/mmedit/models/backbones/encoder_decoders/gl_encoder_decoder.py index 6517de1be2..c2f243484b 100644 --- a/mmedit/models/backbones/encoder_decoders/gl_encoder_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/gl_encoder_decoder.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.runner import load_checkpoint + from mmedit.models.builder import build_component from mmedit.models.registry import BACKBONES from mmedit.utils import get_root_logger diff --git a/mmedit/models/backbones/encoder_decoders/necks/contextual_attention_neck.py b/mmedit/models/backbones/encoder_decoders/necks/contextual_attention_neck.py index 7d81f33cf5..535527c32d 100644 --- a/mmedit/models/backbones/encoder_decoders/necks/contextual_attention_neck.py +++ b/mmedit/models/backbones/encoder_decoders/necks/contextual_attention_neck.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.cnn import ConvModule + from mmedit.models.common import SimpleGatedConvModule from mmedit.models.common.contextual_attention import ContextualAttentionModule from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/necks/gl_dilation.py b/mmedit/models/backbones/encoder_decoders/necks/gl_dilation.py index 3183774520..d6510df3e2 100644 --- a/mmedit/models/backbones/encoder_decoders/necks/gl_dilation.py +++ b/mmedit/models/backbones/encoder_decoders/necks/gl_dilation.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.cnn import ConvModule + from mmedit.models.common import SimpleGatedConvModule from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/backbones/encoder_decoders/pconv_encoder_decoder.py b/mmedit/models/backbones/encoder_decoders/pconv_encoder_decoder.py index 1bdabefa0c..5cb906f7ff 100644 --- a/mmedit/models/backbones/encoder_decoders/pconv_encoder_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/pconv_encoder_decoder.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.runner import load_checkpoint + from mmedit.models.builder import build_component from mmedit.models.registry import BACKBONES from mmedit.utils import get_root_logger diff --git a/mmedit/models/backbones/encoder_decoders/simple_encoder_decoder.py b/mmedit/models/backbones/encoder_decoders/simple_encoder_decoder.py index 48687a997d..a3de3f61bc 100644 --- a/mmedit/models/backbones/encoder_decoders/simple_encoder_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/simple_encoder_decoder.py @@ -1,4 +1,5 @@ import torch.nn as nn + from mmedit.models.builder import build_component from mmedit.models.registry import BACKBONES diff --git a/mmedit/models/backbones/encoder_decoders/two_stage_encoder_decoder.py b/mmedit/models/backbones/encoder_decoders/two_stage_encoder_decoder.py index 9ce4209ab9..11a925726c 100644 --- a/mmedit/models/backbones/encoder_decoders/two_stage_encoder_decoder.py +++ b/mmedit/models/backbones/encoder_decoders/two_stage_encoder_decoder.py @@ -3,6 +3,7 @@ from mmcv.cnn import constant_init, normal_init from mmcv.runner import load_checkpoint from mmcv.utils.parrots_wrapper import _BatchNorm + from mmedit.models.builder import build_backbone, build_component from mmedit.models.registry import BACKBONES from mmedit.utils import get_root_logger diff --git a/mmedit/models/backbones/generation_backbones/resnet_generator.py b/mmedit/models/backbones/generation_backbones/resnet_generator.py index d62aa95622..6a4716171f 100644 --- a/mmedit/models/backbones/generation_backbones/resnet_generator.py +++ b/mmedit/models/backbones/generation_backbones/resnet_generator.py @@ -1,6 +1,7 @@ import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import load_checkpoint + from mmedit.models.common import (ResidualBlockWithDropout, generation_init_weights) from mmedit.models.registry import BACKBONES diff --git a/mmedit/models/backbones/generation_backbones/unet_generator.py b/mmedit/models/backbones/generation_backbones/unet_generator.py index e3e8b8c1f9..9ba3d25c9b 100644 --- a/mmedit/models/backbones/generation_backbones/unet_generator.py +++ b/mmedit/models/backbones/generation_backbones/unet_generator.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.runner import load_checkpoint + from mmedit.models.common import (UnetSkipConnectionBlock, generation_init_weights) from mmedit.models.registry import BACKBONES diff --git a/mmedit/models/backbones/sr_backbones/edsr.py b/mmedit/models/backbones/sr_backbones/edsr.py index 038b794864..d201a5439a 100644 --- a/mmedit/models/backbones/sr_backbones/edsr.py +++ b/mmedit/models/backbones/sr_backbones/edsr.py @@ -3,6 +3,7 @@ import torch import torch.nn as nn from mmcv.runner import load_checkpoint + from mmedit.models.common import (PixelShufflePack, ResidualBlockNoBN, make_layer) from mmedit.models.registry import BACKBONES diff --git a/mmedit/models/backbones/sr_backbones/edvr_net.py b/mmedit/models/backbones/sr_backbones/edvr_net.py index f79fb825ea..3731b45129 100644 --- a/mmedit/models/backbones/sr_backbones/edvr_net.py +++ b/mmedit/models/backbones/sr_backbones/edvr_net.py @@ -3,11 +3,12 @@ from mmcv.cnn import ConvModule, constant_init, kaiming_init from mmcv.ops import ModulatedDeformConv2d, modulated_deform_conv2d from mmcv.runner import load_checkpoint +from torch.nn.modules.utils import _pair + from mmedit.models.common import (PixelShufflePack, ResidualBlockNoBN, make_layer) from mmedit.models.registry import BACKBONES from mmedit.utils import get_root_logger -from torch.nn.modules.utils import _pair class ModulatedDCNPack(ModulatedDeformConv2d): diff --git a/mmedit/models/backbones/sr_backbones/rrdb_net.py b/mmedit/models/backbones/sr_backbones/rrdb_net.py index fcecc2c79d..7ea16597ca 100644 --- a/mmedit/models/backbones/sr_backbones/rrdb_net.py +++ b/mmedit/models/backbones/sr_backbones/rrdb_net.py @@ -2,6 +2,7 @@ import torch.nn as nn import torch.nn.functional as F from mmcv.runner import load_checkpoint + from mmedit.models.common import default_init_weights, make_layer from mmedit.models.registry import BACKBONES from mmedit.utils import get_root_logger diff --git a/mmedit/models/backbones/sr_backbones/sr_resnet.py b/mmedit/models/backbones/sr_backbones/sr_resnet.py index 783c6d204c..84bbb6c010 100644 --- a/mmedit/models/backbones/sr_backbones/sr_resnet.py +++ b/mmedit/models/backbones/sr_backbones/sr_resnet.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.runner import load_checkpoint + from mmedit.models.common import (PixelShufflePack, ResidualBlockNoBN, default_init_weights, make_layer) from mmedit.models.registry import BACKBONES diff --git a/mmedit/models/backbones/sr_backbones/srcnn.py b/mmedit/models/backbones/sr_backbones/srcnn.py index 13117ac3be..324a3e1dcc 100644 --- a/mmedit/models/backbones/sr_backbones/srcnn.py +++ b/mmedit/models/backbones/sr_backbones/srcnn.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.runner import load_checkpoint + from mmedit.models.registry import BACKBONES from mmedit.utils import get_root_logger diff --git a/mmedit/models/backbones/sr_backbones/tof.py b/mmedit/models/backbones/sr_backbones/tof.py index 9eb3c198a5..05e48ddac6 100644 --- a/mmedit/models/backbones/sr_backbones/tof.py +++ b/mmedit/models/backbones/sr_backbones/tof.py @@ -3,6 +3,7 @@ import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import load_checkpoint + from mmedit.models.common import flow_warp from mmedit.models.registry import BACKBONES from mmedit.utils import get_root_logger diff --git a/mmedit/models/components/discriminators/deepfill_disc.py b/mmedit/models/components/discriminators/deepfill_disc.py index b3104cfea2..28a33d7a3a 100644 --- a/mmedit/models/components/discriminators/deepfill_disc.py +++ b/mmedit/models/components/discriminators/deepfill_disc.py @@ -1,6 +1,7 @@ import torch.nn as nn from mmcv.cnn import normal_init from mmcv.runner import load_checkpoint + from mmedit.models import build_component from mmedit.models.registry import COMPONENTS from mmedit.utils import get_root_logger diff --git a/mmedit/models/components/discriminators/gl_disc.py b/mmedit/models/components/discriminators/gl_disc.py index 6270dde82e..ad04cf6686 100644 --- a/mmedit/models/components/discriminators/gl_disc.py +++ b/mmedit/models/components/discriminators/gl_disc.py @@ -1,9 +1,9 @@ import torch import torch.nn as nn from mmcv.runner import load_checkpoint + from mmedit.models.registry import COMPONENTS from mmedit.utils import get_root_logger - from .multi_layer_disc import MultiLayerDiscriminator diff --git a/mmedit/models/components/discriminators/modified_vgg.py b/mmedit/models/components/discriminators/modified_vgg.py index 104f647582..b6e3e53dec 100644 --- a/mmedit/models/components/discriminators/modified_vgg.py +++ b/mmedit/models/components/discriminators/modified_vgg.py @@ -1,5 +1,6 @@ import torch.nn as nn from mmcv.runner import load_checkpoint + from mmedit.models.registry import COMPONENTS from mmedit.utils import get_root_logger diff --git a/mmedit/models/components/discriminators/multi_layer_disc.py b/mmedit/models/components/discriminators/multi_layer_disc.py index fba80e58a9..641cbf4018 100644 --- a/mmedit/models/components/discriminators/multi_layer_disc.py +++ b/mmedit/models/components/discriminators/multi_layer_disc.py @@ -1,6 +1,7 @@ import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import load_checkpoint + from mmedit.models.common import LinearModule from mmedit.models.registry import COMPONENTS from mmedit.utils import get_root_logger diff --git a/mmedit/models/components/discriminators/patch_disc.py b/mmedit/models/components/discriminators/patch_disc.py index 1a76be794a..421738a18c 100644 --- a/mmedit/models/components/discriminators/patch_disc.py +++ b/mmedit/models/components/discriminators/patch_disc.py @@ -1,6 +1,7 @@ import torch.nn as nn from mmcv.cnn import ConvModule, build_conv_layer from mmcv.runner import load_checkpoint + from mmedit.models.common import generation_init_weights from mmedit.models.registry import COMPONENTS from mmedit.utils import get_root_logger diff --git a/mmedit/models/components/refiners/deepfill_refiner.py b/mmedit/models/components/refiners/deepfill_refiner.py index 7ac0c670ed..221660f9ad 100644 --- a/mmedit/models/components/refiners/deepfill_refiner.py +++ b/mmedit/models/components/refiners/deepfill_refiner.py @@ -1,6 +1,7 @@ import torch import torch.nn as nn import torch.nn.functional as F + from mmedit.models.builder import build_component from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/components/refiners/plain_refiner.py b/mmedit/models/components/refiners/plain_refiner.py index 0bb8545646..1a32a82190 100644 --- a/mmedit/models/components/refiners/plain_refiner.py +++ b/mmedit/models/components/refiners/plain_refiner.py @@ -1,6 +1,7 @@ import torch import torch.nn as nn from mmcv.cnn.utils.weight_init import xavier_init + from mmedit.models.registry import COMPONENTS diff --git a/mmedit/models/inpaintors/one_stage.py b/mmedit/models/inpaintors/one_stage.py index 9d27bb43f7..9bb0b9710f 100644 --- a/mmedit/models/inpaintors/one_stage.py +++ b/mmedit/models/inpaintors/one_stage.py @@ -3,9 +3,9 @@ import mmcv import torch -from mmedit.core import L1Evaluation, psnr, ssim, tensor2img from torchvision.utils import save_image +from mmedit.core import L1Evaluation, psnr, ssim, tensor2img from ..base import BaseModel from ..builder import build_backbone, build_component, build_loss from ..common import set_requires_grad diff --git a/mmedit/models/inpaintors/pconv_inpaintor.py b/mmedit/models/inpaintors/pconv_inpaintor.py index 3cf2aea6ba..25e09ceb9e 100644 --- a/mmedit/models/inpaintors/pconv_inpaintor.py +++ b/mmedit/models/inpaintors/pconv_inpaintor.py @@ -3,8 +3,8 @@ import mmcv import torch -from mmedit.core import tensor2img +from mmedit.core import tensor2img from ..registry import MODELS from .one_stage import OneStageInpaintor diff --git a/mmedit/models/inpaintors/two_stage.py b/mmedit/models/inpaintors/two_stage.py index 477774c552..b9daa8bff6 100644 --- a/mmedit/models/inpaintors/two_stage.py +++ b/mmedit/models/inpaintors/two_stage.py @@ -3,9 +3,9 @@ import mmcv import torch -from mmedit.core import tensor2img from torchvision.utils import save_image +from mmedit.core import tensor2img from ..common.model_utils import set_requires_grad from ..registry import MODELS from .one_stage import OneStageInpaintor diff --git a/mmedit/models/losses/perceptual_loss.py b/mmedit/models/losses/perceptual_loss.py index facac79f3b..56e239c56a 100644 --- a/mmedit/models/losses/perceptual_loss.py +++ b/mmedit/models/losses/perceptual_loss.py @@ -2,8 +2,8 @@ import torch.nn as nn import torchvision.models.vgg as vgg from mmcv.runner import load_checkpoint -from mmedit.utils import get_root_logger +from mmedit.utils import get_root_logger from ..registry import LOSSES diff --git a/mmedit/models/mattors/base_mattor.py b/mmedit/models/mattors/base_mattor.py index 684438e45d..b01f9533c2 100644 --- a/mmedit/models/mattors/base_mattor.py +++ b/mmedit/models/mattors/base_mattor.py @@ -7,8 +7,8 @@ import numpy as np from mmcv import ConfigDict from mmcv.utils import print_log -from mmedit.core.evaluation import connectivity, gradient_error, mse, sad +from mmedit.core.evaluation import connectivity, gradient_error, mse, sad from ..base import BaseModel from ..builder import build_backbone, build_component from ..registry import MODELS diff --git a/mmedit/models/restorers/basic_restorer.py b/mmedit/models/restorers/basic_restorer.py index 3716f42281..e52db921ce 100644 --- a/mmedit/models/restorers/basic_restorer.py +++ b/mmedit/models/restorers/basic_restorer.py @@ -2,8 +2,8 @@ import os.path as osp import mmcv -from mmedit.core import psnr, ssim, tensor2img +from mmedit.core import psnr, ssim, tensor2img from ..base import BaseModel from ..builder import build_backbone, build_loss from ..registry import MODELS diff --git a/mmedit/models/restorers/edvr.py b/mmedit/models/restorers/edvr.py index 9376f5fdfc..5bbbb76893 100644 --- a/mmedit/models/restorers/edvr.py +++ b/mmedit/models/restorers/edvr.py @@ -2,8 +2,8 @@ import os.path as osp import mmcv -from mmedit.core import tensor2img +from mmedit.core import tensor2img from ..registry import MODELS from .basic_restorer import BasicRestorer diff --git a/mmedit/models/synthesizers/cycle_gan.py b/mmedit/models/synthesizers/cycle_gan.py index 35d26cf4c8..29aa5d5ec0 100644 --- a/mmedit/models/synthesizers/cycle_gan.py +++ b/mmedit/models/synthesizers/cycle_gan.py @@ -4,8 +4,8 @@ import numpy as np import torch.nn as nn from mmcv.parallel import MMDistributedDataParallel -from mmedit.core import tensor2img +from mmedit.core import tensor2img from ..base import BaseModel from ..builder import build_backbone, build_component, build_loss from ..common import GANImageBuffer, set_requires_grad diff --git a/mmedit/models/synthesizers/pix2pix.py b/mmedit/models/synthesizers/pix2pix.py index 32c32771af..36bf234fc8 100644 --- a/mmedit/models/synthesizers/pix2pix.py +++ b/mmedit/models/synthesizers/pix2pix.py @@ -3,8 +3,8 @@ import mmcv import numpy as np import torch -from mmedit.core import tensor2img +from mmedit.core import tensor2img from ..base import BaseModel from ..builder import build_backbone, build_component, build_loss from ..common import set_requires_grad diff --git a/setup.cfg b/setup.cfg index 9e7e0e2f0d..fc1b712740 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ split_before_expression_after_opening_paren = true line_length = 79 multi_line_output = 0 known_standard_library = pkg_resources,setuptools -known_first_party = mmsr +known_first_party = mmedit known_third_party =PIL,cv2,lmdb,mmcv,numpy,pytest,scipy,torch,torchvision no_lines_before = STDLIB,LOCALFOLDER default_section = THIRDPARTY diff --git a/tests/test_augmentation.py b/tests/test_augmentation.py index 118ad952c3..6644743d50 100644 --- a/tests/test_augmentation.py +++ b/tests/test_augmentation.py @@ -3,6 +3,7 @@ import numpy as np import pytest import torch + # yapf: disable from mmedit.datasets.pipelines import (BinarizeImage, Flip, GenerateFrameIndices, diff --git a/tests/test_base_model.py b/tests/test_base_model.py index a3126c9cb0..6c7d1a9717 100644 --- a/tests/test_base_model.py +++ b/tests/test_base_model.py @@ -3,6 +3,7 @@ import pytest import torch + from mmedit.models import BaseModel diff --git a/tests/test_basic_restorer.py b/tests/test_basic_restorer.py index 210e358377..dc158cf1b4 100644 --- a/tests/test_basic_restorer.py +++ b/tests/test_basic_restorer.py @@ -4,6 +4,7 @@ import pytest import torch from mmcv.runner import obj_from_dict + from mmedit.models import build_model from mmedit.models.backbones import MSRResNet from mmedit.models.losses import L1Loss diff --git a/tests/test_common_module.py b/tests/test_common_module.py index 4c65e2eab4..cd648407d0 100644 --- a/tests/test_common_module.py +++ b/tests/test_common_module.py @@ -1,6 +1,7 @@ import pytest import torch import torch.nn as nn + from mmedit.models.common import (ASPP, DepthwiseSeparableConvModule, GCAModule, LinearModule, MaskConvModule, PartialConv2d, SimpleGatedConvModule) diff --git a/tests/test_compose.py b/tests/test_compose.py index 6dd2f0298b..aa8cc69c93 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from mmedit.datasets.pipelines import Compose, ImageToTensor diff --git a/tests/test_crop.py b/tests/test_crop.py index 6be83c3564..425e321e96 100644 --- a/tests/test_crop.py +++ b/tests/test_crop.py @@ -2,6 +2,7 @@ import numpy as np import pytest + from mmedit.datasets.pipelines import (Crop, CropAroundCenter, CropAroundFg, CropAroundUnknown, FixedCrop, ModCrop, PairedRandomCrop) diff --git a/tests/test_cyclegan.py b/tests/test_cyclegan.py index fe2e3dd2b0..7b29c68838 100644 --- a/tests/test_cyclegan.py +++ b/tests/test_cyclegan.py @@ -6,6 +6,7 @@ import torch from mmcv.parallel import DataContainer as DC from mmcv.runner import obj_from_dict + from mmedit.models import build_model from mmedit.models.backbones import ResnetGenerator from mmedit.models.components import PatchDiscriminator diff --git a/tests/test_dataset_builder.py b/tests/test_dataset_builder.py index 05e582d1ba..518692cda0 100644 --- a/tests/test_dataset_builder.py +++ b/tests/test_dataset_builder.py @@ -1,9 +1,10 @@ import math +from torch.utils.data import ConcatDataset, RandomSampler, SequentialSampler + from mmedit.datasets import (DATASETS, RepeatDataset, build_dataloader, build_dataset) from mmedit.datasets.samplers import DistributedSampler -from torch.utils.data import ConcatDataset, RandomSampler, SequentialSampler @DATASETS.register_module() diff --git a/tests/test_datasets.py b/tests/test_datasets.py index ac43711933..8e2b43fb1e 100644 --- a/tests/test_datasets.py +++ b/tests/test_datasets.py @@ -4,13 +4,14 @@ import numpy as np import pytest +from torch.utils.data import Dataset + from mmedit.datasets import (AdobeComp1kDataset, BaseGenerationDataset, BaseSRDataset, GenerationPairedDataset, GenerationUnpairedDataset, RepeatDataset, SRAnnotationDataset, SRFolderDataset, SRLmdbDataset, SRREDSDataset, SRVid4Dataset, SRVimeo90KDataset) -from torch.utils.data import Dataset def mock_open(*args, **kargs): diff --git a/tests/test_decoders.py b/tests/test_decoders.py index 59e44005c4..07c714ed6f 100644 --- a/tests/test_decoders.py +++ b/tests/test_decoders.py @@ -1,6 +1,7 @@ import numpy as np import pytest import torch + from mmedit.models.backbones import (VGG16, IndexedUpsample, IndexNetDecoder, IndexNetEncoder, PlainDecoder, ResGCADecoder, ResGCAEncoder, ResNetDec, diff --git a/tests/test_deepfill_decoder.py b/tests/test_deepfill_decoder.py index 95a0128622..08367f73c0 100644 --- a/tests/test_deepfill_decoder.py +++ b/tests/test_deepfill_decoder.py @@ -1,4 +1,5 @@ import torch + from mmedit.models.backbones import DeepFillDecoder diff --git a/tests/test_deepfill_disc.py b/tests/test_deepfill_disc.py index 7e0a510bbd..03b70ac6be 100644 --- a/tests/test_deepfill_disc.py +++ b/tests/test_deepfill_disc.py @@ -1,5 +1,6 @@ import pytest import torch + from mmedit.models.components import (DeepFillv1Discriminators, MultiLayerDiscriminator) diff --git a/tests/test_deepfill_encdec.py b/tests/test_deepfill_encdec.py index f9e6ace2eb..609b90e111 100644 --- a/tests/test_deepfill_encdec.py +++ b/tests/test_deepfill_encdec.py @@ -1,4 +1,5 @@ import torch + from mmedit.models.backbones import DeepFillEncoderDecoder, GLEncoderDecoder from mmedit.models.components import DeepFillRefiner diff --git a/tests/test_deepfill_encoder.py b/tests/test_deepfill_encoder.py index 10a92dce8a..e11d3385fd 100644 --- a/tests/test_deepfill_encoder.py +++ b/tests/test_deepfill_encoder.py @@ -1,4 +1,5 @@ import torch + from mmedit.models.backbones import ContextualAttentionNeck, DeepFillEncoder from mmedit.models.common import SimpleGatedConvModule diff --git a/tests/test_deepfill_inpaintor.py b/tests/test_deepfill_inpaintor.py index 228fe16133..a1104f2c8e 100644 --- a/tests/test_deepfill_inpaintor.py +++ b/tests/test_deepfill_inpaintor.py @@ -5,6 +5,7 @@ import pytest import torch from mmcv import Config + from mmedit.core import build_optimizers from mmedit.models import DeepFillv1Inpaintor diff --git a/tests/test_deepfill_refiner.py b/tests/test_deepfill_refiner.py index bd5cfccaab..f0920c5a5a 100644 --- a/tests/test_deepfill_refiner.py +++ b/tests/test_deepfill_refiner.py @@ -1,4 +1,5 @@ import torch + from mmedit.models import (ContextualAttentionNeck, DeepFillDecoder, DeepFillEncoder, DeepFillRefiner, GLDilationNeck) diff --git a/tests/test_discriminators.py b/tests/test_discriminators.py index 3ea1c76337..cc1dddc824 100644 --- a/tests/test_discriminators.py +++ b/tests/test_discriminators.py @@ -3,6 +3,7 @@ import numpy as np import pytest import torch + from mmedit.models import build_component diff --git a/tests/test_duf.py b/tests/test_duf.py index 6763a18576..06b2803070 100644 --- a/tests/test_duf.py +++ b/tests/test_duf.py @@ -1,5 +1,6 @@ import pytest import torch + from mmedit.models.backbones.sr_backbones.duf import DynamicUpsamplingFilter diff --git a/tests/test_edvr_model.py b/tests/test_edvr_model.py index e65c57c995..1573609228 100644 --- a/tests/test_edvr_model.py +++ b/tests/test_edvr_model.py @@ -4,6 +4,7 @@ import pytest import torch from mmcv.runner import obj_from_dict + from mmedit.models import build_model from mmedit.models.backbones import EDVRNet from mmedit.models.losses import L1Loss diff --git a/tests/test_edvr_net.py b/tests/test_edvr_net.py index c91621a305..9fc2194669 100644 --- a/tests/test_edvr_net.py +++ b/tests/test_edvr_net.py @@ -1,5 +1,6 @@ import pytest import torch + from mmedit.models.backbones.sr_backbones.edvr_net import (EDVRNet, PCDAlignment, TSAFusion) diff --git a/tests/test_encoder_decoder.py b/tests/test_encoder_decoder.py index 5b7f863efc..3d73d6e9ac 100644 --- a/tests/test_encoder_decoder.py +++ b/tests/test_encoder_decoder.py @@ -1,5 +1,6 @@ import numpy as np import torch + from mmedit.models.backbones import SimpleEncoderDecoder diff --git a/tests/test_encoders.py b/tests/test_encoders.py index be5fc58405..e9b62bc492 100644 --- a/tests/test_encoders.py +++ b/tests/test_encoders.py @@ -4,6 +4,7 @@ import pytest import torch from mmcv.utils.parrots_wrapper import _BatchNorm + from mmedit.models.backbones import (VGG16, DepthwiseIndexBlock, HolisticIndexBlock, IndexNetEncoder, ResGCAEncoder, ResNetEnc, ResShortcutEnc) diff --git a/tests/test_esrgan.py b/tests/test_esrgan.py index 4a10bafbcd..85582b10fd 100644 --- a/tests/test_esrgan.py +++ b/tests/test_esrgan.py @@ -2,6 +2,7 @@ import torch from mmcv.runner import obj_from_dict + from mmedit.models import build_model from mmedit.models.backbones import MSRResNet from mmedit.models.components import ModifiedVGG diff --git a/tests/test_eval_hook.py b/tests/test_eval_hook.py index cfad03256a..53a87d57ae 100644 --- a/tests/test_eval_hook.py +++ b/tests/test_eval_hook.py @@ -7,9 +7,10 @@ import torch import torch.nn as nn from mmcv.runner import obj_from_dict -from mmedit.core import EvalIterHook from torch.utils.data import DataLoader, Dataset +from mmedit.core import EvalIterHook + class ExampleDataset(Dataset): diff --git a/tests/test_flow_warp.py b/tests/test_flow_warp.py index 9184d75eb0..36017b7ffe 100644 --- a/tests/test_flow_warp.py +++ b/tests/test_flow_warp.py @@ -1,5 +1,6 @@ import pytest import torch + from mmedit.models import flow_warp diff --git a/tests/test_formating.py b/tests/test_formating.py index 06b83da95c..4be3999bac 100644 --- a/tests/test_formating.py +++ b/tests/test_formating.py @@ -1,6 +1,7 @@ import numpy as np import pytest import torch + from mmedit.datasets.pipelines import (Collect, FormatTrimap, GetMaskedImage, ImageToTensor, ToTensor) from mmedit.datasets.pipelines.formating import FramesToTensor diff --git a/tests/test_generators.py b/tests/test_generators.py index 212f2a10c8..11382d4946 100644 --- a/tests/test_generators.py +++ b/tests/test_generators.py @@ -3,6 +3,7 @@ import numpy as np import pytest import torch + from mmedit.models import build_backbone from mmedit.models.common import (ResidualBlockWithDropout, UnetSkipConnectionBlock) diff --git a/tests/test_gl_inpaintor.py b/tests/test_gl_inpaintor.py index 717e2227c1..3441b2062b 100644 --- a/tests/test_gl_inpaintor.py +++ b/tests/test_gl_inpaintor.py @@ -2,6 +2,7 @@ import torch from mmcv import Config + from mmedit.models import build_model diff --git a/tests/test_gl_model.py b/tests/test_gl_model.py index dcca1a1373..89f571bbb2 100644 --- a/tests/test_gl_model.py +++ b/tests/test_gl_model.py @@ -1,5 +1,6 @@ import pytest import torch + from mmedit.models import build_backbone, build_component from mmedit.models.backbones import GLDilationNeck from mmedit.models.common import SimpleGatedConvModule diff --git a/tests/test_loading.py b/tests/test_loading.py index fcebdb5fb1..6578b807dd 100644 --- a/tests/test_loading.py +++ b/tests/test_loading.py @@ -5,6 +5,7 @@ import mmcv import numpy as np import pytest + from mmedit.datasets.pipelines import (GetSpatialDiscountMask, LoadImageFromFile, LoadImageFromFileList, LoadMask, diff --git a/tests/test_losses.py b/tests/test_losses.py index cccef6c3d3..5732926b72 100644 --- a/tests/test_losses.py +++ b/tests/test_losses.py @@ -4,6 +4,7 @@ import numpy.testing as npt import pytest import torch + from mmedit.models.losses import (CharbonnierCompLoss, CharbonnierLoss, DiscShiftLoss, GANLoss, GradientLoss, GradientPenaltyLoss, L1CompositionLoss, diff --git a/tests/test_mask_generation.py b/tests/test_mask_generation.py index a37a3152e1..fba7cd0239 100644 --- a/tests/test_mask_generation.py +++ b/tests/test_mask_generation.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from mmedit.core.mask import (bbox2mask, brush_stroke_mask, get_irregular_mask, random_bbox) diff --git a/tests/test_matting_refiners.py b/tests/test_matting_refiners.py index 6f59f7a1ab..6a21293c60 100644 --- a/tests/test_matting_refiners.py +++ b/tests/test_matting_refiners.py @@ -1,5 +1,6 @@ import numpy as np import torch + from mmedit.models import PlainRefiner diff --git a/tests/test_mattors.py b/tests/test_mattors.py index 893b84b3b6..5db3ab7ca6 100644 --- a/tests/test_mattors.py +++ b/tests/test_mattors.py @@ -5,6 +5,7 @@ import numpy as np import pytest import torch + from mmedit.models import BaseMattor, build_model diff --git a/tests/test_metrics.py b/tests/test_metrics.py index bc32ffefa8..29c3889e11 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -1,6 +1,7 @@ import mmcv import numpy as np import pytest + from mmedit.core.evaluation.metrics import (connectivity, gradient_error, mse, niqe, psnr, reorder_image, sad, ssim) diff --git a/tests/test_model_utils.py b/tests/test_model_utils.py index 5b74a44a3a..4a4c77cde5 100644 --- a/tests/test_model_utils.py +++ b/tests/test_model_utils.py @@ -4,6 +4,7 @@ import pytest import torch import torch.nn as nn + from mmedit.models.common import (GANImageBuffer, extract_around_bbox, extract_bbox_patch, generation_init_weights, set_requires_grad) diff --git a/tests/test_multi_layer_disc.py b/tests/test_multi_layer_disc.py index 9bf59a375d..c3933e9130 100644 --- a/tests/test_multi_layer_disc.py +++ b/tests/test_multi_layer_disc.py @@ -1,6 +1,7 @@ import pytest import torch import torch.nn as nn + from mmedit.models.components import MultiLayerDiscriminator diff --git a/tests/test_normalization.py b/tests/test_normalization.py index 61d7db7320..aaf7a74423 100644 --- a/tests/test_normalization.py +++ b/tests/test_normalization.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from mmedit.datasets.pipelines import Normalize, RescaleToZeroOne diff --git a/tests/test_one_stage_inpaintor.py b/tests/test_one_stage_inpaintor.py index 19b4d4b7d1..e93e20c9a6 100644 --- a/tests/test_one_stage_inpaintor.py +++ b/tests/test_one_stage_inpaintor.py @@ -7,6 +7,7 @@ import pytest import torch from mmcv import Config + from mmedit.models import build_model from mmedit.models.backbones import GLEncoderDecoder diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py index c53daacb44..034f20e4c0 100644 --- a/tests/test_optimizer.py +++ b/tests/test_optimizer.py @@ -1,5 +1,6 @@ import torch import torch.nn as nn + from mmedit.core import build_optimizers diff --git a/tests/test_pconv_encdec.py b/tests/test_pconv_encdec.py index c1712e51f0..dd0924f4ec 100644 --- a/tests/test_pconv_encdec.py +++ b/tests/test_pconv_encdec.py @@ -1,6 +1,7 @@ import pytest import torch from mmcv.utils.parrots_wrapper import _BatchNorm + from mmedit.models.backbones import PConvEncoder, PConvEncoderDecoder diff --git a/tests/test_pconv_inpaintor.py b/tests/test_pconv_inpaintor.py index 693ec22ec0..09e16aa067 100644 --- a/tests/test_pconv_inpaintor.py +++ b/tests/test_pconv_inpaintor.py @@ -6,6 +6,7 @@ import pytest import torch from mmcv import Config + from mmedit.models import build_model from mmedit.models.losses import PerceptualVGG diff --git a/tests/test_pipeline_utils.py b/tests/test_pipeline_utils.py index 36f6198ca6..01d67ec557 100644 --- a/tests/test_pipeline_utils.py +++ b/tests/test_pipeline_utils.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from mmedit.datasets.pipelines.utils import adjust_gamma, dtype_range diff --git a/tests/test_pix2pix.py b/tests/test_pix2pix.py index e7bc46cdc2..7e72328ea0 100644 --- a/tests/test_pix2pix.py +++ b/tests/test_pix2pix.py @@ -6,6 +6,7 @@ import torch from mmcv.parallel import DataContainer as DC from mmcv.runner import obj_from_dict + from mmedit.models import build_model from mmedit.models.backbones import UnetGenerator from mmedit.models.components import PatchDiscriminator diff --git a/tests/test_sr_backbones.py b/tests/test_sr_backbones.py index 3f8c30617f..31662b8894 100644 --- a/tests/test_sr_backbones.py +++ b/tests/test_sr_backbones.py @@ -1,6 +1,7 @@ import numpy as np import pytest import torch + from mmedit.models.backbones import EDSR, SRCNN, MSRResNet, RRDBNet from mmedit.models.components import ModifiedVGG diff --git a/tests/test_srgan.py b/tests/test_srgan.py index ebe0054546..84e5fb4f99 100644 --- a/tests/test_srgan.py +++ b/tests/test_srgan.py @@ -3,6 +3,7 @@ import pytest import torch from mmcv.runner import obj_from_dict + from mmedit.models import build_model from mmedit.models.backbones import MSRResNet from mmedit.models.components import ModifiedVGG diff --git a/tests/test_tensor2img.py b/tests/test_tensor2img.py index 58905c6522..6b92a79da5 100644 --- a/tests/test_tensor2img.py +++ b/tests/test_tensor2img.py @@ -1,9 +1,10 @@ import numpy as np import pytest import torch -from mmedit.core import tensor2img from torchvision.utils import make_grid +from mmedit.core import tensor2img + def test_tensor2img(): tensor_4d_1 = torch.FloatTensor(2, 3, 4, 4).uniform_(0, 1) diff --git a/tests/test_tof.py b/tests/test_tof.py index 24c5cbaeb2..5c767b2653 100644 --- a/tests/test_tof.py +++ b/tests/test_tof.py @@ -1,5 +1,6 @@ import pytest import torch + from mmedit.models.backbones import TOFlow diff --git a/tests/test_trimap.py b/tests/test_trimap.py index e4d88c5947..0d48ab25a6 100644 --- a/tests/test_trimap.py +++ b/tests/test_trimap.py @@ -1,6 +1,7 @@ import cv2 import numpy as np import pytest + from mmedit.datasets.pipelines import (CompositeFg, GenerateSeg, GenerateSoftSeg, GenerateTrimap, GenerateTrimapWithDistTransform, diff --git a/tests/test_two_stage_inpaintor.py b/tests/test_two_stage_inpaintor.py index 939fc97965..942679dbf6 100644 --- a/tests/test_two_stage_inpaintor.py +++ b/tests/test_two_stage_inpaintor.py @@ -5,6 +5,7 @@ import pytest import torch from mmcv import Config + from mmedit.core import build_optimizers from mmedit.models import TwoStageInpaintor diff --git a/tests/test_visual_hook.py b/tests/test_visual_hook.py index 4f669792e2..35f84f5a99 100644 --- a/tests/test_visual_hook.py +++ b/tests/test_visual_hook.py @@ -7,9 +7,10 @@ import pytest import torch import torch.nn as nn +from torch.utils.data import DataLoader, Dataset + from mmedit.core import VisualizationHook from mmedit.utils import get_root_logger -from torch.utils.data import DataLoader, Dataset class ExampleDataset(Dataset): diff --git a/tools/evaluate_comp1k.py b/tools/evaluate_comp1k.py index 2ffb989713..d33dc68e7d 100644 --- a/tools/evaluate_comp1k.py +++ b/tools/evaluate_comp1k.py @@ -4,6 +4,7 @@ import mmcv import numpy as np + from mmedit.core.evaluation import connectivity, gradient_error, mse, sad diff --git a/tools/get_flops.py b/tools/get_flops.py index af6d9c8765..0a9d83a9d0 100644 --- a/tools/get_flops.py +++ b/tools/get_flops.py @@ -2,6 +2,7 @@ from mmcv import Config from mmcv.cnn.utils import get_model_complexity_info + from mmedit.models import build_model diff --git a/tools/test.py b/tools/test.py index 9c52356afa..d965c0eacb 100644 --- a/tools/test.py +++ b/tools/test.py @@ -5,6 +5,7 @@ import torch from mmcv.parallel import MMDataParallel from mmcv.runner import get_dist_info, init_dist, load_checkpoint + from mmedit.apis import multi_gpu_test, set_random_seed, single_gpu_test from mmedit.core.distributed_wrapper import DistributedDataParallelWrapper from mmedit.datasets import build_dataloader, build_dataset diff --git a/tools/train.py b/tools/train.py index eea0ce6060..ed3a8e7f2f 100644 --- a/tools/train.py +++ b/tools/train.py @@ -8,6 +8,7 @@ import torch from mmcv import Config from mmcv.runner import init_dist + from mmedit import __version__ from mmedit.apis import set_random_seed, train_model from mmedit.datasets import build_dataset