1{ lib
2, buildPythonPackage
3, fetchPypi
4, pythonOlder
5, matplotlib
6, numpy
7, opencv4
8, pillow
9, scikit-learn
10, torch
11, torchvision
12, ttach
13, tqdm
14}:
15
16buildPythonPackage rec {
17 pname = "grad-cam";
18 version = "1.4.8";
19 disabled = pythonOlder "3.6";
20 format = "pyproject";
21
22 src = fetchPypi {
23 inherit pname version;
24 hash = "sha256-BNcwDaEEmRsEoJ4nvvGfjZ9LdG0eRqZCFuY5/Gmp5N4=";
25 };
26
27 postPatch = ''
28 substituteInPlace requirements.txt --replace "opencv-python" "opencv"
29 '';
30
31 propagatedBuildInputs = [
32 matplotlib
33 numpy
34 opencv4
35 pillow
36 scikit-learn
37 torchvision
38 ttach
39 tqdm
40 ];
41
42 # Let the user bring their own instance (as with torchmetrics)
43 buildInputs = [
44 torch
45 ];
46
47 doCheck = false; # every nontrivial test tries to download a pretrained model
48
49 pythonImportsCheck = [
50 "pytorch_grad_cam"
51 "pytorch_grad_cam.metrics"
52 "pytorch_grad_cam.metrics.cam_mult_image"
53 "pytorch_grad_cam.metrics.road"
54 "pytorch_grad_cam.utils"
55 "pytorch_grad_cam.utils.image"
56 "pytorch_grad_cam.utils.model_targets"
57 ];
58
59 meta = with lib; {
60 description = "Advanced AI explainability for computer vision.";
61 homepage = "https://jacobgil.github.io/pytorch-gradcam-book";
62 license = licenses.mit;
63 maintainers = with maintainers; [ bcdarwin ];
64 };
65}