1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # dependencies
10 datasets,
11 fastapi,
12 mlx,
13 mlx-lm,
14 numpy,
15 opencv-python,
16 pillow,
17 requests,
18 scipy,
19 soundfile,
20 tqdm,
21 transformers,
22 uvicorn,
23
24 # tests
25 psutil,
26 pytestCheckHook,
27 rich,
28}:
29
30buildPythonPackage rec {
31 pname = "mlx-vlm";
32 version = "0.3.3";
33 pyproject = true;
34
35 src = fetchFromGitHub {
36 owner = "Blaizzy";
37 repo = "mlx-vlm";
38 tag = "v${version}";
39 hash = "sha256-KhppKqIJPmtjgSXSC3n5HTMm3fDUJaoYJEiGfQ5vGNQ=";
40 };
41
42 build-system = [
43 setuptools
44 ];
45
46 pythonRelaxDeps = [
47 "opencv-python"
48 ];
49 dependencies = [
50 datasets
51 fastapi
52 mlx
53 mlx-lm
54 numpy
55 opencv-python
56 pillow
57 requests
58 scipy
59 soundfile
60 tqdm
61 transformers
62 uvicorn
63 ];
64
65 pythonImportsCheck = [ "mlx_vlm" ];
66
67 nativeCheckInputs = [
68 psutil
69 pytestCheckHook
70 rich
71 ];
72
73 disabledTests = [
74 # Fatal Python error: Aborted
75 # mlx_vlm/models/multi_modality/vision.py", line 174 in __call__
76 "test_multi_modality"
77
78 # RuntimeError: [metal_kernel] No GPU back-end
79 "test_glm4v_moe"
80 "test_kimi_vl"
81 ];
82
83 disabledTestPaths = [
84 # ImportError: cannot import name 'get_class_predicate' from 'mlx_vlm.utils'
85 # This function is indeed not exposed by `mlx_vlm.utils`
86 "mlx_vlm/tests/test_utils.py"
87
88 # fixture 'model_path' not found
89 "mlx_vlm/tests/test_smoke.py"
90 ];
91
92 meta = {
93 description = "Inference and fine-tuning of Vision Language Models (VLMs) on your Mac using MLX";
94 homepage = "https://github.com/Blaizzy/mlx-vlm";
95 changelog = "https://github.com/Blaizzy/mlx-vlm/releases/tag/v${version}";
96 license = lib.licenses.mit;
97 maintainers = with lib.maintainers; [ GaetanLepage ];
98 };
99}