about summary refs log tree commit diff
path: root/pkgs/applications/video/deface/default.nix
blob: 054bb04aee72a047e53ffbac35f9615e7a90549f (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
55
56
57
58
59
{ lib
, stdenv
, python3
, fetchFromGitHub
, pkgs
}:

python3.pkgs.buildPythonApplication rec {
  pname = "deface";
  version = "1.5.0";
  pyproject = true;

  disabled = python3.pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "ORB-HD";
    repo = "deface";
    rev = "refs/tags/v${version}";
    hash = "sha256-/mXWeL6OSgW4BMXtAZD/3UxQUGt7UE5ZvH8CXNCueJo=";
  };

  build-system = with python3.pkgs; [
    setuptools-scm
  ];

  dependencies = 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 ]}"''
  ];

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "opencv-python" "opencv"
  '';

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

  meta = {
    description = "Video anonymization by face detection";
    homepage = "https://github.com/ORB-HD/deface";
    changelog = "https://github.com/ORB-HD/deface/releases/tag/v${version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ lurkki ];
    mainProgram = "deface";
    # terminate called after throwing an instance of 'onnxruntime::OnnxRuntimeException'
    broken = stdenv.hostPlatform.system == "aarch64-linux";
  };
}