Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] wgangp config error #100

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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)))
8 changes: 4 additions & 4 deletions mmgen/datasets/pipelines/crop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_)

Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mmgen/datasets/unconditional_image_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand Down
6 changes: 3 additions & 3 deletions mmgen/models/gans/base_gan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions mmgen/models/gans/singan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 1 addition & 6 deletions mmgen/ops/conv2d_gradfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions tests/test_datasets/test_pipelines/test_crop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down