diff --git a/configs/wgan-gp/wgangp_GN_celeba-cropped_128_b64x1_160kiter.py b/configs/wgan-gp/wgangp_GN_celeba-cropped_128_b64x1_160kiter.py index bcb608a40..fdd0e2929 100644 --- a/configs/wgan-gp/wgangp_GN_celeba-cropped_128_b64x1_160kiter.py +++ b/configs/wgan-gp/wgangp_GN_celeba-cropped_128_b64x1_160kiter.py @@ -1,6 +1,6 @@ _base_ = [ '../_base_/datasets/unconditional_imgs_128x128.py', - '../_base_/models/wgangp_base.py' + '../_base_/models/wgangp_base.py', '../_base_/default_runtime.py' ] data = dict( @@ -20,6 +20,11 @@ lr_config = None total_iters = 160000 +runner = dict( + type='DynamicIterBasedRunner', + is_dynamic_ddp=False, # Note that this flag should be False. + pass_training_status=True) + metrics = dict( ms_ssim10k=dict(type='MS_SSIM', num_images=10000), swd16k=dict(type='SWD', num_images=16384, image_shape=(3, 128, 128))) diff --git a/mmgen/datasets/pipelines/crop.py b/mmgen/datasets/pipelines/crop.py index 2cff59a79..74257767e 100644 --- a/mmgen/datasets/pipelines/crop.py +++ b/mmgen/datasets/pipelines/crop.py @@ -49,8 +49,8 @@ def _crop(self, data): y_offset = max(0, (data_h - crop_h)) // 2 crop_bbox = [x_offset, y_offset, crop_w, crop_h] - item_ = item[y_offset:y_offset + crop_h, - x_offset:x_offset + crop_w, ...] + item_ = item[y_offset:y_offset + crop_h, x_offset:x_offset + + crop_w, ...] crop_bbox_list.append(crop_bbox) data_list_.append(item_) @@ -111,8 +111,8 @@ def __init__(self, keys, crop_size, crop_pos=None): def _crop(self, data, x_offset, y_offset, crop_w, crop_h): crop_bbox = [x_offset, y_offset, crop_w, crop_h] - data_ = data[y_offset:y_offset + crop_h, x_offset:x_offset + crop_w, - ...] + data_ = data[y_offset:y_offset + crop_h, x_offset:x_offset + + crop_w, ...] return data_, crop_bbox def __call__(self, results): diff --git a/mmgen/datasets/unconditional_image_dataset.py b/mmgen/datasets/unconditional_image_dataset.py index 47498b016..958f9c25b 100644 --- a/mmgen/datasets/unconditional_image_dataset.py +++ b/mmgen/datasets/unconditional_image_dataset.py @@ -23,7 +23,7 @@ class UnconditionalImageDataset(Dataset): mode. Otherwise, in train mode. Default to False. """ - _VALID_IMG_SUFFIX = ('.jpg', '.png', '.jpeg', '.JPEG') + _VALID_IMG_SUFFIX = ('.jpg', '.png', '.jpeg', '.JPEG', '.webp') def __init__(self, imgs_root, pipeline, test_mode=False): super().__init__() diff --git a/mmgen/models/gans/base_gan.py b/mmgen/models/gans/base_gan.py index dbc524376..784a15ba1 100644 --- a/mmgen/models/gans/base_gan.py +++ b/mmgen/models/gans/base_gan.py @@ -28,9 +28,9 @@ def with_ema_gen(self): @property def with_gen_auxiliary_loss(self): """bool: whether the GAN adopts auxiliary loss in the generator.""" - return hasattr(self, - 'gen_auxiliary_losses') and (self.gen_auxiliary_losses - is not None) + return hasattr( + self, + 'gen_auxiliary_losses') and (self.gen_auxiliary_losses is not None) @property def with_disc_auxiliary_loss(self): diff --git a/mmgen/models/gans/singan.py b/mmgen/models/gans/singan.py index 7f87a3400..d413502bd 100644 --- a/mmgen/models/gans/singan.py +++ b/mmgen/models/gans/singan.py @@ -383,8 +383,8 @@ def train_step(self, # end of each scale # calculate noise weight for next scale - if (curr_iter % self.train_cfg['iters_per_scale'] - == 0) and (self.curr_stage < len(self.reals) - 1): + if (curr_iter % self.train_cfg['iters_per_scale'] == 0) and ( + self.curr_stage < len(self.reals) - 1): with torch.no_grad(): g_recon = self.generator( diff --git a/mmgen/ops/conv2d_gradfix.py b/mmgen/ops/conv2d_gradfix.py index ebdd70899..0eec8603e 100644 --- a/mmgen/ops/conv2d_gradfix.py +++ b/mmgen/ops/conv2d_gradfix.py @@ -121,12 +121,7 @@ def no_weight_gradients(): weight_gradients_disabled = old -def conv2d(input, - weight, - bias=None, - stride=1, - padding=0, - dilation=1, +def conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1): if _should_use_custom_op(input): return _conv2d_gradfix( diff --git a/tests/test_datasets/test_pipelines/test_crop.py b/tests/test_datasets/test_pipelines/test_crop.py index 9f6ab3e00..dc557e496 100644 --- a/tests/test_datasets/test_pipelines/test_crop.py +++ b/tests/test_datasets/test_pipelines/test_crop.py @@ -131,12 +131,12 @@ def test_fixed_crop(self): assert crop_w == results['img_b_crop_bbox'][2] assert crop_h == results['img_b_crop_bbox'][3] assert np.array_equal( - self.results['img_a'][y_offset:y_offset + crop_h, - x_offset:x_offset + crop_w, :], + self.results['img_a'][y_offset:y_offset + + crop_h, x_offset:x_offset + crop_w, :], results['img_a']) assert np.array_equal( - self.results['img_b'][y_offset:y_offset + crop_h, - x_offset:x_offset + crop_w, :], + self.results['img_b'][y_offset:y_offset + + crop_h, x_offset:x_offset + crop_w, :], results['img_b']) # test given pos crop for lager size than the original shape