Code Monkey home page Code Monkey logo

Comments (1)

dfacct avatar dfacct commented on August 29, 2024

If you comment line 22 and uncomment lines 79-80 of align_images_masked.py, you will find it speeds up alignment dramatically and works with high resolution images. The problem is that the aligned face is sourced from an 800px copy of the original, which looks pretty awful if the face is far from the camera.

I've never written Python before, but I made some changes that perform get_landmarks on an 800px copy then upscales the landmarks so the aligned face is sourced from the original and maintains sharpness. I tested it with 6000x4000px images and it worked fine with my 1060. I also perform 90º rotations until a face is found. I'm not sure if this is worth adding to the main repository, but check my fork if you want to try it out, it's much faster if using GPU and still reasonably accurate:
https://github.com/dfacct/df/blob/master/align_images_masked.py

I added 4 optional arguments:
--fast-mode (creates an 800px copy before performing get_landmarks, then upscales landmarks so the aligned image is sourced from the orginal)
--fast-mode-size default 800 (in pixels, smaller = faster/less accurate)
--try-rotated (rotates the image by 90º, 180º, and 270º, stopping when a face is found. Will increase overall processing time but will likely find more faces)
--use-gpu (disables monkey_patch_face_detector and utilizes GPU)

Try this command and tinker with the fast-mode-size argument to find the best speed/accuracy balance.
python align_images_masked.py c:\source-images --fast-mode --fast-mode-size 800 --try-rotated --use-gpu

from df.

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.