1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, fetchurl
5, cython
6, torch
7, torchvision
8, pillow
9, tqdm
10, scikit-learn
11, pywavelets
12, matplotlib
13, pytestCheckHook
14, pytest-mock
15}:
16let
17 MobileNetV3 = fetchurl {
18 url = "https://download.pytorch.org/models/mobilenet_v3_small-047dcff4.pth";
19 hash = "sha256-BH3P9K3e+G6lvC7/E8lhTcEfR6sRYNCnGiXn25lPTh8=";
20 };
21 ViT = fetchurl {
22 url = "https://download.pytorch.org/models/vit_b_16_swag-9ac1b537.pth";
23 hash = "sha256-msG1N42ZJ71sg3TODNVX74Dhs/j7wYWd8zLE3J0P2CU=";
24 };
25 EfficientNet = fetchurl {
26 url = "https://download.pytorch.org/models/efficientnet_b4_rwightman-7eb33cd5.pth";
27 hash = "sha256-I6uLzVvb72GnpDuRrcrYH2Iv1/NvtJNaVpgo13iIxE4=";
28 };
29in
30buildPythonPackage rec {
31 pname = "imagededup";
32 version = "0.3.2";
33 format = "setuptools";
34
35 src = fetchFromGitHub {
36 owner = "idealo";
37 repo = pname;
38 rev = "v${version}";
39 hash = "sha256-B2IuNMTZnzBi6IxrHBoMDsmIcqGQpznd/2f1XKo1Oa4=";
40 };
41
42 nativeBuildInputs = [
43 cython
44 ];
45
46 propagatedBuildInputs = [
47 torch
48 torchvision
49 pillow
50 tqdm
51 scikit-learn
52 pywavelets
53 matplotlib
54 ];
55
56 nativeCheckInputs = [ pytestCheckHook pytest-mock ];
57
58 preCheck = ''
59 # checks fail with: error: [Errno 13] Permission denied: '/homeless-shelter'
60 export HOME=$(mktemp -d)
61
62 # checks with CNN are preloaded to avoid downloads in check-phase
63 mkdir -p $HOME/.cache/torch/hub/checkpoints/
64 ln -s ${MobileNetV3} $HOME/.cache/torch/hub/checkpoints/${MobileNetV3.name}
65 ln -s ${ViT} $HOME/.cache/torch/hub/checkpoints/${ViT.name}
66 ln -s ${EfficientNet} $HOME/.cache/torch/hub/checkpoints/${EfficientNet.name}
67 '';
68
69 pythonImportsCheck = [ "imagededup" ];
70
71 meta = with lib; {
72 homepage = "https://idealo.github.io/imagededup/";
73 changelog = "https://github.com/idealo/imagededup/releases/tag/${src.rev}";
74 description = "Finding duplicate images made easy";
75 license = licenses.asl20;
76 maintainers = with maintainers; [ stunkymonkey ];
77 };
78}