How to use "FaceDetectorYN"

you do not need any contrib modules for this,

but a more recent opencv version (4.5.3 does not have this class)

then, try the sample here