{"library":"mtcnn","title":"MTCNN (Multi-task Cascaded Convolutional Networks)","description":"The `mtcnn` library provides a Python implementation of the Multi-task Cascaded Convolutional Networks (MTCNN) for robust face detection and alignment. It is currently at version 1.0.0, supporting Python >= 3.10 and TensorFlow >= 2.12. Releases are infrequent, indicating a mature and stable codebase.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install mtcnn"],"cli":null},"imports":["from mtcnn.mtcnn import MTCNN"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import cv2\nfrom mtcnn.mtcnn import MTCNN\n\n# Example image (replace with your path or download one)\n# For demonstration, we'll create a dummy image if file not found\ntry:\n    img_path = 'sample_image.jpg' # Replace with a path to a real image\n    img = cv2.imread(img_path)\n    if img is None:\n        # Create a blank image with a simple 'face' if sample_image.jpg not found\n        print(f\"Warning: '{img_path}' not found. Creating a dummy image.\")\n        img = 255 * (cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (50, 50)))\n        img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)\n        # Add a simple rectangle to simulate a face\n        cv2.rectangle(img, (100, 100), (200, 200), (0, 0, 255), 2)\n\nexcept Exception as e:\n    print(f\"Error loading image or creating dummy: {e}\")\n    # Fallback to a completely black image if even dummy creation fails\n    img = (255 * (cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (50, 50))))\n    img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)\n\n# MTCNN expects RGB images, OpenCV loads BGR by default\nimg_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n\n# Initialize the MTCNN detector\ndetector = MTCNN()\n\n# Detect faces in the image\nfaces = detector.detect_faces(img_rgb)\n\n# Print detected faces (each face is a dict with 'box', 'confidence', 'keypoints')\nfor face in faces:\n    print(face)\n\n# Optional: Draw bounding boxes and keypoints on the original image\n# for face in faces:\n#     x, y, width, height = face['box']\n#     cv2.rectangle(img, (x, y), (x + width, y + height), (0, 255, 0), 2)\n#     for key, value in face['keypoints'].items():\n#         cv2.circle(img, value, 2, (0, 0, 255), 2)\n# cv2.imshow('Detected Faces', img)\n# cv2.waitKey(0)\n# cv2.destroyAllWindows()\n","lang":"python","description":"This quickstart demonstrates how to load an image (using OpenCV, converting to RGB), initialize the MTCNN detector, and use `detect_faces` to find faces and their keypoints. The output `faces` is a list of dictionaries, where each dictionary contains the bounding box, confidence score, and facial keypoints.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"0.1.1","pypi_latest":"1.0.0","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":3.4,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"mtcnn","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"mtcnn","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.9,"import_time_s":null,"mem_mb":null,"disk_size":"28M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"mtcnn","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"mtcnn","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.9,"import_time_s":null,"mem_mb":null,"disk_size":"31M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"mtcnn","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"mtcnn","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"22M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"mtcnn","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"mtcnn","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"22M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"mtcnn","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"mtcnn","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":9.5,"import_time_s":null,"mem_mb":null,"disk_size":"358M"}]}}