Background restoration not being applied #114

Open
opened 2026-01-29 21:42:43 +00:00 by claunia · 7 comments
Owner

Originally created by @Brian-Vineland on GitHub (Dec 12, 2021).

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.

Originally created by @Brian-Vineland on GitHub (Dec 12, 2021). 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.
Author
Owner

@celikmustafa89 commented on GitHub (Dec 13, 2021):

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

@celikmustafa89 commented on GitHub (Dec 13, 2021): How can we colorize the whole image instead of only the face part?
Author
Owner

@Brian-Vineland commented on GitHub (Dec 13, 2021):

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 commented on GitHub (Dec 13, 2021): > 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).
Author
Owner

@tasbirul commented on GitHub (Jan 2, 2022):

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 commented on GitHub (Jan 2, 2022): > 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
Author
Owner

@Arcyno commented on GitHub (Jan 3, 2022):

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

@Arcyno commented on GitHub (Jan 3, 2022): It does not work if you don't have cuda enabled. I got the background improvement when I managed to install cuda
Author
Owner

@shyamjos commented on GitHub (Aug 16, 2022):

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 commented on GitHub (Aug 16, 2022): 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 ````
Author
Owner

@ppetrucz commented on GitHub (Sep 5, 2022):

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 commented on GitHub (Sep 5, 2022): 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
Author
Owner

@Thumulavamshi commented on GitHub (Jun 8, 2025):

@Brian-Vineland & @ppetrucz, were you able to resolve this issue? Are you now able to restore both the faces and the non-face regions of the images?"

@Thumulavamshi commented on GitHub (Jun 8, 2025): @Brian-Vineland & @ppetrucz, were you able to resolve this issue? Are you now able to restore both the faces and the non-face regions of the images?"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#114