Metadata-Version: 2.4
Name: merlin-vlm
Version: 0.0.4
Summary: Merlin: A Vision Language Foundation Model for 3D Computed Tomography
Author: Stanford Machine Intelligence for Medical Imaging (MIMI)
Author-email: Louis Blankemeier <louis.blankemeier@stanford.edu>, Ashwin Kumar <akkumar@stanford.edu>
License: MIT License
        
        Copyright (c) 2025 Stanford MIMI Lab
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: homepage, https://github.com/StanfordMIMI/Merlin
Project-URL: repository, https://github.com/StanfordMIMI/Merlin
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Healthcare Industry
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26.4
Requires-Dist: torch>=2.1.2
Requires-Dist: monai>=1.3.0
Requires-Dist: huggingface_hub
Requires-Dist: transformers>=4.38.2
Requires-Dist: torchvision>=0.16.2
Requires-Dist: nibabel
Requires-Dist: nltk
Requires-Dist: pandas
Requires-Dist: rich
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: mdformat; extra == "dev"
Dynamic: license-file

# Merlin: Vision Language Foundation Model for 3D Computed Tomography

[![arXiv](https://img.shields.io/badge/arXiv-2406.06512-b31b1b.svg?style=for-the-badge)](https://arxiv.org/abs/2406.06512)    [![Hugging Face](https://huggingface.co/datasets/huggingface/badges/resolve/main/model-on-hf-md.svg)](https://huggingface.co/stanfordmimi/Merlin)    [![pypi](https://img.shields.io/pypi/v/merlin-vlm?style=for-the-badge)](https://pypi.org/project/merlin-vlm/)    [![Watch the Talk on YouTube](https://img.shields.io/badge/YouTube-Talk-red?style=for-the-badge&logo=youtube)](https://youtu.be/XWmCkbpXOUw?si=6GggZgj9U4kbLAKx)    ![License](https://img.shields.io/github/license/stanfordmimi/merlin?style=for-the-badge)

*Merlin is a 3D VLM for computed tomography that leverages both structured electronic health records (EHR) and unstructured radiology reports for pretraining.*

<!-- ![Key Graphic](documentation/assets/overview.png) -->

## ⚡️ Installation

To install Merlin, you can simply run:

```bash
pip install merlin-vlm
```

For an editable installation, use the following commands to clone and install this repository.

```bash
conda create -name merlin
conda activate merlin

git clone https://github.com/StanfordMIMI/Merlin.git
cd merlin
pip install -e .

# Alternatively, to install exact package versions as tested:
# uv sync
```

## 🚀 Inference with Merlin

To create a Merlin model with both image and text embeddings enabled, use the following:

```python
from merlin import Merlin

model = Merlin()
```

To initialize the model with **only image embeddings** active, use:

```python
from merlin import Merlin

model = Merlin(ImageEmbedding=True)
```

To initialize the model for **phenotype classification**, use:

```python
from merlin import Merlin

model = Merlin(PhenotypeCls=True)
```

#### For inference on a demo CT scan, please check out the [demo](documentation/demo.py)

#### For additional information, please read the [documentation](documentation/inference.md).

## 📂  Merlin Abdominal CT Dataset

We are excited to release the **Merlin Abdominal CT Dataset** to the community!

For details on accessing and using the dataset, please see the [download documentation](documentation/download.md)!

## 📎 Citation

If you find this repository useful for your work, please cite the cite the [original paper](https://arxiv.org/abs/2406.06512):

```bibtex
@article{blankemeier2024merlin,
  title={Merlin: A vision language foundation model for 3d computed tomography},
  author={Blankemeier, Louis and Cohen, Joseph Paul and Kumar, Ashwin and Van Veen, Dave and Gardezi, Syed Jamal Safdar and Paschali, Magdalini and Chen, Zhihong and Delbrouck, Jean-Benoit and Reis, Eduardo and Truyts, Cesar and others},
  journal={Research Square},
  pages={rs--3},
  year={2024}
}
```
