1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fire,
6 flask,
7 flask-cors,
8 gdown,
9 gunicorn,
10 mtcnn,
11 numpy,
12 opencv4,
13 pandas,
14 pillow,
15 requests,
16 retinaface,
17 setuptools,
18 tensorflow,
19 tqdm,
20}:
21
22buildPythonPackage rec {
23 pname = "deepface";
24 version = "0.0.95";
25 pyproject = true;
26
27 src = fetchFromGitHub {
28 owner = "serengil";
29 repo = "deepface";
30 tag = "v${version}";
31 hash = "sha256-BLbDW/NBeLKFcijMSeYfYxSFmqfG8WYHbVQpFyvMEZY=";
32 };
33
34 postPatch = ''
35 # prevent collisions
36 substituteInPlace setup.py \
37 --replace-fail "data_files=[(\"\", [\"README.md\", \"requirements.txt\", \"package_info.json\"])]," "" \
38 --replace-fail "install_requires=requirements," ""
39
40 substituteInPlace deepface/models/face_detection/OpenCv.py \
41 --replace-fail "opencv_path = self.__get_opencv_path()" "opencv_path = '/'.join(os.path.dirname(cv2.__file__).split(os.path.sep)[0:-4]) + \"/share/opencv4/haarcascades/\""
42 '';
43
44 build-system = [ setuptools ];
45
46 dependencies = [
47 fire
48 flask
49 flask-cors
50 gdown
51 gunicorn
52 mtcnn
53 numpy
54 opencv4
55 pandas
56 pillow
57 requests
58 retinaface
59 tensorflow
60 tqdm
61 ];
62
63 # requires internet connection
64 doCheck = false;
65
66 pythonImportsCheck = [ "deepface" ];
67
68 meta = {
69 description = "Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python";
70 homepage = "https://github.com/serengil/deepface";
71 changelog = "https://github.com/serengil/deepface/releases/tag/${src.tag}";
72 license = lib.licenses.mit;
73 maintainers = with lib.maintainers; [ derdennisop ];
74 };
75}