{"id":28143,"library":"retinaface-py","title":"RetinaFace","description":"A Python implementation of RetinaFace, a single-stage dense face localisation model for face detection and landmark localisation in the wild. Current version 0.0.2, requires Python >=3.6, uses PyTorch. The library wraps a pre-trained ResNet50-based RetinaFace model. Release cadence: low (last update likely 2021).","status":"active","version":"0.0.2","language":"python","source_language":"en","source_url":"https://github.com/andresprados/Pytorch_Retinaface","tags":["face-detection","retinaface","pytorch","computer-vision"],"install":[{"cmd":"pip install retinaface-py","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"Core dependency for model inference; must be installed separately if not using PyTorch-compatible environment.","package":"torch","optional":false},{"reason":"Required for image preprocessing and transforms.","package":"torchvision","optional":false},{"reason":"Used for array operations and bounding box processing.","package":"numpy","optional":false},{"reason":"Required for image loading and handling.","package":"Pillow","optional":false},{"reason":"Optional but recommended for additional image I/O and visualization.","package":"opencv-python","optional":true}],"imports":[{"note":"Common mistake: using lowercase 'retinaface'. The correct module name is 'RetinaFace' with capital R and F.","wrong":"from retinaface import RetinaFace","symbol":"RetinaFace","correct":"from RetinaFace import RetinaFace"}],"quickstart":{"code":"\nfrom RetinaFace import RetinaFace\nimport cv2\n\n# Load image (assuming opencv-python is installed)\nimg = cv2.imread('face.jpg')\nimg_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n\n# Detect faces\ndetections = RetinaFace.detect_faces(img_rgb)\n\n# Print results\nfor face_id, face_data in detections.items():\n    print(f\"{face_id}: score={face_data['score']}, box={face_data['facial_area']}\")\n","lang":"python","description":"Detect faces in an image using RetinaFace. The input image should be a numpy array (RGB). Returns a dictionary of detections."},"warnings":[{"fix":"Use the correct import statement: from RetinaFace import RetinaFace","message":"The module name is case-sensitive: 'RetinaFace' not 'retinaface'. Import as 'from RetinaFace import RetinaFace'.","severity":"gotcha","affected_versions":"*"},{"fix":"Convert BGR to RGB before passing: img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)","message":"Input image must be a numpy array in RGB format, not BGR. OpenCV loads images as BGR by default.","severity":"gotcha","affected_versions":"*"},{"fix":"Consider using alternative face detection libraries like DeepFace, MTCNN, or dlib.","message":"The library is no longer actively maintained; last version 0.0.2 released around 2021. May not work with newer PyTorch versions.","severity":"deprecated","affected_versions":"0.0.2"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use: from RetinaFace import RetinaFace","cause":"Incorrect module name used in import. The correct module is 'RetinaFace' with capital letters.","error":"ModuleNotFoundError: No module named 'retinaface'"},{"fix":"Use: detector = RetinaFace(); detections = detector.detect_faces(img) or simply RetinaFace.detect_faces(img)","cause":"Trying to call the class directly instead of using the static method detect_faces.","error":"TypeError: 'RetinaFace' object is not callable"},{"fix":"Ensure image is a 3-channel RGB numpy array with dtype uint8.","cause":"Passing an image with non-RGB channels (e.g., RGBA) or incorrect dtype.","error":"ValueError: The truth value of an array with more than one element is ambiguous"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}