Is there any way, to extract every still picture with a face in it, without the whole picture cropped? i would prefer to work with deepfacelab, but if you know any other free open source app/code it will also work
2 Answers
- Take a frame / picture
- Resize it - decrease dimensions in x times
- Detect any face(s) there. Is yes - you've got THAT face picture.

- 753
- 1
- 9
- 18
-
i dont get it. (sorry i am a little bit new in this topic) – Erik Ehlers Nov 30 '21 at 23:01
-
If so.. Well, you could try to explore examples from deepface, try to write your code and then come back here. – Bohdan Dec 01 '21 at 05:30
Do you mean to collect the frames from the video, from which the faces are extracted? One way could be the following - this is how I extract faces lately:
- Export target frames to files before extracting the faces with DFL. E.g. select only regions from the video, do not process the whole. It's simple with Virtualdub. (Another solution is to edit the video and leave only the desired frames, then process the whole video).
The frames extraction could be done with ffmpeg script as well, something like:
ffmpeg -i input.mp4 '%04d.png'
Fastest way to extract frames using ffmpeg?
VirtualDub:
File->Export->Image Sequence
Invoke the DFL extract script with paths set to that directory. The script will store the extracted faces with the file names of these frames.
You can run a simple python script which checks the filenames of the extracted faces (a bit of string operations may be needed if there are many faces and there are extensions _0, _1 etc.) and copy the respective names where you want.
Of course you can do the last operation manually as well - just see the names of the files, usually regions, and copy the respective original frames.
With a Python script, one way to scan a dir and take the files is (Windows):
import glob
where = "Z:\\video\\"
files = glob.glob(where+"*.jpg") #also png etc.
Another more advanced solution would be to modify the DFL code to automatically save also the whole frames during extraction (if done from a video), or just to print/store the filenames if extracting from stills - collect the paths in a file/script, and then if the user wants she can run it to copy the frames somewhere.
Lately I've been working on a DFL extension, I may add such a function, too.
PS. BTW, usually you may need all frames from the target video anyway, if you want to merge with all frames with faces on them.

- 825
- 7
- 15