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.92";
26 pyproject = true;
27
28 disabled = pythonOlder "3.7";
29
30 src = fetchFromGitHub {
31 owner = "serengil";
32 repo = "deepface";
33 rev = "refs/tags/v${version}";
34 hash = "sha256-Vjm8lfpGyJ7/1CUwIvxXxHqwmv0+iKewYV3vE08gpPQ=";
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/detectors/OpenCv.py \
44 --replace-fail "opencv_home = cv2.__file__" "opencv_home = os.readlink(cv2.__file__)" \
45 --replace-fail "folders = opencv_home.split(os.path.sep)[0:-1]" "folders = opencv_home.split(os.path.sep)[0:-4]" \
46 --replace-fail "return path + \"/data/\"" "return path + \"/share/opencv4/haarcascades/\""
47 '';
48
49 build-system = [ setuptools ];
50
51 dependencies = [
52 fire
53 flask
54 flask-cors
55 gdown
56 gunicorn
57 mtcnn
58 numpy
59 opencv4
60 pandas
61 pillow
62 requests
63 retinaface
64 tensorflow
65 tqdm
66 ];
67
68 # requires internet connection
69 doCheck = false;
70
71 pythonImportsCheck = [ "deepface" ];
72
73 meta = {
74 description = "Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python";
75 homepage = "https://github.com/serengil/deepface";
76 changelog = "https://github.com/serengil/deepface/releases/tag/v${version}";
77 license = lib.licenses.mit;
78 maintainers = with lib.maintainers; [ derdennisop ];
79 };
80}