1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 lap,
12 matplotlib,
13 opencv-python,
14 pandas,
15 pillow,
16 polars,
17 psutil,
18 py-cpuinfo,
19 pyyaml,
20 requests,
21 scipy,
22 seaborn,
23 torch,
24 torchvision,
25 tqdm,
26 ultralytics-thop,
27
28 # tests
29 pytestCheckHook,
30 onnx,
31 onnxruntime,
32}:
33
34buildPythonPackage rec {
35 pname = "ultralytics";
36 version = "8.3.203";
37 pyproject = true;
38
39 src = fetchFromGitHub {
40 owner = "ultralytics";
41 repo = "ultralytics";
42 tag = "v${version}";
43 hash = "sha256-j19eHxhrkvZ8tyVjO+VSNwXHrH1+c16g9byg69G7miI=";
44 };
45
46 build-system = [ setuptools ];
47
48 pythonRelaxDeps = [
49 "numpy"
50 ];
51
52 dependencies = [
53 lap
54 matplotlib
55 opencv-python
56 pandas
57 pillow
58 polars
59 psutil
60 py-cpuinfo
61 pyyaml
62 requests
63 scipy
64 scipy
65 seaborn
66 torch
67 torchvision
68 tqdm
69 ultralytics-thop
70 ];
71
72 pythonImportsCheck = [ "ultralytics" ];
73
74 nativeCheckInputs = [
75 pytestCheckHook
76 onnx
77 onnxruntime
78 ];
79
80 enabledTestPaths = [
81 # rest of the tests require internet access
82 "tests/test_python.py"
83 ];
84
85 disabledTests = [
86 # also remove the individual tests that require internet
87 "test_all_model_yamls"
88 "test_data_annotator"
89 "test_labels_and_crops"
90 "test_model_embeddings"
91 "test_model_methods"
92 "test_predict_callback_and_setup"
93 "test_predict_grey_and_4ch"
94 "test_predict_img"
95 "test_predict_txt"
96 "test_predict_visualize"
97 "test_results"
98 "test_train_pretrained"
99 "test_train_scratch"
100 "test_utils_torchutils"
101 "test_val"
102 "test_workflow"
103 "test_yolo_world"
104 "test_yolov10"
105 "test_yoloe"
106 "test_multichannel"
107 "test_grayscale"
108 ]
109 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
110 # Fatal Python error: Aborted
111 # onnxruntime/capi/_pybind_state.py", line 32 in <module>
112 "test_utils_benchmarks"
113 ]
114 ++ lib.optionals stdenv.hostPlatform.isDarwin [
115 # Fatal Python error: Aborted
116 # ultralytics/utils/checks.py", line 598 in check_imshow
117 "test_utils_checks"
118
119 # RuntimeError: required keyword attribute 'value' has the wrong type
120 "test_utils_benchmarks"
121 ];
122
123 meta = {
124 homepage = "https://github.com/ultralytics/ultralytics";
125 changelog = "https://github.com/ultralytics/ultralytics/releases/tag/${src.tag}";
126 description = "Train YOLO models for computer vision tasks";
127 mainProgram = "yolo";
128 license = lib.licenses.agpl3Only;
129 maintainers = with lib.maintainers; [ osbm ];
130 };
131}