Skip to main content

A face detection library based on libfacedetection

Project description

Yuface

PyPI License

Introduction

A super fast face detector packaged by the libfacedetection repository using pybind11.

Change Log

[2023-5-8] Project init.

Quick start

pip install yuface

Usage

  1. Load image
# opencv
import cv2
img = cv2.imread('xxx.jpg')

# PIL
import PIL
import numpy as np
img = PIL.Image.open('xxx.jpg').convert('RGB')
img = np.array(img)                             # convert to numpy array
img = img[:, :, ::-1]                           # convert to BGR

# imageio
import imageio as io
img = io.imread('xxx.jpg')
img = img[:, :, ::-1]                           # convert to BGR
  1. Detect
# img: numpy.ndarray, shape=(H, W, 3), dtype=uint8, BGR
# conf_thresh: float, confidence threshold, default=0.5, range=[0.0, 0.1]
from yuface import detect
confs, bboxes, landmarks = detect(img, conf_thresh=0.5)
  1. Deal result
# confs: numpy.ndarray, shape=(N,), dtype=uint16, confidence 
# bboxes: numpy.ndarray, shape=(N, 4), dtype=uint16, bounding box (XYWH)
# landmarks: numpy.ndarray, shape=(N, 10), dtype=uint16, landmarks (XYXYXYXYXY)
import cv2
for conf, bbox, landmark in zip(confs, bboxes, landmarks):
    cv2.rectangle(img, (bbox[0], bbox[1]), (bbox[0] + bbox[2], bbox[1] + bbox[3]), (0, 255, 0), 1)
    cv2.putText(img, str(conf), (bbox[0], bbox[1]), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 1)
    for i in range(5):
        cv2.circle(img, (landmark[2*i], landmark[2*i+1]), 2, (0, 255, 0), 1)
cv2.imwrite('result.jpg', img)

result

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

yuface-2023.5.1-cp311-cp311-win_amd64.whl (230.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

yuface-2023.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (474.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

yuface-2023.5.1-cp310-cp310-win_amd64.whl (230.7 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

yuface-2023.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (474.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

yuface-2023.5.1-cp39-cp39-win_amd64.whl (230.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

yuface-2023.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (474.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

yuface-2023.5.1-cp38-cp38-win_amd64.whl (230.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

yuface-2023.5.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (474.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

yuface-2023.5.1-cp37-cp37m-win_amd64.whl (230.9 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

yuface-2023.5.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (475.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

yuface-2023.5.1-cp36-cp36m-win_amd64.whl (231.1 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

yuface-2023.5.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (475.2 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page