liubw commited on
Commit
5363475
·
verified ·
1 Parent(s): fb2bb5f

Upload CONCH model files

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. README.md +162 -0
  3. hf.jpg +3 -0
  4. meta.yaml +2 -0
  5. pytorch_model.bin +3 -0
  6. requesting_access.png +0 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ hf.jpg filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-nd-4.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - pathology
7
+ - vision
8
+ - vision language
9
+ - pytorch
10
+ extra_gated_prompt: >-
11
+ This model and associated code are released under the CC-BY-NC-ND 4.0 license
12
+ and may only be used for non-commercial, academic research purposes with
13
+ proper attribution. Any commercial use, sale, or other monetization of the
14
+ CONCH model and its derivatives, which include models trained on outputs from
15
+ the CONCH model or datasets created from the CONCH model, is prohibited and
16
+ requires prior approval. Downloading the model requires prior registration on
17
+ Hugging Face and agreeing to the terms of use. By downloading this model, you
18
+ agree not to distribute, publish or reproduce a copy of the model. If another
19
+ user within your organization wishes to use the CONCH model, they must
20
+ register as an individual user and agree to comply with the terms of use.
21
+ Users may not attempt to re-identify the deidentified data used to develop the
22
+ underlying model. If you are a commercial entity, please contact the
23
+ corresponding author. Please note that the primary email used to sign up for
24
+ your Hugging Face account must match your institutional email to received
25
+ approval. Further details included in the model card.
26
+ extra_gated_fields:
27
+ Full name: text
28
+ Affiliation: text
29
+ Type of affiliation:
30
+ type: select
31
+ options:
32
+ - Academia
33
+ - Industry
34
+ - label: Other
35
+ value: other
36
+ Official email (must match primary email in your Hugging Face account): text
37
+ Please explain your intended research use: text
38
+ I agree to all terms outlined above: checkbox
39
+ I agree to use this model for non-commercial, academic purposes only: checkbox
40
+ I agree not to distribute the model, if another user within your organization wishes to use the CONCH model, they must register as an individual user: checkbox
41
+ library_name: timm
42
+ pipeline_tag: image-feature-extraction
43
+ ---
44
+
45
+ # Model Card for CONCH
46
+ \[[Journal Link](https://www.nature.com/articles/s41591-024-02856-4)\] | \[[Open Access Read Link](https://rdcu.be/dBMf6)\] | [\[Github Repo](https://github.com/mahmoodlab/CONCH)\] | \[[Cite](#how-to-cite)\]
47
+
48
+ ## What is CONCH?
49
+ CONCH (CONtrastive learning from Captions for Histopathology) is a vision language foundation model for histopathology, pretrained on currently the largest histopathology-specific vision-language dataset of 1.17M image caption pairs. Compare to other vision language foundation models, it demonstrates state-of-the-art performance across 14 tasks in computational pathology ranging from image classification, text-to-image, and image-to-text retrieval, captioning, and tissue segmentation.
50
+ - _**Why use CONCH?**_: Compared to popular self-supervised encoders for computational pathology that were pretrained only on H&E images, CONCH may produce more performant representations for non-H&E stained images such as IHCs and special stains, and can be used for a wide range of downstream tasks involving either or both histopathology images and text. CONCH also did not use large public histology slide collections such as TCGA, PAIP, GTEX, etc. for pretraining, which are routinely used in benchmark development in computational pathology. Therefore, we make CONCH available for the research community in building and evaluating pathology AI models with minimal risk of data contamination on public benchmarks or private histopathology slide collections.
51
+
52
+ ![image/png](hf.jpg)
53
+
54
+ ## Requesting Access
55
+
56
+ As mentioned in the gated prompt, you must agree to the outlined terms of use, _**with the primary email for your HuggingFace account matching your institutional email**_. If your primary email is a personal email (@gmail/@hotmail/@qq) **your request will be denied**. To fix this, you can: (1) add your official institutional email to your HF account, and confirm your email address to verify, and (2) set your institutional email as your primary email in your HF account. Other reasons for your request access being denied include other mistakes in the form submitted, for example: full name includes abbreviations, affiliation is not spelled out, the described research use is not sufficient, or email domain address not recognized.
57
+
58
+ ## License and Terms of Use
59
+
60
+ This model and associated code are released under the CC-BY-NC-ND 4.0 license and may only be used for non-commercial, academic research purposes with proper attribution. Any commercial use, sale, or other monetization of the CONCH model and its derivatives, which include models trained on outputs from the CONCH model or datasets created from the CONCH model, is prohibited and requires prior approval. Downloading the model requires prior registration on Hugging Face and agreeing to the terms of use. By downloading this model, you agree not to distribute, publish or reproduce a copy of the model. If another user within your organization wishes to use the CONCH model, they must register as an individual user and agree to comply with the terms of use. Users may not attempt to re-identify the deidentified data used to develop the underlying model. If you are a commercial entity, please contact the corresponding author.
61
+
62
+ ![](requesting_access.png)
63
+
64
+ ## Model Details
65
+
66
+ ### Model Description
67
+
68
+ - **Developed by:** Mahmood Lab AI for Pathology Lab @ Harvard/BWH
69
+ - **Model type:** Pretrained vision-language encoders (vision encoder: ViT-B/16, 90M params; text encoder: L12-E768-H12, 110M params)
70
+ - **Pretraining dataset:** 1.17 million histopathology image-caption pairs
71
+ - **Repository:** https://github.com/mahmoodlab/CONCH
72
+ - **Paper:** https://www.nature.com/articles/s41591-024-02856-4
73
+ - **License:** CC-BY-NC-ND-4.0
74
+
75
+ Note: while the original CONCH model arechitecture also includes a multimodal decoder trained with the captioning loss of CoCa, as additional precaution to ensure that no proprietary data or Protected Health Information (PHI) is leaked untentionally, we have removed the weights for the decoder from the publicly released CONCH weights.
76
+ The weights for the text encoder and the vision encoder are intact and therefore the results on all key tasks presented in the paper such as image classification and image-text retrieval are not affected.
77
+ The ability of CONCH to serve as a general purpose encoder for both histopathology images and pathology-related text also remains unaffected.
78
+
79
+ ### Usage
80
+ Install the conch repository using pip:
81
+ ```shell
82
+ pip install git+https://github.com/Mahmoodlab/CONCH.git
83
+ ```
84
+
85
+ After succesfully requesting access to the weights:
86
+ ```python
87
+ from conch.open_clip_custom import create_model_from_pretrained
88
+ model, preprocess = create_model_from_pretrained('conch_ViT-B-16', "hf_hub:MahmoodLab/conch", hf_auth_token="<your_user_access_token>")
89
+ ```
90
+
91
+ Note you may need to supply your huggingface user access token via `hf_auth_token=<your_token>` to `create_model_from_pretrained` for authentification. See the [HF documentation](https://huggingface.co/docs/hub/security-tokens) for more details.
92
+
93
+ Alternatively, you can download the checkpoint mannually, and load the model as follows:
94
+ ```python
95
+ model, preprocess = create_model_from_pretrained('conch_ViT-B-16', "path/to/conch/pytorch_model.bin")
96
+ ```
97
+
98
+ You can then use the model to encode images as follows:
99
+ ```python
100
+ import torch
101
+ from PIL import Image
102
+ image = Image.open("path/to/image.jpg")
103
+ image = preprocess(image).unsqueeze(0)
104
+ with torch.inference_mode():
105
+ image_embs = model.encode_image(image, proj_contrast=False, normalize=False)
106
+ ```
107
+
108
+ This will give you the image embeddings before the projection head and normalization, suitable for linear probe or working with WSIs under the multiple-instance learning framework.
109
+
110
+ For image-text retrieval tasks, you should use the normalized and projected embeddings as follows:
111
+ ```python
112
+ with torch.inference_mode():
113
+ image_embs = model.encode_image(image, proj_contrast=True, normalize=True)
114
+ text_embedings = model.encode_text(tokenized_prompts)
115
+ sim_scores = (image_embedings @ text_embedings.T).squeeze(0)
116
+ ```
117
+
118
+ For concrete examples on using the model for various tasks, please visit the [github](https://github.com/mahmoodlab/CONCH) repository.
119
+
120
+ ### Use Cases
121
+
122
+ The model is primarily intended for researchers and can be used to perform tasks in computational pathology such as:
123
+ - Zero-shot ROI classification
124
+ - Zero-shot ROI image to text and text to image retrieval
125
+ - Zero-shot WSI classification using MI-Zero
126
+ - ROI classification using linear probing / knn probing / end-to-end fine-tuning
127
+ - WSI classification using with multiple instance learning (MIL)
128
+
129
+ ## Training Details
130
+
131
+ - **Training data:** 1.17 million human histopathology image-caption pairs from publicly available Pubmed Central Open Access (PMC-OA) and internally curated sources. Images include H&E, IHC, and special stains.
132
+ - **Training regime:** fp16 automatic mixed-precision
133
+ - **Training objective:** CoCa (image-text contrastive loss + captioning loss)
134
+ - **Hardware:** 8 x Nvidia A100
135
+ - **Hours used:** ~21.5 hours
136
+ - **Software:** PyTorch 2.0, CUDA 11.7
137
+
138
+ Note: The vision encoder and the text encoder / decoder are first pretrained separately and then fine-tuned together using the CoCa loss. See the paper for more details.
139
+
140
+ ## Contact
141
+
142
+ For any additional questions or comments, contact Faisal Mahmood (`faisalmahmood@bwh.harvard.edu`),
143
+ Ming Y. Lu (`mlu16@bwh.harvard.edu`),
144
+ or Bowen Chen (`bchen18@bwh.harvard.edu`).
145
+
146
+ ## Acknowledgements
147
+
148
+ The project was built on top of amazing repositories such as [openclip](https://github.com/mlfoundations/open_clip) (used for model training), [timm](https://github.com/huggingface/pytorch-image-models/) (ViT model implementation) and [huggingface transformers](https://github.com/huggingface/transformers) (tokenization). We thank the authors and developers for their contribution.
149
+
150
+ ## How to Cite
151
+
152
+ ```
153
+ @article{lu2024avisionlanguage,
154
+ title={A visual-language foundation model for computational pathology},
155
+ author={Lu, Ming Y and Chen, Bowen and Williamson, Drew FK and Chen, Richard J and Liang, Ivy and Ding, Tong and Jaume, Guillaume and Odintsov, Igor and Le, Long Phi and Gerber, Georg and others},
156
+ journal={Nature Medicine},
157
+ pages={863–874},
158
+ volume={30},
159
+ year={2024},
160
+ publisher={Nature Publishing Group}
161
+ }
162
+ ```
hf.jpg ADDED

Git LFS Details

  • SHA256: 5c78f250b21601d70ca12204e7048ae6111b2ae387f002cb6c24cf67ddb0614a
  • Pointer size: 131 Bytes
  • Size of remote file: 643 kB
meta.yaml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ model_name: CONCH
2
+ model_version: 1.0
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40a9644b9ba0e83a74576e0a5e5f7313599fa9c9cdaf3c20f8a3e271b0e9ae7c
3
+ size 802235437
requesting_access.png ADDED