Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 stdenv, 3 lib, 4 buildPythonPackage, 5 fetchFromGitHub, 6 ninja, 7 which, 8 # build inputs 9 pillow, 10 matplotlib, 11 pycocotools, 12 termcolor, 13 yacs, 14 tabulate, 15 cloudpickle, 16 tqdm, 17 tensorboard, 18 fvcore, 19 iopath, 20 omegaconf, 21 hydra-core, 22 packaging, 23 torch, 24 pydot, 25 black, 26 # optional dependencies 27 fairscale, 28 timm, 29 scipy, 30 shapely, 31 pygments, 32 psutil, 33 # check inputs 34 pytestCheckHook, 35 torchvision, 36 av, 37 opencv4, 38 pytest-mock, 39 pybind11, 40}: 41 42let 43 pname = "detectron2"; 44 version = "0.6"; 45 optional-dependencies = { 46 all = [ 47 fairscale 48 timm 49 scipy 50 shapely 51 pygments 52 psutil 53 ]; 54 }; 55in 56buildPythonPackage { 57 inherit pname version; 58 format = "setuptools"; 59 60 src = fetchFromGitHub { 61 owner = "facebookresearch"; 62 repo = "detectron2"; 63 rev = "refs/tags/v${version}"; 64 sha256 = "1w6cgvc8r2lwr72yxicls650jr46nriv1csivp2va9k1km8jx2sf"; 65 }; 66 67 postPatch = '' 68 # https://github.com/facebookresearch/detectron2/issues/5010 69 substituteInPlace detectron2/data/transforms/transform.py \ 70 --replace "interp=Image.LINEAR" "interp=Image.BILINEAR" 71 ''; 72 73 nativeBuildInputs = [ 74 ninja 75 which 76 ]; 77 78 buildInputs = [ pybind11 ]; 79 80 pythonRelaxDeps = [ "black" ]; 81 82 propagatedBuildInputs = [ 83 pillow 84 matplotlib 85 pycocotools 86 termcolor 87 yacs 88 tabulate 89 cloudpickle 90 tqdm 91 tensorboard 92 fvcore 93 iopath 94 omegaconf 95 hydra-core 96 packaging 97 black 98 torch # not explicitly declared in setup.py because they expect you to install it yourself 99 pydot # no idea why this is not in their setup.py 100 ]; 101 102 passthru.optional-dependencies = optional-dependencies; 103 104 nativeCheckInputs = [ 105 av 106 opencv4 107 pytest-mock 108 pytestCheckHook 109 torchvision 110 ]; 111 112 preCheck = '' 113 # prevent import errors for C extension modules 114 rm -r detectron2 115 ''; 116 117 pytestFlagsArray = [ 118 # prevent include $sourceRoot/projects/*/tests 119 "tests" 120 ]; 121 122 disabledTestPaths = [ 123 # try import caffe2 124 "tests/test_export_torchscript.py" 125 "tests/test_model_analysis.py" 126 "tests/modeling/test_backbone.py" 127 "tests/modeling/test_roi_heads.py" 128 "tests/modeling/test_rpn.py" 129 "tests/structures/test_instances.py" 130 # hangs for some reason 131 "tests/modeling/test_model_e2e.py" 132 # KeyError: 'precision' 133 "tests/data/test_coco_evaluation.py" 134 ]; 135 136 disabledTests = 137 [ 138 # fails for some reason 139 "test_checkpoint_resume" 140 "test_map_style" 141 # requires shapely 142 "test_resize_and_crop" 143 # require caffe2 144 "test_predict_boxes_tracing" 145 "test_predict_probs_tracing" 146 "testMaskRCNN" 147 "testRetinaNet" 148 # require coco dataset 149 "test_default_trainer" 150 "test_unknown_category" 151 "test_build_dataloader_train" 152 "test_build_iterable_dataloader_train" 153 # require network access 154 "test_opencv_exif_orientation" 155 "test_read_exif_orientation" 156 # use deprecated api, numpy.bool 157 "test_BWmode_nomask" 158 "test_draw_binary_mask" 159 "test_draw_empty_mask_predictions" 160 "test_draw_instance_predictions" 161 "test_draw_no_metadata" 162 "test_overlay_instances" 163 "test_overlay_instances_no_boxes" 164 "test_get_bounding_box" 165 ] 166 ++ lib.optionals (stdenv.isLinux && stdenv.isAarch64) [ 167 "test_build_batch_dataloader_inference" 168 "test_build_dataloader_inference" 169 "test_build_iterable_dataloader_inference" 170 "test_to_iterable" 171 ]; 172 173 pythonImportsCheck = [ "detectron2" ]; 174 175 meta = with lib; { 176 description = "Facebooks's next-generation platform for object detection, segmentation and other visual recognition tasks"; 177 homepage = "https://github.com/facebookresearch/detectron2"; 178 license = licenses.asl20; 179 maintainers = with maintainers; [ happysalada ]; 180 }; 181}