Git Product home page Git Product logo

Comments (8)

serengil avatar serengil commented on June 1, 2024

extract_faces is already returning facial area as

face_objs = DeepFace.extract_faces(img)
for face_obj in face_objs:
   x = ["facial_area"]["x"]
   y = ["facial_area"]["y"]
   w = ["facial_area"]["w"]
   h = ["facial_area"]["h"]

then, face center point is

face_center = (int(y + h/2), int(x + w/2))

from deepface.

serengil avatar serengil commented on June 1, 2024

expand_area is also an optional argument and its default value is 0.

i do not think this is a necessary change.

from deepface.

deepfree2023 avatar deepfree2023 commented on June 1, 2024

It's right that face center point can be easily obtained in normal cases.

But not in the case I've described (real scenario includes face swapping, if more environmental info is required, expand_percentage need to be a large value). In this case, the calculated face center point using x,y,w,h obtained from extract_faces will not be the same as the real face center point before expanding.

Because in the simple expanding algorithm, if one side reaches image edge, the expanding area will stop increase at that side, but still increase in the opposite side. Thus the face center point will keep on drifting towards the opposite side.

from deepface.

deepfree2023 avatar deepfree2023 commented on June 1, 2024

The problem can be resolved by using trial and error method to set a valid expand_percentage value. But in batch processing scenario, it's not possible to adjust expand_percentage for each run.

from deepface.

serengil avatar serengil commented on June 1, 2024

I limited the facial area with boundaries if it exceeds in purpose. Because I can monitor that using this approach has an impact on facial recognition accuracy. I prefer not to terminate expanding if it exceeds the boundaries.

from deepface.

deepfree2023 avatar deepfree2023 commented on June 1, 2024

I see. But I've got a lot of result images from extract_faces with head + neck and chest, even more body part, othertimes maybe small head under lots of sky... Since I have to generate square image from the result images for next step processing, without real face center info, I don't know how to achieve that.

Currently I modified deepface source code to return extra real face center info before expanding, it works quite well.

from deepface.

deepfree2023 avatar deepfree2023 commented on June 1, 2024

For different image size, head size, head position, the largest expand_percentage value without changing the face center position is different, this makes single-expand_percentage-for-all method not working.

from deepface.

serengil avatar serengil commented on June 1, 2024

Customization the source code is fine in your case. But again I do not think that change is required in the source code of the repo.

from deepface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.