Arminius-Software / face2video

MIT License
61 stars 3 forks source link

Keep Original Frame when no Face found #7

Closed tokenwizard closed 3 weeks ago

tokenwizard commented 1 month ago

Hi, I actually created a similar script to dump a video to frames and then feed those into ComfyUI ReActor node, 500 at a time, to limit RAM usage. The issue I'm facing, and wondering if your script accounts for, is if there are frames that do not have a detectable face, does your setup keep those original frames?

For example, if there are 5000 total frames, and only 4500 have a detectable face, then my output (swapped) frames no longer match the duration of the original video, meaning when I recombine the audio track, they become out of sync.

Arminius-Software commented 4 weeks ago

Hi, yes the way the reactor api in automatic 1111 is set up it will simply return the original image if no face is detected. One way to fix your issue would be to write a script with something like retinaface (https://github.com/serengil/retinaface) to do a initial check for all images if they contain a face or not and then only enter the images that contain a face and keep the rest for the final video. However that would slow it down a lot. Maybe you can alter the comfy node to behave similar to the automatic 1111 reactor api.