2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
isPy27,
|
|
|
|
numpy,
|
|
|
|
scikit-learn,
|
|
|
|
pytestCheckHook,
|
|
|
|
torch,
|
|
|
|
torchvision,
|
|
|
|
tqdm,
|
|
|
|
faiss,
|
2020-05-29 06:06:01 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2024-06-05 15:53:02 +00:00
|
|
|
pname = "pytorch-metric-learning";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "2.5.0";
|
2024-01-02 11:29:13 +00:00
|
|
|
format = "setuptools";
|
2020-05-29 06:06:01 +00:00
|
|
|
|
|
|
|
disabled = isPy27;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "KevinMusgrave";
|
|
|
|
repo = pname;
|
2022-08-12 12:06:08 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-1y7VCnzgwFOMeMloVdYyszNhf/zZlBJUjuF4qgA5c0A=";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
numpy
|
2022-09-09 14:08:57 +00:00
|
|
|
torch
|
2021-05-20 23:08:51 +00:00
|
|
|
scikit-learn
|
2020-05-29 06:06:01 +00:00
|
|
|
torchvision
|
|
|
|
tqdm
|
|
|
|
];
|
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME=$TMP
|
|
|
|
export TEST_DEVICE=cpu
|
|
|
|
export TEST_DTYPES=float32,float64 # half-precision tests fail on CPU
|
|
|
|
'';
|
2022-08-12 12:06:08 +00:00
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
# package only requires `unittest`, but use `pytest` to exclude tests
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-08-12 12:06:08 +00:00
|
|
|
faiss
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
disabledTests =
|
|
|
|
[
|
|
|
|
# TypeError: setup() missing 1 required positional argument: 'world_size'
|
|
|
|
"TestDistributedLossWrapper"
|
|
|
|
# require network access:
|
|
|
|
"TestInference"
|
|
|
|
"test_get_nearest_neighbors"
|
|
|
|
"test_tuplestoweights_sampler"
|
|
|
|
"test_untrained_indexer"
|
|
|
|
"test_metric_loss_only"
|
|
|
|
"test_pca"
|
|
|
|
# flaky
|
|
|
|
"test_distributed_classifier_loss_and_miner"
|
|
|
|
]
|
|
|
|
++ lib.optionals (stdenv.isLinux && stdenv.isAarch64) [
|
|
|
|
# RuntimeError: DataLoader worker (pid(s) <...>) exited unexpectedly
|
|
|
|
"test_global_embedding_space_tester"
|
|
|
|
"test_with_same_parent_label_tester"
|
|
|
|
];
|
2020-11-15 13:44:38 +00:00
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
meta = {
|
|
|
|
description = "Metric learning library for PyTorch";
|
|
|
|
homepage = "https://github.com/KevinMusgrave/pytorch-metric-learning";
|
|
|
|
changelog = "https://github.com/KevinMusgrave/pytorch-metric-learning/releases/tag/v${version}";
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
maintainers = with lib.maintainers; [ bcdarwin ];
|
|
|
|
};
|
|
|
|
}
|