Co-authored-by: Roman Suvorov <r.suvorov@samsung.com>
pull/108/head
Roman 3 years ago committed by GitHub
parent 0f8e03cf20
commit d97ac962bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      bin/predict.py
  2. 1
      saicinpainting/evaluation/data.py

@ -76,6 +76,11 @@ def main(predict_config: OmegaConf):
batch = model(batch)
cur_res = batch[predict_config.out_key][0].permute(1, 2, 0).detach().cpu().numpy()
unpad_to_size = batch.get('unpad_to_size', None)
if unpad_to_size is not None:
orig_height, orig_width = unpad_to_size
cur_res = cur_res[:orig_height, :orig_width]
cur_res = np.clip(cur_res * 255, 0, 255).astype('uint8')
cur_res = cv2.cvtColor(cur_res, cv2.COLOR_RGB2BGR)
cv2.imwrite(cur_out_fname, cur_res)

@ -76,6 +76,7 @@ class InpaintingDataset(Dataset):
result['mask'] = scale_image(result['mask'], self.scale_factor, interpolation=cv2.INTER_NEAREST)
if self.pad_out_to_modulo is not None and self.pad_out_to_modulo > 1:
result['unpad_to_size'] = result['image'].shape[1:]
result['image'] = pad_img_to_modulo(result['image'], self.pad_out_to_modulo)
result['mask'] = pad_img_to_modulo(result['mask'], self.pad_out_to_modulo)

Loading…
Cancel
Save