1{
2 lib,
3 albumentations,
4 buildPythonPackage,
5 cython,
6 easydict,
7 fetchPypi,
8 insightface,
9 matplotlib,
10 mxnet,
11 numpy,
12 onnx,
13 onnxruntime,
14 opencv4,
15 pillow,
16 prettytable,
17 pythonOlder,
18 requests,
19 setuptools,
20 scipy,
21 scikit-image,
22 scikit-learn,
23 testers,
24 tqdm,
25 stdenv,
26}:
27
28buildPythonPackage rec {
29 pname = "insightface";
30 version = "0.7.3";
31 pyproject = true;
32
33 disabled = pythonOlder "3.8";
34
35 src = fetchPypi {
36 inherit pname version;
37 hash = "sha256-8ZH3GWEuuzcBj0GTaBRQBUTND4bm/NZ2wCPzVMZo3fc=";
38 };
39
40 build-system = [
41 cython
42 setuptools
43 ];
44
45 dependencies = [
46 albumentations
47 easydict
48 matplotlib
49 mxnet # used in insightface/commands/rec_add_mask_param.py
50 numpy
51 onnx
52 onnxruntime
53 opencv4
54 pillow
55 prettytable
56 requests
57 scikit-learn
58 scikit-image
59 scipy
60 tqdm
61 ];
62
63 # aarch64-linux tries to get cpu information from /sys, which isn't available
64 # inside the nix build sandbox.
65 dontUsePythonImportsCheck = stdenv.buildPlatform.system == "aarch64-linux";
66
67 passthru.tests = lib.optionalAttrs (stdenv.buildPlatform.system != "aarch64-linux") {
68 version = testers.testVersion {
69 package = insightface;
70 command = "insightface-cli --help";
71 # Doesn't support --version but we still want to make sure the cli is executable
72 # and returns the help output
73 version = "help";
74 };
75 };
76
77 pythonImportsCheck = [
78 "insightface"
79 "insightface.app"
80 "insightface.data"
81 ];
82
83 doCheck = false; # Upstream has no tests
84
85 meta = {
86 description = "State-of-the-art 2D and 3D Face Analysis Project";
87 mainProgram = "insightface-cli";
88 homepage = "https://github.com/deepinsight/insightface";
89 license = lib.licenses.mit;
90 maintainers = with lib.maintainers; [ oddlama ];
91 };
92}