Coder Social home page Coder Social logo

Comments (4)

0phoi5 avatar 0phoi5 commented on May 26, 2024

The relevant section of code that needs amendment is in ~/.local/lib/python3.10/site-packages/deepface/commons/functions.py;

# img might be path, base64 or numpy array. Convert it to numpy whatever it is.
    img, img_name = load_image(img)
    img_region = [0, 0, img.shape[1], img.shape[0]]

    if detector_backend == "skip":
        face_objs = [(img, img_region, 0)]
    else:
        face_objs = DetectorWrapper.detect_faces(detector_backend, img, align)

from deepface.

0phoi5 avatar 0phoi5 commented on May 26, 2024

Possibly not the perfect solution, but this works well enough.
{img_name} needs to be printed at the point of failure. I used a try/except, one can then see what image failed to read correctly and simply remove it from the input directory or fix the image itself.

    # img might be path, base64 or numpy array. Convert it to numpy whatever it is.
    try:
        img, img_name = load_image(img)
        img_region = [0, 0, img.shape[1], img.shape[0]]

        if detector_backend == "skip":
            face_objs = [(img, img_region, 0)]
        else:
            face_objs = DetectorWrapper.detect_faces(detector_backend, img, align)
    except AttributeError as e:
        raise ValueError(f"Unreadable file - AttributeError occured for {img_name}: {e}")
ValueError: Unreadable file - AttributeError occured for /path/to/dir/failed_image.jpg: 'NoneType' object has no attribute 'shape'

from deepface.

serengil avatar serengil commented on May 26, 2024

Definitely, users should see a meaningful exception message.

Firstly, as I see you are using an old version of DeepFace. Would you please update the package first? This may not be an issue for the current package.

Instead of using try catch, I prefer to raise an error if img is None after load_image performed: https://github.com/serengil/deepface/blob/master/deepface/modules/detection.py#L77

from deepface.

serengil avatar serengil commented on May 26, 2024

Closed with PR - #1038

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.