summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/ultralytics/default.nix
blob: dba583b0a608e64a859bce99e09c548ad8d1c827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  lap,
  matplotlib,
  opencv-python,
  pandas,
  pillow,
  polars,
  psutil,
  py-cpuinfo,
  pyyaml,
  requests,
  scipy,
  seaborn,
  torch,
  torchvision,
  tqdm,
  ultralytics-thop,

  # tests
  aiohttp,
  onnx,
  onnxruntime,
  pytestCheckHook,
}:

buildPythonPackage (finalAttrs: {
  pname = "ultralytics";
  version = "8.4.6";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "ultralytics";
    repo = "ultralytics";
    tag = "v${finalAttrs.version}";
    hash = "sha256-kNOldJvJlyBkV7VeETtxQJdtToJyGID2dEIq1z0Fg1c=";
  };

  build-system = [ setuptools ];

  pythonRelaxDeps = [
    "numpy"
  ];

  dependencies = [
    lap
    matplotlib
    opencv-python
    pandas
    pillow
    polars
    psutil
    py-cpuinfo
    pyyaml
    requests
    scipy
    scipy
    seaborn
    torch
    torchvision
    tqdm
    ultralytics-thop
  ];

  pythonImportsCheck = [ "ultralytics" ];

  nativeCheckInputs = [
    aiohttp
    onnx
    onnxruntime
    pytestCheckHook
  ];

  enabledTestPaths = [
    # rest of the tests require internet access
    "tests/test_python.py"
  ];

  disabledTests = [
    # also remove the individual tests that require internet
    "test_predict_gray_and_4ch"
    "test_all_model_yamls"
    "test_data_annotator"
    "test_labels_and_crops"
    "test_model_embeddings"
    "test_model_methods"
    "test_predict_callback_and_setup"
    "test_predict_grey_and_4ch"
    "test_predict_img"
    "test_predict_txt"
    "test_predict_visualize"
    "test_results"
    "test_train_pretrained"
    "test_train_scratch"
    "test_utils_torchutils"
    "test_val"
    "test_workflow"
    "test_yolo_world"
    "test_yolov10"
    "test_yoloe"
    "test_multichannel"
    "test_grayscale"
  ]
  ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
    # Fatal Python error: Aborted
    # onnxruntime/capi/_pybind_state.py", line 32 in <module>
    "test_utils_benchmarks"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # Fatal Python error: Aborted
    # ultralytics/utils/checks.py", line 598 in check_imshow
    "test_utils_checks"

    # RuntimeError: required keyword attribute 'value' has the wrong type
    "test_utils_benchmarks"

    # RuntimeError: Dataset 'https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8-ndjson.ndjson'
    # error <E2><9D><8C> [Errno 13] Permission denied:
    # '/nix/store/rnns5r21nibx26f2c2gxdk3h8l0jcg68-python3.12-ultralytics-8.3.221/datasets/coco8-ndjson/labels/train/000000000009.txt'
    "test_train_ndjson"
  ];

  meta = {
    homepage = "https://github.com/ultralytics/ultralytics";
    changelog = "https://github.com/ultralytics/ultralytics/releases/tag/${finalAttrs.src.tag}";
    description = "Train YOLO models for computer vision tasks";
    mainProgram = "yolo";
    license = lib.licenses.agpl3Only;
    maintainers = with lib.maintainers; [ osbm ];
  };
})