Files
insightface/deploy/test.py

29 lines
696 B
Python
Raw Normal View History

2018-01-26 13:07:00 +08:00
import argparse
import cv2
import sys
2018-01-26 13:07:00 +08:00
import numpy as np
2021-05-04 16:17:50 +08:00
import insightface
from insightface.app import FaceAnalysis
2018-01-26 13:07:00 +08:00
2021-05-04 22:38:07 +08:00
assert insightface.__version__>='0.2'
2021-05-04 16:17:50 +08:00
parser = argparse.ArgumentParser(description='insightface test')
2018-01-26 13:07:00 +08:00
# general
2021-05-04 16:17:50 +08:00
parser.add_argument('--ctx', default=0, type=int, help='ctx id, <0 means using cpu')
2018-01-26 13:07:00 +08:00
args = parser.parse_args()
2021-05-04 16:17:50 +08:00
app = FaceAnalysis(name='antelope')
2021-05-04 22:38:07 +08:00
app.prepare(ctx_id=args.ctx, det_size=(640,640))
2020-11-07 13:22:05 +08:00
2021-05-04 22:38:07 +08:00
img = cv2.imread('../sample-images/t1.jpg')
2021-05-04 16:17:50 +08:00
faces = app.get(img)
2021-05-04 22:38:07 +08:00
assert len(faces)==6
rimg = app.draw_on(img, faces)
cv2.imwrite("./t1_output.jpg", rimg)
2021-05-04 16:17:50 +08:00
print(len(faces))
for face in faces:
print(face.bbox)
print(face.kps)
print(face.embedding.shape)
2020-11-07 13:22:05 +08:00