GFPGAN icon indicating copy to clipboard operation
GFPGAN copied to clipboard

Background restoration not being applied

Open Brian-Vineland opened this issue 4 years ago • 7 comments

Excellent work, thank you for making this available!

When I run the original paper model with the commands included in PaperModel.md I get colorization but not background restoration. In the results folder there are the cropped faces and they look great, but then the full restored images just include that cropped region restored with colorization then simply pasted into the original image (with no other restoration around the cropped region).

Note that I see the tiles being processed in the prompt.

Brian-Vineland avatar Dec 12 '21 17:12 Brian-Vineland

How can we colorize the whole image instead of only the face part?

celikmustafa89 avatar Dec 13 '21 10:12 celikmustafa89

How can we colorize the whole image instead of only the face part?

Just to clarify I get no colorization or quality improvement for the background. I tried Real-ESRGAN by itself and also don't get any improvement to the image (with or without enhanced face processing by connecting GFPGAN through it).

Brian-Vineland avatar Dec 13 '21 14:12 Brian-Vineland

Excellent work, thank you for making this available!

When I run the original paper model with the commands included in PaperModel.md I get colorization but not background restoration. In the results folder there are the cropped faces and they look great, but then the full restored images just include that cropped region restored with colorization then simply pasted into the original image (with no other restoration around the cropped region).

Note that I see the tiles being processed in the prompt.

Try Real-ESRGAN: https://github.com/xinntao/Real-ESRGAN

tasbirul avatar Jan 02 '22 14:01 tasbirul

It does not work if you don't have cuda enabled. I got the background improvement when I managed to install cuda

Arcyno avatar Jan 03 '22 18:01 Arcyno

To enable background enhancement on computers without GPU, you need to modify code (inference_gfpgan.py) as below, This worked on my ThinkPad with AMD ryzen7 CPU ( no dedicated GPU)

Original code

    # ------------------------ set up background upsampler ------------------------
    if args.bg_upsampler == 'realesrgan':
        if not torch.cuda.is_available():  # CPU
            import warnings
            warnings.warn('The unoptimized RealESRGAN is slow on CPU. We do not use it. '
                          'If you really want to use it, please modify the corresponding codes.')
            bg_upsampler = None

Modified Code (To enable BG enhancement on CPU mode)

    # ------------------------ set up background upsampler ------------------------
    if args.bg_upsampler == 'realesrgan':
        if not torch.cuda.is_available():  # CPU
            import warnings
            warnings.warn('The unoptimized RealESRGAN is slow on CPU. We do not use it. '
                          'If you really want to use it, please modify the corresponding codes.')
            from basicsr.archs.rrdbnet_arch import RRDBNet
            from realesrgan import RealESRGANer
            model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2)
            bg_upsampler = RealESRGANer(
                scale=2,
                model_path='https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth',
                model=model,
                tile=args.bg_tile,
                tile_pad=10,
                pre_pad=0,
                half=False)  # need to set False in CPU mode

shyamjos avatar Aug 16 '22 02:08 shyamjos

Background restoration not working for me. I've followed the paper model instructions, and I am able to colourize and restore faces but not the background. Cuda is installed and when I run the inference_gfpgan.py I can see the job running with nvidia-smi. I've installed pip install realesrgan as well. Edit: Background is being upscaled as well, but not colorized

ppetrucz avatar Sep 05 '22 15:09 ppetrucz