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 pythonOlder,
16 requests,
17 retinaface,
18 setuptools,
19 tensorflow,
20 tqdm,
21}:
22
23buildPythonPackage rec {
24 pname = "deepface";
25 version = "0.0.94";
26 pyproject = true;
27
28 disabled = pythonOlder "3.7";
29
30 src = fetchFromGitHub {
31 owner = "serengil";
32 repo = "deepface";
33 tag = "v${version}";
34 hash = "sha256-jtDj1j2STjoEW6MdQai6ZuRYVmLo0Ga+VPJ01105Byc=";
35 };
36
37 postPatch = ''
38 # prevent collisions
39 substituteInPlace setup.py \
40 --replace-fail "data_files=[(\"\", [\"README.md\", \"requirements.txt\", \"package_info.json\"])]," "" \
41 --replace-fail "install_requires=requirements," ""
42
43 substituteInPlace deepface/models/face_detection/OpenCv.py \
44 --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/\""
45 '';
46
47 build-system = [ setuptools ];
48
49 dependencies = [
50 fire
51 flask
52 flask-cors
53 gdown
54 gunicorn
55 mtcnn
56 numpy
57 opencv4
58 pandas
59 pillow
60 requests
61 retinaface
62 tensorflow
63 tqdm
64 ];
65
66 # requires internet connection
67 doCheck = false;
68
69 pythonImportsCheck = [ "deepface" ];
70
71 meta = {
72 description = "Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python";
73 homepage = "https://github.com/serengil/deepface";
74 changelog = "https://github.com/serengil/deepface/releases/tag/${src.tag}";
75 license = lib.licenses.mit;
76 maintainers = with lib.maintainers; [ derdennisop ];
77 };
78}