about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/video/deface/default.nix
blob: 428275535af49d450ef607890bbaec72d265a903 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ lib
, stdenv
, python3
, fetchFromGitHub
, makeWrapper
, pkgs
}:

python3.pkgs.buildPythonApplication rec {
  pname = "deface";
  version = "1.4.0";
  format = "pyproject";

  src = fetchFromGitHub {
    owner = "ORB-HD";
    repo = "deface";
    rev = "v${version}";
    hash = "sha256-tLNTgdnKKmyYHVajz0dHIb7cvC1by5LQ5CFIbMvPEYk=";
  };

  nativeBuildInputs = with python3.pkgs; [
    setuptools-scm
  ];

  propagatedBuildInputs = with python3.pkgs; [
    imageio
    imageio-ffmpeg
    numpy
    onnx
    onnxruntime # Nixpkgs onnxruntime is missing CUDA support
    opencv4
    scikit-image
    tqdm
  ];

  # Native onnxruntime lib used by Python module onnxruntime can't find its other libs without this
  makeWrapperArgs = [
    ''--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ pkgs.onnxruntime ]}"''
  ];

  patchPhase = ''
    substituteInPlace pyproject.toml requirements.txt --replace "opencv-python" "opencv"
  '';

  pythonImportsCheck = [ "deface" "onnx" "onnxruntime" ];

  meta = with lib; {
    description = "Video anonymization by face detection";
    homepage = "https://github.com/ORB-HD/deface";
    license = licenses.mit;
    maintainers = with maintainers; [ lurkki ];
    mainProgram = "deface";
  };
}