模型简介
模型特点
模型能力
使用案例
🚀 TITAN-preview模型介绍
TITAN-preview 是一个基于Transformer的多模态全切片基础模型,通过视觉自监督学习和视觉 - 语言对齐进行预训练。它利用了大量的全切片图像和病理报告,在多种下游任务中取得了先进的性能。本模型仅用于非商业的学术研究目的。
🚀 快速开始
模型访问
要访问该模型,你需要同意使用条款,并且Hugging Face账户的主邮箱必须与你的机构邮箱一致。如果主邮箱是个人邮箱(如 @gmail/@hotmail/@qq),请求将被拒绝。你可以通过以下步骤解决:
- 将你的官方机构邮箱添加到Hugging Face账户,并确认邮箱地址以进行验证。
- 将机构邮箱设置为Hugging Face账户的主邮箱。
若提交的表单存在其他错误,如全名包含缩写、所属机构未完整拼写、描述的研究用途不充分或邮箱域名未被认可,访问请求也会被拒绝。
模型使用
环境要求
torch==2.0.1
timm==1.0.3
einops==0.6.1
einops-exts==0.0.4
transformers==4.46.0
加载模型
from huggingface_hub import login
from transformers import AutoModel
login() # 使用你的用户访问令牌登录,令牌可在 https://huggingface.co/settings/tokens 找到
titan = AutoModel.from_pretrained('MahmoodLab/TITAN', trust_remote_code=True)
conch, eval_transform = titan.return_conch()
幻灯片级特征提取
import h5py
from transformers import AutoModel
# 加载模型
titan = AutoModel.from_pretrained('MahmoodLab/TITAN', trust_remote_code=True)
# 加载CONCH v1.5演示特征
h5_path = 'TCGA_demo_features/TCGA-RM-A68W-01Z-00-DX1.4E62E4F4-415C-46EB-A6C8-45BA14E82708.h5'
with h5py.File(h5_path, 'r') as file:
features = torch.from_numpy(file['features'][:])
coords = torch.from_numpy(file['coords'][:])
patch_size_lv0 = file['coords'].attrs['patch_size_level0']
# 提取幻灯片嵌入
with torch.autocast('cuda', torch.float16), torch.inference_mode():
slide_embedding = model.encode_slide_from_patch_features(features, coords, patch_size_lv0)
这些预提取的特征可用于幻灯片级分类(通过线性探测)、检索(通过l2距离)和其他机器学习场景,无需进行特定任务的微调。
我们还在 TCGA_TITAN_features.pkl
中发布了所有TCGA TITAN-preview特征。更多详细的线性探测和零样本评估可在我们的 GitHub 上查看。
✨ 主要特性
- 多模态基础模型:TITAN(基于Transformer的病理图像和文本对齐网络)是一个多模态全切片基础模型,通过视觉自监督学习和视觉 - 语言对齐进行预训练。
- 丰富的数据利用:利用了来自马萨诸塞州综合医院布莱根妇女医院的335,645张全切片图像(WSIs),以及超过182,000份病理报告和由 PathChat 生成的423,000多个合成标题。
- 先进的性能:TITAN的幻灯片嵌入在多种下游任务中实现了最先进的性能,包括线性探测、少样本和零样本分类、罕见癌症检索、跨模态检索和病理报告生成。
📦 安装指南
模型使用前需要安装以下依赖:
torch==2.0.1
timm==1.0.3
einops==0.6.1
einops-exts==0.0.4
transformers==4.46.0
💻 使用示例
基础用法
from huggingface_hub import login
from transformers import AutoModel
login() # 使用你的用户访问令牌登录,令牌可在 https://huggingface.co/settings/tokens 找到
titan = AutoModel.from_pretrained('MahmoodLab/TITAN', trust_remote_code=True)
conch, eval_transform = titan.return_conch()
高级用法
import h5py
from transformers import AutoModel
# 加载模型
titan = AutoModel.from_pretrained('MahmoodLab/TITAN', trust_remote_code=True)
# 加载CONCH v1.5演示特征
h5_path = 'TCGA_demo_features/TCGA-RM-A68W-01Z-00-DX1.4E62E4F4-415C-46EB-A6C8-45BA14E82708.h5'
with h5py.File(h5_path, 'r') as file:
features = torch.from_numpy(file['features'][:])
coords = torch.from_numpy(file['coords'][:])
patch_size_lv0 = file['coords'].attrs['patch_size_level0']
# 提取幻灯片嵌入
with torch.autocast('cuda', torch.float16), torch.inference_mode():
slide_embedding = model.encode_slide_from_patch_features(features, coords, patch_size_lv0)
📚 详细文档
模型描述
属性 | 详情 |
---|---|
模型类型 | 预训练的视觉 - 语言编码器 |
训练数据 | Mass-340K,来自私人组织学收藏(BWH / MGH),以及公共GTEx联盟的切片 |
仓库地址 | https://github.com/mahmoodlab/TITAN |
预印本 | https://arxiv.org/abs/2411.19666 |
许可证 | CC-BY-NC-ND-4.0 |
模型使用说明
TITAN-preview是一个在CONCH v1.5补丁特征上训练的视觉 - 语言模型,补丁大小为512x512像素,放大倍数为20x。
注意事项
⚠️ 重要提示
本模型和相关代码根据CC-BY-NC-ND 4.0许可证发布,仅可用于非商业的学术研究目的,并需进行适当的引用。任何商业使用、销售或对TITAN模型及其衍生产品(包括在TITAN模型输出上训练的模型或由TITAN模型创建的数据集)的其他货币化行为均被禁止,需要事先获得批准。下载模型需要事先在Hugging Face上注册并同意使用条款。下载此模型即表示你同意不分发、发布或复制该模型的副本。如果你所在组织的其他用户希望使用TITAN模型,他们必须作为个人用户注册并同意遵守使用条款。用户不得尝试重新识别用于开发基础模型的去标识化数据。如果你是商业实体,请联系相应的作者。
🔧 技术细节
TITAN利用视觉自监督学习和视觉 - 语言对齐进行预训练。它从CONCH v1.5补丁特征构建特征网格,使用补丁的坐标和距离。补丁坐标始终保存在幻灯片的0级放大倍数下,TITAN采用 patch_size_lv0
表示在0级放大倍数下两个相邻补丁之间的距离。如果幻灯片为40x,则为1024;如果为20x,则为512。
📄 许可证
本模型和相关代码根据CC-BY-NC-ND 4.0许可证发布。具体使用限制请参考上文的重要提示。
📞 联系信息
如有任何额外问题或建议,请联系以下人员:
- Faisal Mahmood (
faisalmahmood@bwh.harvard.edu
) - Tong Ding (
tong_ding@g.harvard.edu
) - Sophia J. Wagner (
sophia.wagner@helmholtz-munich.de
) - Andrew H. Song (
asong@bwh.harvard.edu
) - Richard J. Chen (
richardchen@g.harvard.edu
)
🙏 致谢
本项目基于许多优秀的代码库构建,如 ViT、iBOT、OpenClip、LGSSL 和 Timm(ViT模型实现)。感谢这些作者和开发者的贡献。
📑 引用信息
如果你在研究中发现我们的工作有用,请考虑引用我们的论文:
Ding, T.*, Wagner S.J.*, Song, A.H.*, Chen, R.J.* 等。Multimodal Whole Slide Foundation Model for Pathology, Arxiv, 2024
@misc{ding2024multimodalslidefoundationmodel,
title={Multimodal Whole Slide Foundation Model for Pathology},
author={Tong Ding and Sophia J. Wagner and Andrew H. Song and Richard J. Chen and Ming Y. Lu and Andrew Zhang and Anurag J. Vaidya and Guillaume Jaume and Muhammad Shaban and Ahrong Kim and Drew F. K. Williamson and Bowen Chen and Cristina Almagro-Perez and Paul Doucet and Sharifa Sahai and Chengkuan Chen and Daisuke Komura and Akihiro Kawabe and Shumpei Ishikawa and Georg Gerber and Tingying Peng and Long Phi Le and Faisal Mahmood},
year={2024},
eprint={2411.19666},
archivePrefix={arXiv},
primaryClass={eess.IV},
url={https://arxiv.org/abs/2411.19666},
}









