Skip to content

Commit

Permalink
[Refact] support all models in translation inferencer (#1650)
Browse files Browse the repository at this point in the history
* fix translation load bug.

* fix lint.

* support cyclegan inference.

* fix lint.
  • Loading branch information
liuwenran authored Feb 21, 2023
1 parent 46ae779 commit a17e934
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mmedit/apis/inferencers/mmedit_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self,
elif self.task in ['inpainting', 'Inpainting']:
self.inferencer = InpaintingInferencer(
config, ckpt, device, extra_parameters, seed=seed)
elif self.task in ['translation', 'Image2Image Translation']:
elif self.task in ['translation', 'Image2Image']:
self.inferencer = TranslationInferencer(
config, ckpt, device, extra_parameters, seed=seed)
elif self.task in ['restoration', 'Image Super-Resolution']:
Expand Down
9 changes: 4 additions & 5 deletions mmedit/apis/inferencers/translation_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ def preprocess(self, img: InputsType) -> Dict:
test_pipeline = Compose(cfg.test_pipeline)

# prepare data
data = dict()
# dirty code to deal with test data pipeline
data = dict()
data['pair_path'] = img
data[f'img_{source_domain}_path'] = img
data[f'img_{self.target_domain}_path'] = img

data['img_A_path'] = img
data['img_B_path'] = img
data = collate([test_pipeline(data)])
data = self.model.data_preprocessor(data, False)
inputs_dict = data['inputs']

inputs_dict = data['inputs']
results = inputs_dict[f'img_{source_domain}']
return results

Expand Down
1 change: 1 addition & 0 deletions mmedit/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class MMEdit:

# translation models
'pix2pix',
'cyclegan',

# restoration models
'esrgan',
Expand Down

0 comments on commit a17e934

Please sign in to comment.