med-vlm-mlx 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of med-vlm-mlx might be problematic. Click here for more details.
- med_vlm_mlx-0.2.2/LICENSE +21 -0
- med_vlm_mlx-0.2.2/PKG-INFO +79 -0
- med_vlm_mlx-0.2.2/README.md +41 -0
- med_vlm_mlx-0.2.2/THIRD_PARTY_NOTICES.md +258 -0
- med_vlm_mlx-0.2.2/med_vlm_mlx.egg-info/PKG-INFO +79 -0
- med_vlm_mlx-0.2.2/med_vlm_mlx.egg-info/SOURCES.txt +101 -0
- med_vlm_mlx-0.2.2/med_vlm_mlx.egg-info/dependency_links.txt +1 -0
- med_vlm_mlx-0.2.2/med_vlm_mlx.egg-info/entry_points.txt +4 -0
- med_vlm_mlx-0.2.2/med_vlm_mlx.egg-info/requires.txt +18 -0
- med_vlm_mlx-0.2.2/med_vlm_mlx.egg-info/top_level.txt +1 -0
- med_vlm_mlx-0.2.2/mlx_vlm/__init__.py +42 -0
- med_vlm_mlx-0.2.2/mlx_vlm/__main__.py +21 -0
- med_vlm_mlx-0.2.2/mlx_vlm/_stream_cleanup.py +10 -0
- med_vlm_mlx-0.2.2/mlx_vlm/adapters.py +530 -0
- med_vlm_mlx-0.2.2/mlx_vlm/apc.py +5188 -0
- med_vlm_mlx-0.2.2/mlx_vlm/apc_adapters.py +802 -0
- med_vlm_mlx-0.2.2/mlx_vlm/apc_coordinator.py +417 -0
- med_vlm_mlx-0.2.2/mlx_vlm/apc_storage.py +96 -0
- med_vlm_mlx-0.2.2/mlx_vlm/apc_types.py +147 -0
- med_vlm_mlx-0.2.2/mlx_vlm/contracts.py +458 -0
- med_vlm_mlx-0.2.2/mlx_vlm/convert.py +551 -0
- med_vlm_mlx-0.2.2/mlx_vlm/fp8.py +153 -0
- med_vlm_mlx-0.2.2/mlx_vlm/generate/__init__.py +58 -0
- med_vlm_mlx-0.2.2/mlx_vlm/generate/__main__.py +4 -0
- med_vlm_mlx-0.2.2/mlx_vlm/generate/ar.py +3600 -0
- med_vlm_mlx-0.2.2/mlx_vlm/generate/cli.py +131 -0
- med_vlm_mlx-0.2.2/mlx_vlm/generate/common.py +372 -0
- med_vlm_mlx-0.2.2/mlx_vlm/generate/dispatch.py +813 -0
- med_vlm_mlx-0.2.2/mlx_vlm/generate/types.py +243 -0
- med_vlm_mlx-0.2.2/mlx_vlm/generate/video.py +175 -0
- med_vlm_mlx-0.2.2/mlx_vlm/kv_quant.py +188 -0
- med_vlm_mlx-0.2.2/mlx_vlm/metal.py +60 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/__init__.py +0 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/activations.py +51 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/attention.py +60 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/base.py +678 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/cache.py +3626 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/gemma3/__init__.py +11 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/gemma3/attention.py +144 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/gemma3/config.py +114 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/gemma3/gemma3.py +276 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/gemma3/language.py +472 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/gemma3/processing_gemma3.py +428 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/gemma3/vision.py +156 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/linear.py +88 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/mla.py +119 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/mlp.py +89 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/processing.py +71 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/protocols.py +136 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/quantized_verifier.py +2114 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/qwen2_5_vl/__init__.py +11 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/qwen2_5_vl/config.py +103 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/qwen2_5_vl/language.py +489 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/qwen2_5_vl/positions.py +169 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/qwen2_5_vl/processing_qwen2_5_vl.py +360 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/qwen2_5_vl/processing_vision.py +840 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/qwen2_5_vl/qwen2_5_vl.py +198 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/qwen2_5_vl/vision.py +566 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/rope_utils.py +1455 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/switch_layers.py +134 -0
- med_vlm_mlx-0.2.2/mlx_vlm/models/vision_features.py +62 -0
- med_vlm_mlx-0.2.2/mlx_vlm/prompt_utils.py +592 -0
- med_vlm_mlx-0.2.2/mlx_vlm/py.typed +0 -0
- med_vlm_mlx-0.2.2/mlx_vlm/quant/__init__.py +15 -0
- med_vlm_mlx-0.2.2/mlx_vlm/quant/awq.py +218 -0
- med_vlm_mlx-0.2.2/mlx_vlm/quant/calibration.py +163 -0
- med_vlm_mlx-0.2.2/mlx_vlm/quant_utils.py +276 -0
- med_vlm_mlx-0.2.2/mlx_vlm/quantization/__init__.py +1 -0
- med_vlm_mlx-0.2.2/mlx_vlm/quantization/one_bit.py +569 -0
- med_vlm_mlx-0.2.2/mlx_vlm/sample_utils.py +536 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/__init__.py +6 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/__main__.py +4 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/anthropic.py +1212 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/app.py +697 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/cli.py +93 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/compaction.py +793 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/generation.py +2074 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/model_discovery.py +140 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/openai.py +2318 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/payloads.py +27 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/request_normalization.py +431 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/responses_state.py +1077 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/runtime.py +69 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/runtime_config.py +549 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/schemas.py +957 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/services.py +95 -0
- med_vlm_mlx-0.2.2/mlx_vlm/server/state_types.py +123 -0
- med_vlm_mlx-0.2.2/mlx_vlm/structured.py +323 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tokenizer_utils.py +550 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tools/__init__.py +34 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tools/base.py +26 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tools/extractor.py +80 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tools/parsers/__init__.py +7 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tools/parsers/json_tools.py +20 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tools/policy.py +140 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tools/registry.py +129 -0
- med_vlm_mlx-0.2.2/mlx_vlm/tools/types.py +38 -0
- med_vlm_mlx-0.2.2/mlx_vlm/turboquant.py +4936 -0
- med_vlm_mlx-0.2.2/mlx_vlm/utils.py +2430 -0
- med_vlm_mlx-0.2.2/mlx_vlm/version.py +1 -0
- med_vlm_mlx-0.2.2/mlx_vlm/vision_cache.py +103 -0
- med_vlm_mlx-0.2.2/pyproject.toml +99 -0
- med_vlm_mlx-0.2.2/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2025 Prince Canuma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: med-vlm-mlx
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: MedGemma and Lingshu medical vision-language inference on Apple Silicon.
|
|
5
|
+
Author: Alfredo Sandoval
|
|
6
|
+
Author-email: Prince Canuma <prince.gdt@gmail.com>
|
|
7
|
+
License-Expression: MIT AND Apache-2.0
|
|
8
|
+
Project-URL: Repository, https://github.com/MedMLX/med-vlm-mlx
|
|
9
|
+
Project-URL: Upstream, https://github.com/Blaizzy/mlx-vlm
|
|
10
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Requires-Python: >=3.13
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
License-File: THIRD_PARTY_NOTICES.md
|
|
20
|
+
Requires-Dist: mlx==0.32.3
|
|
21
|
+
Requires-Dist: transformers==5.19.0
|
|
22
|
+
Requires-Dist: jinja2>=3.1.6
|
|
23
|
+
Requires-Dist: sentencepiece>=0.2.1
|
|
24
|
+
Requires-Dist: tqdm>=4.66.3
|
|
25
|
+
Requires-Dist: Pillow<14,>=13
|
|
26
|
+
Requires-Dist: requests>=2.33.0
|
|
27
|
+
Requires-Dist: llguidance>=1.7.0
|
|
28
|
+
Requires-Dist: opencv-python>=4.12.0.88
|
|
29
|
+
Requires-Dist: fastapi>=0.143.0
|
|
30
|
+
Requires-Dist: starlette>=1.3.1
|
|
31
|
+
Requires-Dist: uvicorn
|
|
32
|
+
Requires-Dist: numpy
|
|
33
|
+
Requires-Dist: cryptography>=50.0.2
|
|
34
|
+
Provides-Extra: medical
|
|
35
|
+
Requires-Dist: fsspec==2026.9.0; extra == "medical"
|
|
36
|
+
Requires-Dist: torch==2.14.1; extra == "medical"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# med-vlm-mlx
|
|
40
|
+
|
|
41
|
+
Run MedGemma 1.5 4B and Lingshu 7B locally on Apple Silicon. Includes Python, CLI and HTTP interfaces.
|
|
42
|
+
|
|
43
|
+
[Docs](https://github.com/MedMLX/med-vlm-mlx/blob/main/docs/usage.md) · [MedMLX](https://github.com/MedMLX)
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
*Chest radiograph → structured modality, body region and visible anatomy.*
|
|
48
|
+
|
|
49
|
+
| Input | Output |
|
|
50
|
+
| :--- | :--- |
|
|
51
|
+
| Image + text prompt | Generated text |
|
|
52
|
+
|
|
53
|
+
**Apple Silicon · Metal · Python 3.13** · [uv](https://docs.astral.sh/uv/)
|
|
54
|
+
|
|
55
|
+
Development setup requires mamba or conda and a maintained Node.js installation.
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uv venv --python 3.13
|
|
61
|
+
source .venv/bin/activate
|
|
62
|
+
uv pip install med-vlm-mlx
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Use a local MedGemma or Lingshu model directory:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python -m mlx_vlm.generate \
|
|
69
|
+
--model /path/to/model --image image.png \
|
|
70
|
+
--prompt 'Describe the image.' --max-tokens 128
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Uses the `mlx_vlm` namespace. Install in a separate environment from upstream `mlx-vlm`.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT, with Apache-2.0 adaptations. See [LICENSE](https://github.com/MedMLX/med-vlm-mlx/blob/main/LICENSE) and [third-party notices](https://github.com/MedMLX/med-vlm-mlx/blob/main/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.
|
|
78
|
+
|
|
79
|
+
For research and education. Outputs require human review.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# med-vlm-mlx
|
|
2
|
+
|
|
3
|
+
Run MedGemma 1.5 4B and Lingshu 7B locally on Apple Silicon. Includes Python, CLI and HTTP interfaces.
|
|
4
|
+
|
|
5
|
+
[Docs](https://github.com/MedMLX/med-vlm-mlx/blob/main/docs/usage.md) · [MedMLX](https://github.com/MedMLX)
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
*Chest radiograph → structured modality, body region and visible anatomy.*
|
|
10
|
+
|
|
11
|
+
| Input | Output |
|
|
12
|
+
| :--- | :--- |
|
|
13
|
+
| Image + text prompt | Generated text |
|
|
14
|
+
|
|
15
|
+
**Apple Silicon · Metal · Python 3.13** · [uv](https://docs.astral.sh/uv/)
|
|
16
|
+
|
|
17
|
+
Development setup requires mamba or conda and a maintained Node.js installation.
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv venv --python 3.13
|
|
23
|
+
source .venv/bin/activate
|
|
24
|
+
uv pip install med-vlm-mlx
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Use a local MedGemma or Lingshu model directory:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m mlx_vlm.generate \
|
|
31
|
+
--model /path/to/model --image image.png \
|
|
32
|
+
--prompt 'Describe the image.' --max-tokens 128
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Uses the `mlx_vlm` namespace. Install in a separate environment from upstream `mlx-vlm`.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT, with Apache-2.0 adaptations. See [LICENSE](https://github.com/MedMLX/med-vlm-mlx/blob/main/LICENSE) and [third-party notices](https://github.com/MedMLX/med-vlm-mlx/blob/main/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.
|
|
40
|
+
|
|
41
|
+
For research and education. Outputs require human review.
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The upstream MIT license and copyright notice are preserved in
|
|
4
|
+
[LICENSE](LICENSE). The source revision and fork attribution are recorded below.
|
|
5
|
+
|
|
6
|
+
## MLX-VLM sources
|
|
7
|
+
|
|
8
|
+
This repository derives from Blaizzy/mlx-vlm, MIT licensed, at commit
|
|
9
|
+
`c24454765c3177a385185c185b4957567c5fdf89` (upstream version 0.7.7).
|
|
10
|
+
The original license is retained and the upstream revision is recorded. This is
|
|
11
|
+
a maintained fork, not a claim of independent authorship of the upstream library.
|
|
12
|
+
|
|
13
|
+
MedMLX's changes address Gemma3/MedGemma attention and scaling, Qwen2.5-VL
|
|
14
|
+
multimodal feature integrity, persistent padding metadata, and reproducible
|
|
15
|
+
verification. Checkpoint ownership and terms remain with their publishers.
|
|
16
|
+
|
|
17
|
+
Human owner: Alfredo Sandoval.
|
|
18
|
+
|
|
19
|
+
## Native processor adaptations
|
|
20
|
+
|
|
21
|
+
The following modules identify adaptations of Hugging Face Transformers in their
|
|
22
|
+
source documentation:
|
|
23
|
+
|
|
24
|
+
- `mlx_vlm/models/gemma3/processing_gemma3.py`: Gemma3 text/image processing.
|
|
25
|
+
- `mlx_vlm/models/qwen2_5_vl/processing_qwen2_5_vl.py`: Qwen2.5-VL processing.
|
|
26
|
+
- `mlx_vlm/models/qwen2_5_vl/processing_vision.py`: Qwen3-VL image/video patch processing.
|
|
27
|
+
|
|
28
|
+
The upstream Transformers source is Apache-2.0 licensed. Its relevant notices
|
|
29
|
+
include Copyright 2018- The Hugging Face team; Copyright 2025 Google Inc. and the
|
|
30
|
+
HuggingFace Inc. team (Gemma3); and Copyright 2025 The Qwen Team and The HuggingFace
|
|
31
|
+
Inc. team (Qwen processors). The full upstream license is included below.
|
|
32
|
+
|
|
33
|
+
The source links below use v5.19.0, this project's pinned Transformers dependency,
|
|
34
|
+
to make those notices inspectable. They do not assert that this was the exact
|
|
35
|
+
historical adaptation revision.
|
|
36
|
+
|
|
37
|
+
- https://github.com/huggingface/transformers/blob/v5.19.0/src/transformers/models/gemma3/processing_gemma3.py
|
|
38
|
+
- https://github.com/huggingface/transformers/blob/v5.19.0/src/transformers/models/qwen2_5_vl/processing_qwen2_5_vl.py
|
|
39
|
+
- https://github.com/huggingface/transformers/blob/v5.19.0/src/transformers/models/qwen3_vl/processing_qwen3_vl.py
|
|
40
|
+
- https://github.com/huggingface/transformers/blob/v5.19.0/src/transformers/models/qwen3_vl/video_processing_qwen3_vl.py
|
|
41
|
+
|
|
42
|
+
Dependencies declared in [pyproject.toml](pyproject.toml) are installed separately
|
|
43
|
+
and retain their respective licenses.
|
|
44
|
+
|
|
45
|
+
## Hugging Face Transformers license (v5.19.0)
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
Copyright 2018- The Hugging Face team. All rights reserved.
|
|
49
|
+
|
|
50
|
+
Apache License
|
|
51
|
+
Version 2.0, January 2004
|
|
52
|
+
http://www.apache.org/licenses/
|
|
53
|
+
|
|
54
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
55
|
+
|
|
56
|
+
1. Definitions.
|
|
57
|
+
|
|
58
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
59
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
60
|
+
|
|
61
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
62
|
+
the copyright owner that is granting the License.
|
|
63
|
+
|
|
64
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
65
|
+
other entities that control, are controlled by, or are under common
|
|
66
|
+
control with that entity. For the purposes of this definition,
|
|
67
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
68
|
+
direction or management of such entity, whether by contract or
|
|
69
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
70
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
71
|
+
|
|
72
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
73
|
+
exercising permissions granted by this License.
|
|
74
|
+
|
|
75
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
76
|
+
including but not limited to software source code, documentation
|
|
77
|
+
source, and configuration files.
|
|
78
|
+
|
|
79
|
+
"Object" form shall mean any form resulting from mechanical
|
|
80
|
+
transformation or translation of a Source form, including but
|
|
81
|
+
not limited to compiled object code, generated documentation,
|
|
82
|
+
and conversions to other media types.
|
|
83
|
+
|
|
84
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
85
|
+
Object form, made available under the License, as indicated by a
|
|
86
|
+
copyright notice that is included in or attached to the work
|
|
87
|
+
(an example is provided in the Appendix below).
|
|
88
|
+
|
|
89
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
90
|
+
form, that is based on (or derived from) the Work and for which the
|
|
91
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
92
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
93
|
+
of this License, Derivative Works shall not include works that remain
|
|
94
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
95
|
+
the Work and Derivative Works thereof.
|
|
96
|
+
|
|
97
|
+
"Contribution" shall mean any work of authorship, including
|
|
98
|
+
the original version of the Work and any modifications or additions
|
|
99
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
100
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
101
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
102
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
103
|
+
means any form of electronic, verbal, or written communication sent
|
|
104
|
+
to the Licensor or its representatives, including but not limited to
|
|
105
|
+
communication on electronic mailing lists, source code control systems,
|
|
106
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
107
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
108
|
+
excluding communication that is conspicuously marked or otherwise
|
|
109
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
110
|
+
|
|
111
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
112
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
113
|
+
subsequently incorporated within the Work.
|
|
114
|
+
|
|
115
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
116
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
117
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
118
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
119
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
120
|
+
Work and such Derivative Works in Source or Object form.
|
|
121
|
+
|
|
122
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
123
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
124
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
125
|
+
(except as stated in this section) patent license to make, have made,
|
|
126
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
127
|
+
where such license applies only to those patent claims licensable
|
|
128
|
+
by such Contributor that are necessarily infringed by their
|
|
129
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
130
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
131
|
+
institute patent litigation against any entity (including a
|
|
132
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
133
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
134
|
+
or contributory patent infringement, then any patent licenses
|
|
135
|
+
granted to You under this License for that Work shall terminate
|
|
136
|
+
as of the date such litigation is filed.
|
|
137
|
+
|
|
138
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
139
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
140
|
+
modifications, and in Source or Object form, provided that You
|
|
141
|
+
meet the following conditions:
|
|
142
|
+
|
|
143
|
+
(a) You must give any other recipients of the Work or
|
|
144
|
+
Derivative Works a copy of this License; and
|
|
145
|
+
|
|
146
|
+
(b) You must cause any modified files to carry prominent notices
|
|
147
|
+
stating that You changed the files; and
|
|
148
|
+
|
|
149
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
150
|
+
that You distribute, all copyright, patent, trademark, and
|
|
151
|
+
attribution notices from the Source form of the Work,
|
|
152
|
+
excluding those notices that do not pertain to any part of
|
|
153
|
+
the Derivative Works; and
|
|
154
|
+
|
|
155
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
156
|
+
distribution, then any Derivative Works that You distribute must
|
|
157
|
+
include a readable copy of the attribution notices contained
|
|
158
|
+
within such NOTICE file, excluding those notices that do not
|
|
159
|
+
pertain to any part of the Derivative Works, in at least one
|
|
160
|
+
of the following places: within a NOTICE text file distributed
|
|
161
|
+
as part of the Derivative Works; within the Source form or
|
|
162
|
+
documentation, if provided along with the Derivative Works; or,
|
|
163
|
+
within a display generated by the Derivative Works, if and
|
|
164
|
+
wherever such third-party notices normally appear. The contents
|
|
165
|
+
of the NOTICE file are for informational purposes only and
|
|
166
|
+
do not modify the License. You may add Your own attribution
|
|
167
|
+
notices within Derivative Works that You distribute, alongside
|
|
168
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
169
|
+
that such additional attribution notices cannot be construed
|
|
170
|
+
as modifying the License.
|
|
171
|
+
|
|
172
|
+
You may add Your own copyright statement to Your modifications and
|
|
173
|
+
may provide additional or different license terms and conditions
|
|
174
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
175
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
176
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
177
|
+
the conditions stated in this License.
|
|
178
|
+
|
|
179
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
180
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
181
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
182
|
+
this License, without any additional terms or conditions.
|
|
183
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
184
|
+
the terms of any separate license agreement you may have executed
|
|
185
|
+
with Licensor regarding such Contributions.
|
|
186
|
+
|
|
187
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
188
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
189
|
+
except as required for reasonable and customary use in describing the
|
|
190
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
191
|
+
|
|
192
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
193
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
194
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
195
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
196
|
+
implied, including, without limitation, any warranties or conditions
|
|
197
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
198
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
199
|
+
appropriateness of using or redistributing the Work and assume any
|
|
200
|
+
risks associated with Your exercise of permissions under this License.
|
|
201
|
+
|
|
202
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
203
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
204
|
+
unless required by applicable law (such as deliberate and grossly
|
|
205
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
206
|
+
liable to You for damages, including any direct, indirect, special,
|
|
207
|
+
incidental, or consequential damages of any character arising as a
|
|
208
|
+
result of this License or out of the use or inability to use the
|
|
209
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
210
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
211
|
+
other commercial damages or losses), even if such Contributor
|
|
212
|
+
has been advised of the possibility of such damages.
|
|
213
|
+
|
|
214
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
215
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
216
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
217
|
+
or other liability obligations and/or rights consistent with this
|
|
218
|
+
License. However, in accepting such obligations, You may act only
|
|
219
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
220
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
221
|
+
defend, and hold each Contributor harmless for any liability
|
|
222
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
223
|
+
of your accepting any such warranty or additional liability.
|
|
224
|
+
|
|
225
|
+
END OF TERMS AND CONDITIONS
|
|
226
|
+
|
|
227
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
228
|
+
|
|
229
|
+
To apply the Apache License to your work, attach the following
|
|
230
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
231
|
+
replaced with your own identifying information. (Don't include
|
|
232
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
233
|
+
comment syntax for the file format. We also recommend that a
|
|
234
|
+
file or class name and description of purpose be included on the
|
|
235
|
+
same "printed page" as the copyright notice for easier
|
|
236
|
+
identification within third-party archives.
|
|
237
|
+
|
|
238
|
+
Copyright [yyyy] [name of copyright owner]
|
|
239
|
+
|
|
240
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
241
|
+
you may not use this file except in compliance with the License.
|
|
242
|
+
You may obtain a copy of the License at
|
|
243
|
+
|
|
244
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
245
|
+
|
|
246
|
+
Unless required by applicable law or agreed to in writing, software
|
|
247
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
248
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
249
|
+
See the License for the specific language governing permissions and
|
|
250
|
+
limitations under the License.
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Showcase image
|
|
255
|
+
|
|
256
|
+
The chest radiograph is by Mikael Häggström,
|
|
257
|
+
[Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Normal_posteroanterior_(PA)_chest_radiograph_(X-ray).jpg),
|
|
258
|
+
[CC0](https://creativecommons.org/publicdomain/zero/1.0/). The showcase adds model output.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: med-vlm-mlx
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: MedGemma and Lingshu medical vision-language inference on Apple Silicon.
|
|
5
|
+
Author: Alfredo Sandoval
|
|
6
|
+
Author-email: Prince Canuma <prince.gdt@gmail.com>
|
|
7
|
+
License-Expression: MIT AND Apache-2.0
|
|
8
|
+
Project-URL: Repository, https://github.com/MedMLX/med-vlm-mlx
|
|
9
|
+
Project-URL: Upstream, https://github.com/Blaizzy/mlx-vlm
|
|
10
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Requires-Python: >=3.13
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
License-File: THIRD_PARTY_NOTICES.md
|
|
20
|
+
Requires-Dist: mlx==0.32.3
|
|
21
|
+
Requires-Dist: transformers==5.19.0
|
|
22
|
+
Requires-Dist: jinja2>=3.1.6
|
|
23
|
+
Requires-Dist: sentencepiece>=0.2.1
|
|
24
|
+
Requires-Dist: tqdm>=4.66.3
|
|
25
|
+
Requires-Dist: Pillow<14,>=13
|
|
26
|
+
Requires-Dist: requests>=2.33.0
|
|
27
|
+
Requires-Dist: llguidance>=1.7.0
|
|
28
|
+
Requires-Dist: opencv-python>=4.12.0.88
|
|
29
|
+
Requires-Dist: fastapi>=0.143.0
|
|
30
|
+
Requires-Dist: starlette>=1.3.1
|
|
31
|
+
Requires-Dist: uvicorn
|
|
32
|
+
Requires-Dist: numpy
|
|
33
|
+
Requires-Dist: cryptography>=50.0.2
|
|
34
|
+
Provides-Extra: medical
|
|
35
|
+
Requires-Dist: fsspec==2026.9.0; extra == "medical"
|
|
36
|
+
Requires-Dist: torch==2.14.1; extra == "medical"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# med-vlm-mlx
|
|
40
|
+
|
|
41
|
+
Run MedGemma 1.5 4B and Lingshu 7B locally on Apple Silicon. Includes Python, CLI and HTTP interfaces.
|
|
42
|
+
|
|
43
|
+
[Docs](https://github.com/MedMLX/med-vlm-mlx/blob/main/docs/usage.md) · [MedMLX](https://github.com/MedMLX)
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
*Chest radiograph → structured modality, body region and visible anatomy.*
|
|
48
|
+
|
|
49
|
+
| Input | Output |
|
|
50
|
+
| :--- | :--- |
|
|
51
|
+
| Image + text prompt | Generated text |
|
|
52
|
+
|
|
53
|
+
**Apple Silicon · Metal · Python 3.13** · [uv](https://docs.astral.sh/uv/)
|
|
54
|
+
|
|
55
|
+
Development setup requires mamba or conda and a maintained Node.js installation.
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uv venv --python 3.13
|
|
61
|
+
source .venv/bin/activate
|
|
62
|
+
uv pip install med-vlm-mlx
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Use a local MedGemma or Lingshu model directory:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python -m mlx_vlm.generate \
|
|
69
|
+
--model /path/to/model --image image.png \
|
|
70
|
+
--prompt 'Describe the image.' --max-tokens 128
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Uses the `mlx_vlm` namespace. Install in a separate environment from upstream `mlx-vlm`.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT, with Apache-2.0 adaptations. See [LICENSE](https://github.com/MedMLX/med-vlm-mlx/blob/main/LICENSE) and [third-party notices](https://github.com/MedMLX/med-vlm-mlx/blob/main/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.
|
|
78
|
+
|
|
79
|
+
For research and education. Outputs require human review.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
THIRD_PARTY_NOTICES.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
med_vlm_mlx.egg-info/PKG-INFO
|
|
6
|
+
med_vlm_mlx.egg-info/SOURCES.txt
|
|
7
|
+
med_vlm_mlx.egg-info/dependency_links.txt
|
|
8
|
+
med_vlm_mlx.egg-info/entry_points.txt
|
|
9
|
+
med_vlm_mlx.egg-info/requires.txt
|
|
10
|
+
med_vlm_mlx.egg-info/top_level.txt
|
|
11
|
+
mlx_vlm/__init__.py
|
|
12
|
+
mlx_vlm/__main__.py
|
|
13
|
+
mlx_vlm/_stream_cleanup.py
|
|
14
|
+
mlx_vlm/adapters.py
|
|
15
|
+
mlx_vlm/apc.py
|
|
16
|
+
mlx_vlm/apc_adapters.py
|
|
17
|
+
mlx_vlm/apc_coordinator.py
|
|
18
|
+
mlx_vlm/apc_storage.py
|
|
19
|
+
mlx_vlm/apc_types.py
|
|
20
|
+
mlx_vlm/contracts.py
|
|
21
|
+
mlx_vlm/convert.py
|
|
22
|
+
mlx_vlm/fp8.py
|
|
23
|
+
mlx_vlm/kv_quant.py
|
|
24
|
+
mlx_vlm/metal.py
|
|
25
|
+
mlx_vlm/prompt_utils.py
|
|
26
|
+
mlx_vlm/py.typed
|
|
27
|
+
mlx_vlm/quant_utils.py
|
|
28
|
+
mlx_vlm/sample_utils.py
|
|
29
|
+
mlx_vlm/structured.py
|
|
30
|
+
mlx_vlm/tokenizer_utils.py
|
|
31
|
+
mlx_vlm/turboquant.py
|
|
32
|
+
mlx_vlm/utils.py
|
|
33
|
+
mlx_vlm/version.py
|
|
34
|
+
mlx_vlm/vision_cache.py
|
|
35
|
+
mlx_vlm/generate/__init__.py
|
|
36
|
+
mlx_vlm/generate/__main__.py
|
|
37
|
+
mlx_vlm/generate/ar.py
|
|
38
|
+
mlx_vlm/generate/cli.py
|
|
39
|
+
mlx_vlm/generate/common.py
|
|
40
|
+
mlx_vlm/generate/dispatch.py
|
|
41
|
+
mlx_vlm/generate/types.py
|
|
42
|
+
mlx_vlm/generate/video.py
|
|
43
|
+
mlx_vlm/models/__init__.py
|
|
44
|
+
mlx_vlm/models/activations.py
|
|
45
|
+
mlx_vlm/models/attention.py
|
|
46
|
+
mlx_vlm/models/base.py
|
|
47
|
+
mlx_vlm/models/cache.py
|
|
48
|
+
mlx_vlm/models/linear.py
|
|
49
|
+
mlx_vlm/models/mla.py
|
|
50
|
+
mlx_vlm/models/mlp.py
|
|
51
|
+
mlx_vlm/models/processing.py
|
|
52
|
+
mlx_vlm/models/protocols.py
|
|
53
|
+
mlx_vlm/models/quantized_verifier.py
|
|
54
|
+
mlx_vlm/models/rope_utils.py
|
|
55
|
+
mlx_vlm/models/switch_layers.py
|
|
56
|
+
mlx_vlm/models/vision_features.py
|
|
57
|
+
mlx_vlm/models/gemma3/__init__.py
|
|
58
|
+
mlx_vlm/models/gemma3/attention.py
|
|
59
|
+
mlx_vlm/models/gemma3/config.py
|
|
60
|
+
mlx_vlm/models/gemma3/gemma3.py
|
|
61
|
+
mlx_vlm/models/gemma3/language.py
|
|
62
|
+
mlx_vlm/models/gemma3/processing_gemma3.py
|
|
63
|
+
mlx_vlm/models/gemma3/vision.py
|
|
64
|
+
mlx_vlm/models/qwen2_5_vl/__init__.py
|
|
65
|
+
mlx_vlm/models/qwen2_5_vl/config.py
|
|
66
|
+
mlx_vlm/models/qwen2_5_vl/language.py
|
|
67
|
+
mlx_vlm/models/qwen2_5_vl/positions.py
|
|
68
|
+
mlx_vlm/models/qwen2_5_vl/processing_qwen2_5_vl.py
|
|
69
|
+
mlx_vlm/models/qwen2_5_vl/processing_vision.py
|
|
70
|
+
mlx_vlm/models/qwen2_5_vl/qwen2_5_vl.py
|
|
71
|
+
mlx_vlm/models/qwen2_5_vl/vision.py
|
|
72
|
+
mlx_vlm/quant/__init__.py
|
|
73
|
+
mlx_vlm/quant/awq.py
|
|
74
|
+
mlx_vlm/quant/calibration.py
|
|
75
|
+
mlx_vlm/quantization/__init__.py
|
|
76
|
+
mlx_vlm/quantization/one_bit.py
|
|
77
|
+
mlx_vlm/server/__init__.py
|
|
78
|
+
mlx_vlm/server/__main__.py
|
|
79
|
+
mlx_vlm/server/anthropic.py
|
|
80
|
+
mlx_vlm/server/app.py
|
|
81
|
+
mlx_vlm/server/cli.py
|
|
82
|
+
mlx_vlm/server/compaction.py
|
|
83
|
+
mlx_vlm/server/generation.py
|
|
84
|
+
mlx_vlm/server/model_discovery.py
|
|
85
|
+
mlx_vlm/server/openai.py
|
|
86
|
+
mlx_vlm/server/payloads.py
|
|
87
|
+
mlx_vlm/server/request_normalization.py
|
|
88
|
+
mlx_vlm/server/responses_state.py
|
|
89
|
+
mlx_vlm/server/runtime.py
|
|
90
|
+
mlx_vlm/server/runtime_config.py
|
|
91
|
+
mlx_vlm/server/schemas.py
|
|
92
|
+
mlx_vlm/server/services.py
|
|
93
|
+
mlx_vlm/server/state_types.py
|
|
94
|
+
mlx_vlm/tools/__init__.py
|
|
95
|
+
mlx_vlm/tools/base.py
|
|
96
|
+
mlx_vlm/tools/extractor.py
|
|
97
|
+
mlx_vlm/tools/policy.py
|
|
98
|
+
mlx_vlm/tools/registry.py
|
|
99
|
+
mlx_vlm/tools/types.py
|
|
100
|
+
mlx_vlm/tools/parsers/__init__.py
|
|
101
|
+
mlx_vlm/tools/parsers/json_tools.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
mlx==0.32.3
|
|
2
|
+
transformers==5.19.0
|
|
3
|
+
jinja2>=3.1.6
|
|
4
|
+
sentencepiece>=0.2.1
|
|
5
|
+
tqdm>=4.66.3
|
|
6
|
+
Pillow<14,>=13
|
|
7
|
+
requests>=2.33.0
|
|
8
|
+
llguidance>=1.7.0
|
|
9
|
+
opencv-python>=4.12.0.88
|
|
10
|
+
fastapi>=0.143.0
|
|
11
|
+
starlette>=1.3.1
|
|
12
|
+
uvicorn
|
|
13
|
+
numpy
|
|
14
|
+
cryptography>=50.0.2
|
|
15
|
+
|
|
16
|
+
[medical]
|
|
17
|
+
fsspec==2026.9.0
|
|
18
|
+
torch==2.14.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mlx_vlm
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import atexit
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "1"
|
|
5
|
+
os.environ["TRANSFORMERS_VERBOSITY"] = "error"
|
|
6
|
+
|
|
7
|
+
from mlx_vlm._stream_cleanup import clear_mlx_streams
|
|
8
|
+
from mlx_vlm.convert import convert
|
|
9
|
+
from mlx_vlm.generate import (
|
|
10
|
+
BatchResponse,
|
|
11
|
+
BatchStats,
|
|
12
|
+
GenerationResult,
|
|
13
|
+
PromptCacheState,
|
|
14
|
+
batch_generate,
|
|
15
|
+
generate,
|
|
16
|
+
stream_generate,
|
|
17
|
+
)
|
|
18
|
+
from mlx_vlm.prompt_utils import apply_chat_template, get_message_json
|
|
19
|
+
from mlx_vlm.utils import load, prepare_inputs, process_image
|
|
20
|
+
from mlx_vlm.version import __version__
|
|
21
|
+
from mlx_vlm.vision_cache import VisionFeatureCache
|
|
22
|
+
|
|
23
|
+
# MLX streams are thread-local and must be released before interpreter teardown.
|
|
24
|
+
atexit.register(clear_mlx_streams)
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"BatchResponse",
|
|
28
|
+
"BatchStats",
|
|
29
|
+
"GenerationResult",
|
|
30
|
+
"PromptCacheState",
|
|
31
|
+
"VisionFeatureCache",
|
|
32
|
+
"__version__",
|
|
33
|
+
"apply_chat_template",
|
|
34
|
+
"batch_generate",
|
|
35
|
+
"convert",
|
|
36
|
+
"generate",
|
|
37
|
+
"get_message_json",
|
|
38
|
+
"load",
|
|
39
|
+
"prepare_inputs",
|
|
40
|
+
"process_image",
|
|
41
|
+
"stream_generate",
|
|
42
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Command entry points for medical inference and checkpoint conversion."""
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main() -> None:
|
|
8
|
+
"""Dispatch only maintained medical runtime commands."""
|
|
9
|
+
commands = ("generate", "convert", "server")
|
|
10
|
+
if len(sys.argv) < 2 or sys.argv[1] in {"-h", "--help"}:
|
|
11
|
+
print("Usage: python -m mlx_vlm {generate,convert,server} [options]")
|
|
12
|
+
return
|
|
13
|
+
command = sys.argv.pop(1)
|
|
14
|
+
if command not in commands:
|
|
15
|
+
raise ValueError(f"Unsupported command {command!r}; choose from {commands}")
|
|
16
|
+
module = importlib.import_module(f"mlx_vlm.{command}")
|
|
17
|
+
module.main()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if __name__ == "__main__":
|
|
21
|
+
main()
|