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