summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/mlx-vlm/default.nix
blob: 9a5f6d6bc13376ebe3b7ef7811fd999aa68e45cf (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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  datasets,
  fastapi,
  mlx,
  mlx-lm,
  numpy,
  opencv-python,
  pillow,
  requests,
  soundfile,
  tqdm,
  transformers,
  uvicorn,

  # tests
  psutil,
  pytestCheckHook,
  rich,
}:

buildPythonPackage rec {
  pname = "mlx-vlm";
  version = "0.3.9";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "Blaizzy";
    repo = "mlx-vlm";
    tag = "v${version}";
    hash = "sha256-L+llrfFo4C++JZ3GjpZi16wMZNXtKrYh3pxhZ5N1n/4=";
  };

  build-system = [
    setuptools
  ];

  pythonRelaxDeps = [
    "opencv-python"
  ];
  dependencies = [
    datasets
    fastapi
    mlx
    mlx-lm
    numpy
    opencv-python
    pillow
    requests
    soundfile
    tqdm
    transformers
    uvicorn
  ];

  pythonImportsCheck = [ "mlx_vlm" ];

  nativeCheckInputs = [
    psutil
    pytestCheckHook
    rich
  ];

  disabledTests = [
    # Fatal Python error: Aborted
    # mlx_vlm/models/multi_modality/vision.py", line 174 in __call__
    "test_multi_modality"

    # RuntimeError: [metal_kernel] No GPU back-end
    "test_glm4v"
    "test_glm4v_moe"
    "test_kimi_vl"
  ];

  disabledTestPaths = [
    # ImportError: cannot import name 'get_class_predicate' from 'mlx_vlm.utils'
    # This function is indeed not exposed by `mlx_vlm.utils`
    "mlx_vlm/tests/test_utils.py"

    # fixture 'model_path' not found
    "mlx_vlm/tests/test_smoke.py"
  ];

  meta = {
    description = "Inference and fine-tuning of Vision Language Models (VLMs) on your Mac using MLX";
    homepage = "https://github.com/Blaizzy/mlx-vlm";
    changelog = "https://github.com/Blaizzy/mlx-vlm/releases/tag/${src.tag}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ GaetanLepage ];
    platforms = [
      "aarch64-darwin"
    ];
  };
}