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