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