Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoneType' object has no attribute 'groups' when using YoloV8 on deepface==0.0.84 #1022

Closed
gbaufake opened this issue Feb 14, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@gbaufake
Copy link

gbaufake commented Feb 14, 2024

Hi @serengil,

Is there an issue when analyzing with Yolo v8?

code sample:
analysis = DeepFace.analyze(img, actions=('emotion'), enforce_detection=False, detector_backend=['yolo_, silent=True)

Logs:

2024-02-14 03:48:24,079 [Thread-14 (analyze_video_with_backend)] INFO: {"level": 20, "message": "Detector processed frames", "detector_backend": "yolov8", "processed_frames": 100, "total_frames": 2568}
2024-02-14 03:48:25,791 [Thread-14 (analyze_video_with_backend)] ERROR: {"level": 40, "message": "Error in DeepFace Analysis", "error_detail": "'NoneType' object has no attribute 'groups'"}

I could not find anywhere on the code that groups might be used.

@serengil serengil added the bug Something isn't working label Feb 14, 2024
@serengil
Copy link
Owner

serengil commented Feb 14, 2024

Need detailed exception message please

Normally, exception thrown module and line info should be printed. As I understand, you customize something because these are not standard output of deepface.

@serengil
Copy link
Owner

serengil commented Feb 14, 2024

When I test that backend as

DeepFace.analyze(img_path=img_path, detector_backend="yolov8")

Then I am having a successful response.

[{'emotion': {'angry': 0.27702577454904015,
   'disgust': 1.6584374963028672e-06,
   'fear': 5.269103613165452e-05,
   'happy': 58.46902829039434,
   'sad': 0.10684493573024102,
   'surprise': 0.004627124696059116,
   'neutral': 41.14242388515757},
  'dominant_emotion': 'happy',
  'region': {'x': 233, 'y': 79, 'w': 152, 'h': 216},
  'face_confidence': 0.863529622554779,
  'age': 30,
  'gender': {'Woman': 99.9902606010437, 'Man': 0.009742558904690668},
  'dominant_gender': 'Woman',
  'race': {'asian': 0.2046308602172649,
   'indian': 0.3006282674523155,
   'black': 0.02210449442703989,
   'white': 83.31937094446248,
   'middle eastern': 7.54583746468052,
   'latino hispanic': 8.607432014193058},
  'dominant_race': 'white'}]

So, your case may be related to the input image you are feeding (share with me if it is not private), or depending on your customization.

@serengil
Copy link
Owner

That error message should come from regex, and regex is not being used in deepface. You may get it from something different than deepface?

@serengil
Copy link
Owner

Closed because exception message is not coming from deepface

@Any-Winter-4079
Copy link

Here's a bit more information about the error:

Traceback (most recent call last):
  File "project/face_recognition/deepface_library/find_match.py", line 32, in <module>
    dfs = DeepFace.find(img_path=test_image_path,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "project/tensorflow-metal-test/lib/python3.11/site-packages/deepface/DeepFace.py", line 296, in find
    return recognition.find(
           ^^^^^^^^^^^^^^^^^
  File "project/tensorflow-metal-test/lib/python3.11/site-packages/deepface/modules/recognition.py", line 209, in find
    source_objs = detection.extract_faces(
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "project/tensorflow-metal-test/lib/python3.11/site-packages/deepface/modules/detection.py", line 84, in extract_faces
    face_objs = DetectorWrapper.detect_faces(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "project/tensorflow-metal-test/lib/python3.11/site-packages/deepface/detectors/DetectorWrapper.py", line 82, in detect_faces
    face_detector: Detector = build_model(detector_backend)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "project/tensorflow-metal-test/lib/python3.11/site-packages/deepface/detectors/DetectorWrapper.py", line 50, in build_model
    face_detector = face_detector()
                    ^^^^^^^^^^^^^^^
  File "project/tensorflow-metal-test/lib/python3.11/site-packages/deepface/detectors/Yolo.py", line 25, in __init__
    self.model = self.build_model()
                 ^^^^^^^^^^^^^^^^^^
  File "project/tensorflow-metal-test/lib/python3.11/site-packages/deepface/detectors/Yolo.py", line 47, in build_model
    gdown.download(WEIGHT_URL, weight_path, quiet=False)
  File "project/tensorflow-metal-test/lib/python3.11/site-packages/gdown/download.py", line 259, in download
    filename_from_url = m.groups()[0]
                        ^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'groups'

@Any-Winter-4079
Copy link

Any-Winter-4079 commented Feb 24, 2024

A hack to solve this:
The weights come from here:
https://drive.google.com/uc?id=1qcr9DbgsX3ryrz2uU8w4Xm3cOrRywXqb

You can download them and put them on your equivalent of this path:
/Users/myself/.deepface/weights/yolov8n-face.pt

Or to be sure, print it in Yolo.py

weight_path = f"{folder_utils.get_deepface_home()}{PATH}"
print(weight_path)

@serengil serengil reopened this Feb 24, 2024
@serengil
Copy link
Owner

Closed with PR - #1038

Thank you @Any-Winter-4079

@gbaufake
Copy link
Author

@serengil can you release a new version of DeepaFace on Pypi?

@serengil
Copy link
Owner

I will do it soon, meanwhile you can use the source code as

$ git clone https://github.com/serengil/deepface.git
$ cd deepface
$ pip install -e .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants