Spaces:
Running
Running
antoinedelplace
commited on
Commit
Β·
3f587ea
1
Parent(s):
fb5bc28
Improve Readme. Add 4 stains
Browse files
README.md
CHANGED
@@ -1,17 +1,29 @@
|
|
1 |
---
|
2 |
-
title: H&E
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.7.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
# H&E
|
13 |
-
|
|
|
|
|
14 |
|
15 |
Original folder: [lifangda01/AdaptiveSupervisedPatchNCE](https://github.com/lifangda01/AdaptiveSupervisedPatchNCE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
|
|
1 |
---
|
2 |
+
title: H&E-to-IHC Stain Translation
|
3 |
+
emoji: πͺπ§¬π
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.7.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
# H&E-to-IHC Stain Translation
|
13 |
+
Gradio App based on Adaptive Supervised PatchNCE Loss for Learning H&E-to-IHC Stain Translation with Inconsistent Groundtruth Image Pairs (MICCAI 2023)
|
14 |
+
|
15 |
+
Online demo: [](https://huggingface.co/spaces/AntoineDelplace/HE-to-IHC)
|
16 |
|
17 |
Original folder: [lifangda01/AdaptiveSupervisedPatchNCE](https://github.com/lifangda01/AdaptiveSupervisedPatchNCE)
|
18 |
+
Original paper: [](https://arxiv.org/pdf/2303.06193)
|
19 |
+
|
20 |
+
## π― Overview
|
21 |
+
This repository features a Gradio-based application built on the methods introduced in the MICCAI 2023 paper, "Adaptive Supervised PatchNCE Loss for Learning H&E-to-IHC Stain Translation with Inconsistent Groundtruth Image Pairs." The application facilitates automatic virtual staining, transforming H&E (Hematoxylin and Eosin) images into corresponding IHC (ImmunoHistoChemistry) images.
|
22 |
+
|
23 |
+
Users can generate virtual IHC stains for four key biomarkers critical to breast cancer diagnostics:
|
24 |
+
- HER2: Human Epidermal Growth Factor Receptor 2
|
25 |
+
- ER: Estrogen Receptor
|
26 |
+
- Ki67: Antigen KI-67 (cell proliferation marker)
|
27 |
+
- PR: Progesterone Receptor
|
28 |
|
29 |
+
This tool simplifies and accelerates the analysis of histopathological samples, making advanced diagnostic insights more accessible through virtual staining technology.
|
app.py
CHANGED
@@ -36,7 +36,14 @@ def postprocess_tensor(tensor):
|
|
36 |
|
37 |
return output_img
|
38 |
|
39 |
-
def convert_he2ihc(input_he_image_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
input_img = Image.open(input_he_image_path).convert('RGB')
|
41 |
original_img_size = input_img.size
|
42 |
|
@@ -44,10 +51,7 @@ def convert_he2ihc(input_he_image_path):
|
|
44 |
gpu_ids=None,
|
45 |
isTrain=False,
|
46 |
checkpoints_dir="../../checkpoints",
|
47 |
-
name=
|
48 |
-
# name="ASP_pretrained/MIST_her2_zero_uniform",
|
49 |
-
# name="ASP_pretrained/BCI_her2_lambda_linear",
|
50 |
-
# name="ASP_pretrained/BCI_her2_zero_uniform",
|
51 |
preprocess="scale_width_and_crop",
|
52 |
nce_layers="0,4,8,12,16",
|
53 |
nce_idt=False,
|
@@ -98,16 +102,27 @@ def convert_he2ihc(input_he_image_path):
|
|
98 |
return output_img
|
99 |
|
100 |
def main():
|
101 |
-
# download_weights("1SMTeMprETgXAfJGXQz0LtgXXetfKXNaW", "../../checkpoints/ASP_pretrained/BCI_her2_zero_uniform/latest_net_G.pth")
|
102 |
-
# download_weights("1PBVAwwytks9FVUEt6k4Ra3vgTB8moFTY", "../../checkpoints/ASP_pretrained/BCI_her2_lambda_linear/latest_net_G.pth")
|
103 |
-
# download_weights("1m75d7dvVs_I8-c5zWKgOBz0dIMz1qdc2", "../../checkpoints/ASP_pretrained/MIST_her2_zero_uniform/latest_net_G.pth")
|
104 |
download_weights("1N_HOGU7FO4u-S1OD-bumZGyevYeucT4Q", "../../checkpoints/ASP_pretrained/MIST_her2_lambda_linear/latest_net_G.pth")
|
|
|
|
|
|
|
105 |
|
106 |
demo = gr.Interface(
|
107 |
fn=convert_he2ihc,
|
108 |
-
inputs=
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
)
|
112 |
|
113 |
demo.launch()
|
|
|
36 |
|
37 |
return output_img
|
38 |
|
39 |
+
def convert_he2ihc(output_stain, input_he_image_path):
|
40 |
+
stain2folder_name = {
|
41 |
+
"HER2 (Human Epidermal growth factor Receptor 2)": "ASP_pretrained/MIST_her2_lambda_linear",
|
42 |
+
"ER (Estrogen Receptor)" : "ASP_pretrained/MIST_er_lambda_linear",
|
43 |
+
"Ki67 (Antigen KI-67)" : "ASP_pretrained/MIST_ki67_lambda_linear",
|
44 |
+
"PR (Progesterone Receptor)" : "ASP_pretrained/MIST_pr_lambda_linear",
|
45 |
+
}
|
46 |
+
|
47 |
input_img = Image.open(input_he_image_path).convert('RGB')
|
48 |
original_img_size = input_img.size
|
49 |
|
|
|
51 |
gpu_ids=None,
|
52 |
isTrain=False,
|
53 |
checkpoints_dir="../../checkpoints",
|
54 |
+
name=stain2folder_name[output_stain],
|
|
|
|
|
|
|
55 |
preprocess="scale_width_and_crop",
|
56 |
nce_layers="0,4,8,12,16",
|
57 |
nce_idt=False,
|
|
|
102 |
return output_img
|
103 |
|
104 |
def main():
|
|
|
|
|
|
|
105 |
download_weights("1N_HOGU7FO4u-S1OD-bumZGyevYeucT4Q", "../../checkpoints/ASP_pretrained/MIST_her2_lambda_linear/latest_net_G.pth")
|
106 |
+
download_weights("1j6xu8MAOVUaZuV4O5CqsBfMtH6-droys", "../../checkpoints/ASP_pretrained/MIST_er_lambda_linear/latest_net_G.pth")
|
107 |
+
download_weights("10STHMS-GMkHMOJp_cJ44T66rRwKlUZyr", "../../checkpoints/ASP_pretrained/MIST_ki67_lambda_linear/latest_net_G.pth")
|
108 |
+
download_weights("1APIrm3kqtPhhAIcU7pvfIcYpMjpsIlQ9", "../../checkpoints/ASP_pretrained/MIST_pr_lambda_linear/latest_net_G.pth")
|
109 |
|
110 |
demo = gr.Interface(
|
111 |
fn=convert_he2ihc,
|
112 |
+
inputs=[
|
113 |
+
gr.Dropdown(
|
114 |
+
choices=["HER2 (Human Epidermal growth factor Receptor 2)",
|
115 |
+
"ER (Estrogen Receptor)",
|
116 |
+
"Ki67 (Antigen KI-67)",
|
117 |
+
"PR (Progesterone Receptor)"],
|
118 |
+
label="Output Stain"
|
119 |
+
),
|
120 |
+
gr.Image(type="filepath", label="Input H&E Image")
|
121 |
+
],
|
122 |
+
outputs=gr.Image(label="Ouput IHC Image"),
|
123 |
+
title="H&E-to-IHC Stain Translation",
|
124 |
+
description="<h2>Stain your H&E (Hematoxylin and Eosin) images into IHC (ImmunoHistoChemistry) images automatically thanks to AI!</h2>",
|
125 |
+
theme="ParityError/Interstellar"
|
126 |
)
|
127 |
|
128 |
demo.launch()
|