Restores face effectively, but doesn't output it correctly. #422

Open
opened 2026-01-29 21:47:38 +00:00 by claunia · 0 comments
Owner

Originally created by @MattPenaTV on GitHub (Dec 10, 2023).

I input an image, like the following, to GFPGAN:

image

Then, I run the code:

import os

from .tools import copy_image

def enhance(image_path):
    filter_folder = "filters/enhance/GFPGAN"
    # Move image into inputs folder
    copy_image(image_path, os.path.join(filter_folder, "inputs/whole_imgs/image.png"))
    # Use GFPGAN (github.com/TencentARC/GFPGAN/tree/master)
    # to enhance image face
    # (still do it even if no face, b/c it adds minor touches)
    os.system(f'''cd {filter_folder}\n
    python3 inference_gfpgan.py -i "inputs/whole_imgs" -o "results" -v 1.3 -s 1
    ''')
    return
    
enhance("thumbnail.png")

When I check the results folder, I get the expected results for "cmp", "cropped_faces", and "restored_faces":
image_00
image_00
image_00

But when I check for the entire restored image in "restored_imgs", I get the same image that I inputted:
image

Here is the full terminal output when I run this code:

/opt/homebrew/lib/python3.11/site-packages/torchvision/transforms/functional_tensor.py:5: UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.
  warnings.warn(
/Users/matthewpena/Documents/Archived/Code/tools2/thumbnailcomposer/filters/enhance/GFPGAN/inference_gfpgan.py:63: UserWarning: The unoptimized RealESRGAN is slow on CPU. We do not use it. If you really want to use it, please modify the corresponding codes.
  warnings.warn('The unoptimized RealESRGAN is slow on CPU. We do not use it. '
/opt/homebrew/lib/python3.11/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
  warnings.warn(
/opt/homebrew/lib/python3.11/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=None`.
  warnings.warn(msg)
Processing image.png ...
Results are in the [results] folder.

Additional Information:

  • When I try running this code with the default images that come when you download GFPGAN, the faces in "restored_imgs" are beautified, as expected.

Any idea what could be causing this?

Originally created by @MattPenaTV on GitHub (Dec 10, 2023). I input an image, like the following, to GFPGAN: ![image](https://github.com/TencentARC/GFPGAN/assets/107569942/9f7b52d9-720f-453a-82f2-6581206e449d) Then, I run the code: ``` import os from .tools import copy_image def enhance(image_path): filter_folder = "filters/enhance/GFPGAN" # Move image into inputs folder copy_image(image_path, os.path.join(filter_folder, "inputs/whole_imgs/image.png")) # Use GFPGAN (github.com/TencentARC/GFPGAN/tree/master) # to enhance image face # (still do it even if no face, b/c it adds minor touches) os.system(f'''cd {filter_folder}\n python3 inference_gfpgan.py -i "inputs/whole_imgs" -o "results" -v 1.3 -s 1 ''') return enhance("thumbnail.png") ``` When I check the results folder, I get the expected results for "cmp", "cropped_faces", and "restored_faces": ![image_00](https://github.com/TencentARC/GFPGAN/assets/107569942/bc40c6c7-6058-43b3-9df3-671025c5bf7b) ![image_00](https://github.com/TencentARC/GFPGAN/assets/107569942/99619e95-e026-49c8-a964-4c6a2cc7083f) ![image_00](https://github.com/TencentARC/GFPGAN/assets/107569942/08cf7022-1562-4a3f-aa3f-eeab23c208a1) But when I check for the entire restored image in "restored_imgs", I get the same image that I inputted: ![image](https://github.com/TencentARC/GFPGAN/assets/107569942/8508b5d7-6c58-4b35-829b-f50cbb6220f3) Here is the full terminal output when I run this code: ``` /opt/homebrew/lib/python3.11/site-packages/torchvision/transforms/functional_tensor.py:5: UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional. warnings.warn( /Users/matthewpena/Documents/Archived/Code/tools2/thumbnailcomposer/filters/enhance/GFPGAN/inference_gfpgan.py:63: UserWarning: The unoptimized RealESRGAN is slow on CPU. We do not use it. If you really want to use it, please modify the corresponding codes. warnings.warn('The unoptimized RealESRGAN is slow on CPU. We do not use it. ' /opt/homebrew/lib/python3.11/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead. warnings.warn( /opt/homebrew/lib/python3.11/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=None`. warnings.warn(msg) Processing image.png ... Results are in the [results] folder. ``` Additional Information: - When I try running this code with the default images that come when you download GFPGAN, the faces in "restored_imgs" are beautified, as expected. Any idea what could be causing this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#422