CivArchive
    ComfyUI - FaceRestore Node - v0.2
    Preview 663263

    Go to https://github.com/mav-rik/facerestore_cf for a more up to date fork of this project.

    These ComfyUI nodes can be used to restore faces in images similar to the face restore option in AUTOMATIC1111 webui.

    Installation

    Extract the zip and put the facerestore directory inside the ComfyUI custom_nodes directory.

    If running the portable windows version of ComfyUI, run embedded_install.bat

    Windows users not running the portable version can run install.bat. Linux and mac users can run install.sh

    If the install fails for whatever reason, you'll need to work out how to install opencv-python yourself (you'll get a cv2 not found error otherwise)

    Face Restoration Models

    These models perform the face restoration. If you use automatic1111 you probably already have them but if not here are the download links.

    Just put them in models/facerestore_models.

    https://github.com/TencentARC/GFPGAN/releases/

    https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth

    https://github.com/sczhou/CodeFormer/releases/

    https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth

    Face detection models

    The face restoration model only works with cropped face images. A face detection model is used to send a crop of each face found to the face restoration model.

    These will automaticly be downloaded and placed in models/facedetection the first time each is used.

    Here's the links if you'd rather download them yourself.

    https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth

    https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_mobilenet0.25_Final.pth

    https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/yolov5l-face.pth

    https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/yolov5n-face.pth

    This also gets downloaded and put in the facedetection folder. It's used to put the restored faces back into the original image.

    https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/parsing_parsenet.pth

    Description

    • Fixed FileNotFoundError Issue some people are having.

    • Added CropFace node, which crops a face without restoring it (maybe useful for comparing the different face detectors). Returns a cropped face and the total faces found. Use index to select a face from an image with multiple faces.

    FAQ

    Comments (14)

    abline11Jul 12, 2023
    CivitAI

    It's a great tool that works very well until you want to increase batch size to > 1. Then it fails with error:->

    !!! Exception during processing !!!

    Traceback (most recent call last):

    File "C:\AI\ComfyUI_windows\ComfyUI\execution.py", line 145, in recursive_execute

    output_data, output_ui = get_output_data(obj, input_data_all)

    File "C:\AI\ComfyUI_windows\ComfyUI\execution.py", line 75, in get_output_data

    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)

    File "C:\AI\ComfyUI_windows\ComfyUI\execution.py", line 68, in map_node_over_list

    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))

    File "C:\AI\ComfyUI_windows\ComfyUI\custom_nodes\facerestore\__init__.py", line 132, in restore_face

    self.face_helper.read_image(image_np)

    File "C:\AI\ComfyUI_windows\ComfyUI\custom_nodes\facerestore\facelib\utils\face_restoration_helper.py", line 131, in read_image

    self.input_img = cv2.resize(self.input_img, (0,0), fx=f, fy=f, interpolation=cv2.INTER_LINEAR)

    cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\resize.cpp:3699: error: (-215:Assertion failed) !dsize.empty() in function 'cv::hal::resize'

    I can instead, of course, just press the Queue Prompt button repeatedly with 'seed' on 'increment' until I've queued the number of images I want to generate.

    nanunanaJul 14, 2023

    can u share your workflow with me?

    abline11Jul 16, 2023

    @nanunana yes, I'd be happy to send you the json file. How do I actually do that on here? Do you have an email address?

    nanunanaJul 17, 2023

    @abline11 [email protected] i thank you very much

    abline11Jul 17, 2023

    @nanunana Hi Mike, I've send you the JSON and associated PNG file in an email. Thanks for looking at it.

    m99
    Author
    Jul 17, 2023

    @abline11 Looks like your review image dissappeared. I'm guessing civit incorrectly auto tagged it as nsfw and removed it. I used to have preview images that showed the face restore in action but that caused this 'model' to be classified as nsfw and be unviewable to anyone not signed in with filters turned off.

    nanunanaJul 17, 2023· 1 reaction

    @abline11 thanx a lot

    You may need to use the "rebatchLatents" node before you decode them. That should then work with batches.

    nanunanaJul 14, 2023
    CivitAI

    Don´t work:

    No module named 'cv2'

    m99
    Author
    Jul 14, 2023

    See the comment left by Andress17 for how to fix that. I'll make the dependency auto-install If I get around to updating this.

    nanunanaJul 14, 2023

    @m99 i´ve solved the problem, i installed first the v1.0 than the v2.0 over it. that works otherwise something is missing

    nanunanaJul 14, 2023

    @m99 but where i find the comment ofAndress17 ???

    thedeadtaco888Jul 18, 2023

    Per flyingshutter's comment, go into the comfyui root folder from a command prompt/console and type:

    .\python_embeded\python -m pip install opencv-python

    malaprisJul 21, 2023
    CivitAI

    It worked just fine until yesterday and now there is a problem with opencv resize :(

    you need to add a requirements.txt file with this :

    opencv-python-4.8.0.74

    Other
    Other
    by m99

    Details

    Downloads
    800
    Platform
    CivitAI
    Platform Status
    Available
    Created
    5/2/2023
    Updated
    5/11/2026
    Deleted
    -

    Available On (1 platform)

    Same model published on other platforms. May have additional downloads or version variants.