Files
2026-10-14 12:12:25 +03:00

95 lines
2.3 KiB
Nix

{
lib,
buildPythonPackage,
cython,
fetchFromGitHub,
fetchurl,
matplotlib,
pillow,
pytest-mock,
pytestCheckHook,
pywavelets,
scikit-learn,
setuptools,
torch,
torchvision,
tqdm,
writableTmpDirAsHomeHook,
}:
let
MobileNetV3 = fetchurl {
url = "https://download.pytorch.org/models/mobilenet_v3_small-047dcff4.pth";
hash = "sha256-BH3P9K3e+G6lvC7/E8lhTcEfR6sRYNCnGiXn25lPTh8=";
};
ViT = fetchurl {
url = "https://download.pytorch.org/models/vit_b_16_swag-9ac1b537.pth";
hash = "sha256-msG1N42ZJ71sg3TODNVX74Dhs/j7wYWd8zLE3J0P2CU=";
};
EfficientNet = fetchurl {
url = "https://download.pytorch.org/models/efficientnet_b4_rwightman-23ab8bcd.pth";
hash = "sha256-I6uLzVvb72GnpDuRrcrYH2Iv1/NvtJNaVpgo13iIxE4=";
};
in
buildPythonPackage (finalAttrs: {
pname = "imagededup";
version = "0.3.3.post2";
pyproject = true;
src = fetchFromGitHub {
owner = "idealo";
repo = "imagededup";
tag = "v${finalAttrs.version}";
hash = "sha256-+/83xsfbrny8x7szVQezix+FBYvoeYXNfTA+Go18ASY=";
};
# don't install the docs generator as a top-level `mkdocs` package
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail 'exclude = ["tests*"]' 'exclude = ["tests*", "mkdocs*"]'
'';
build-system = [
cython
setuptools
];
dependencies = [
matplotlib
pillow
pywavelets
scikit-learn
torch
torchvision
tqdm
];
nativeCheckInputs = [
pytest-mock
pytestCheckHook
writableTmpDirAsHomeHook
];
preCheck = ''
# Checks with CNN are preloaded to avoid downloads in the check phase
mkdir -p $HOME/.cache/torch/hub/checkpoints/
ln -s ${MobileNetV3} $HOME/.cache/torch/hub/checkpoints/${MobileNetV3.name}
ln -s ${ViT} $HOME/.cache/torch/hub/checkpoints/${ViT.name}
ln -s ${EfficientNet} $HOME/.cache/torch/hub/checkpoints/${EfficientNet.name}
'';
disabledTests = [
# deletes the preloaded MobileNet checkpoint, so later tests try to download it
"test_import_defaults"
];
pythonImportsCheck = [ "imagededup" ];
meta = {
homepage = "https://idealo.github.io/imagededup/";
changelog = "https://github.com/idealo/imagededup/releases/tag/${finalAttrs.src.tag}";
description = "Finding duplicate images made easy";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ stunkymonkey ];
};
})