Pypi の Insightface ライブラリ ( https://pypi.org/project/insightface/ ) を使用しています。ソース コードはこちら: https://github.com/deepinsight/insightface/blob/master/python-package/ Insightface/model_zoo/scrfd.py .
GPUで実行すると、CPUのRAMの深刻なメモリリークが発生し、停止するまで40 GBを超えます(GPUメモリではありません)。
ここに私のスクリプトがあります:
import insightface
import cv2
import time
model = insightface.app.FaceAnalysis()
# It happens only when using GPU !!!
ctx_id = 0
image_path = "my-face-image.jpg"
image = cv2.imread(image_path)
model.prepare(ctx_id = ctx_id, det_thresh=0.3, det_size=[416, 416])
detector = model.models["detection"]
for i in range(100000):
start_t = time.time()
bboxes, landmarks = detector.detect(image)
end_t = time.time()
print('Detection time: {}'.format(end_t - start_t))
print('DONE')
私のセットアップは(ドッカー内)です:
- Docker ベース イメージ - nvidia/cuda:11.0.3-cudnn8-devel-ubuntu18.04
- Nvidia ドライバー - 465.27
- パイソン-3.6.9
- Insightface==0.3.8
- mxnet==1.8.0.post0
- mxnet-cu110==2.0.0a0
- numpy==1.18.5
- onnx==1.9.0
- onnxruntime-gpu==1.8.1