Skip to content

Commit

Permalink
[Enhancement] support all unconditional models inference. (#1659)
Browse files Browse the repository at this point in the history
support all unconditional model
  • Loading branch information
liuwenran authored Feb 23, 2023
1 parent 83bfa52 commit 0acc032
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mmedit/apis/inferencers/unconditional_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UnconditionalInferencer(BaseMMEditInferencer):
visualize=['result_out_dir'],
postprocess=[])

extra_parameters = dict(num_batches=4, sample_model='ema')
extra_parameters = dict(num_batches=4, sample_model='orig')

def preprocess(self) -> Dict:
"""Process the inputs into a model-feedable format.
Expand Down Expand Up @@ -57,7 +57,10 @@ def visualize(self,
res_list = []
res_list.extend([item.fake_img.data.cpu() for item in preds])
results = torch.stack(res_list, dim=0)
results = (results[:, [2, 1, 0]] + 1.) / 2.
if results.shape[1] == 3:
results = (results[:, [2, 1, 0]] + 1.) / 2.
else:
results = (results + 1.) / 2.

# save images
if result_out_dir:
Expand Down
10 changes: 10 additions & 0 deletions mmedit/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class MMEdit:
>>> # see demo/mmediting_inference_tutorial.ipynb for more examples
"""
# unsupported now
# singan

inference_supported_models = [
# colorization models
'inst_colorization',
Expand All @@ -48,7 +51,14 @@ class MMEdit:
'sagan',

# unconditional models
'dcgan',
'wgan-gp',
'lsgan',
'ggan',
'pggan',
'styleganv1',
'styleganv2',
'styleganv3',

# matting models
'gca',
Expand Down

0 comments on commit 0acc032

Please sign in to comment.