Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
This repo provides the out-of-box face detection and face alignment with batch input support and enables real-time application on CPU.
While not required, for optimal performance it is highly recommended to run the code using a CUDA enabled GPU.
The easiest way to install it is using pip:
pip install git+https://github.com/elliottzheng/batch-face.git@master
No extra setup needs, most of the pretrained weights will be downloaded automatically.
You can clone the repo and run tests like this
python -m tests.camera
import cv2
from batch_face import RetinaFace
detector = RetinaFace(gpu_id=0)
img = cv2.imread("examples/obama.jpg")
faces = detector(img, cv=True) # set cv to False for rgb input, the default value of cv is False
box, landmarks, score = faces[0]
In order to specify the device (GPU or CPU) on which the code will run one can explicitly pass the device id.
from batch_face import RetinaFace
# 0 means using GPU with id 0 for inference
# default -1: means using cpu for inference
detector = RetinaFace(gpu_id=0)
GPU(GTX 1080TI,batch size=1) | GPU(GTX 1080TI,batch size=750) | CPU(Intel(R) Core(TM) i7-7800X CPU @ 3.50GHz) | |
---|---|---|---|
FPS | 44.02405810720893 | 96.64058005582535 | 15.452635835550483 |
SPF | 0.022714852809906007 | 0.010347620010375976 | 0.0647138786315918 |
Detector with CUDA process batch input faster than the same amount of single input.
import cv2
from batch_face import RetinaFace
detector = RetinaFace()
img= cv2.imread('examples/obama.jpg')[...,::-1]
all_faces = detector([img,img]) # return faces list of all images
box, landmarks, score = all_faces[0][0]
Note: All the input images must of the same size, for input images with different size, please use detector.pseudo_batch_detect
.
from batch_face import drawLandmark_multiple, LandmarkPredictor, RetinaFace
predictor = LandmarkPredictor(0)
detector = RetinaFace(0)
imgname = "examples/obama.jpg"
img = cv2.imread(imgname)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
faces = detector(img)
if len(faces) == 0:
print("NO face is detected!")
exit(-1)
# the first input for the predictor is a list of face boxes. [[x1,y1,x2,y2]]
results = predictor(faces, img, from_fd=True) # from_fd=True to convert results from our detection results to simple boxes
for face, landmarks in zip(faces, results):
img = drawLandmark_multiple(img, face[0], landmarks)
FAQs
Batch Face Preprocessing for Modern Research
We found that batch-face demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.