dchatel / comfyui_facetools

These custom nodes provide a rotation aware face extraction, paste back, and various face related masking options.
MIT License
67 stars 8 forks source link

Face detection on images bigger than 1.2mpix #8

Open Maelstrom2014 opened 3 months ago

Maelstrom2014 commented 3 months ago

Hi, Creator! Im resizing input image to Npixels with ImageScaleToTotalPixels Face detection on images bigger than 1.2pix outputs black image. "Detect faces" node set max size to 2000, threshold 0.8.

dchatel commented 3 months ago

If you get a black image, that means it did not detect any face that satisfy the conditions (min size, max size and/or threshold). You can try lowering the threshold first.

Maelstrom2014 commented 3 months ago

Why this image not detected in such resolution?

port_face https://images.bauerhosting.com/legacy/lifestyle-legacy/25/1c000/c14fc/771a6/3a730/e74e8/abc69/Beyonce%20hair%20styles%209_700x1050.jpg?auto=format&w=1440&q=80

Detect faces set to: max_size=2000, threshold =0.8

dchatel commented 3 months ago

I just tested it. It appears to be a case where face_yolov8m model don't detect the face unless you set a threshold lower or equal to 0.54. And even if you do, it has enough difficulty that it gets the alignment incorrectly.

The issue lies in the face_yolov8m model. You can try other models here: https://github.com/akanametov/yolov8-face, under the section Trained models. Download one of the face models (yolov8l-face works in this case), and put it in comfyui/models/ultralytics/bbox/ Then, in face_tools, you need to change utils.py on line 36: instead of face_yolov8m.pt, you set yolov8l-face.t (or whatever the filename of the model you downloaded is).

I'll see if I make a change to the nodes, so you can choose your own yolov model without having to do this.

Maelstrom2014 commented 3 months ago

Please add a option to choose model from node menu. It will be great!

Maelstrom2014 commented 3 months ago

I just tested it. It appears to be a case where face_yolov8m model don't detect the face unless you set a threshold lower or equal to 0.54. And even if you do, it has enough difficulty that it gets the alignment incorrectly.

The issue lies in the face_yolov8m model. You can try other models here: https://github.com/akanametov/yolov8-face, under the section Trained models. Download one of the face models (yolov8l-face works in this case), and put it in comfyui/models/ultralytics/bbox/ Then, in face_tools, you need to change utils.py on line 36: instead of face_yolov8m.pt, you set yolov8l-face.t (or whatever the filename of the model you downloaded is).

I'll see if I make a change to the nodes, so you can choose your own yolov model without having to do this.

another way is to make image 0.5 pixels (downscale). so it not a automatic solution. How to inpaint back to bigger size of image? Warps and "face" wire for another resolution?