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