microsoft / Bringing-Old-Photos-Back-to-Life

Bringing Old Photo Back to Life (CVPR 2020 oral)
https://arxiv.org/abs/2004.09484
MIT License
14.68k stars 1.93k forks source link

Mask Detection is producing wrong size #141

Open mahesh557 opened 3 years ago

mahesh557 commented 3 years ago

HI,

I tried to generate mask for image of size 1180 768 It produced mask of size 1184 768

D:\photo_restoration\Global>python detection.py --test_path input --output_dir output --input_size full_size --GPU -1
initializing the dataloader
model weights loaded
directory of testing image: input
processing final_momdad.jpeg

Due to mismatched sizes, restoration failed with below error

D:\photo_restoration\Global>python test.py --Scratch_and_Quality_restore --test_input input --test_mask output\mask --outputs_dir output --gpu_ids -1
You are using NL + Res
Now you are processing final_momdad.jpeg
Traceback (most recent call last):
  File "D:\photo_restoration\Global\test.py", line 139, in <module>
    input = irregular_hole_synthesize(input, mask)
  File "D:\photo_restoration\Global\test.py", line 53, in irregular_hole_synthesize
    img_new = img_np * (1 - mask_np) + mask_np * 255
ValueError: operands could not be broadcast together with shapes (768,1180,3) (768,1184,3)
Jayyyyyyyyyyyy commented 3 years ago

do your fix it?

mahesh557 commented 3 years ago

nope.. can't do anything..

syfbme commented 3 years ago

The source code will resize image's height and weight to 16 multiple. So you can resize your image too using code like: oh = int(round(oh / 16) * 16) ow = int(round(ow / 16) * 16)

p1x31 commented 2 years ago

I can reproduce this when running sequentially one after another, but I can not reproduce this with Full Pipeline. Could be related to h = int(round(oh / 4) * 4) vs h = int(round(oh / 16) * 16)

p1x31 commented 2 years ago

detection.py produces two folders input and mask, input containing your original image with the right rescale. After running detection.py your command should be python test.py --Scratch_and_Quality_restore --test_input output/input --test_mask output/mask --outputs_dir output --gpu_ids -1 providing the right path for --test_input flag run.py works fine because it propagates paths correctly.

tainmo commented 2 years ago

how to solve this ValueError? everyone who know?