File size: 10,187 Bytes
b4dcd00
45118fd
 
 
fa8ae90
 
9d45190
45118fd
 
29b86f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45118fd
 
 
29b86f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45118fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import os
import gradio as gr
# from model import predict
import cv2
# os.system("cd ./D-MASTER_1/models/ops")
os.system("sh ./D-MASTER_1/models/ops/make.sh")
print("Layer building done!")


# with gr.Blocks() as demo:
#     with gr.Column():
#         title = "<h1 style='margin-bottom: -10px; text-align: center'>D-MASTER: Mask Annealed Transformer for Unsupervised Domain Adaptation in Breast Cancer Detection from Mammograms</h1>"
#         # gr.HTML(title)
#         gr.Markdown(
#             "<h1 style='text-align: center; margin-bottom: 1rem'>"
#             + title
#             + "</h1>"
#         )

#         description = "<p style='font-size: 14px; margin: 5px; font-weight: 300; text-align: center'> <a href='' style='text-decoration:none' target='_blank'>Tajamul Ashraff<sup>*</sup></a>, <a href='' style='text-decoration:none' target='_blank'>Chetan Arora<sup>*</sup></a> </p>" \
#                     + "<p style='font-size: 16px; margin: 5px; font-weight: 600; text-align: center'>  <a href='' target='_blank'>Publication</a> | <a href='' target='_blank'>Website</a> | <a href='' target='_blank'>Github Repo</a></p>" \
#                     + "<p style='text-align: center; margin: 5px; font-size: 14px; font-weight: 300;'> We focus on the problem of Unsupervised Domain Adaptation (UDA) for breast cancer detection from mammograms (BCDM) problem. Recent advancements have shown that masked image modeling serves as a robust pretext task for UDA. However, when applied to cross-domain BCDM, these techniques struggle with breast abnormalities such as masses, asymmetries, and micro-calcifications, in part due to the typically much smaller size of region of interest in comparison to natural images. This often results in more false positives per image (FPI) and significant noise in pseudo-labels typically used to bootstrap such techniques. Recognizing these challenges, we introduce a transformer-based Domain-invariant Mask Annealed Student Teacher autoencoder (D-MASTER) framework. D-MASTER adaptively masks and reconstructs multi-scale feature maps, enhancing the model’s ability to capture reliable target domain features. D-MASTER also includes adaptive confidence refinement to filter pseudo-labels, ensuring only high-quality detections are considered. We also provide a bounding box annotated subset of 1000 mammograms from the RSNA Breast Screening Dataset (referred to as RSNA-BSD1K) to support further research in BCDM. We evaluate D-MASTER on multiple BCDM datasets acquired from diverse domains. Experimental results show a significant improvement of 9% and 13% in sensitivity at 0.3 FPI over state-of-the-art UDA techniques on publicly available benchmark INBreast and DDSM datasets respectively. We also report an improvement of 11% and 17% on In-house and RSNA-BSD1K datasets respectively. To promote reproducible research and address the scarcity of accessible resources in BCDM, we will publicly release source code, and pre-trained D-MASTER model, along with RSNA-BSD1K annotations. To get started, you can try one of the present examples.</p>" \
#                     + "<p style='text-align: center; font-size: 14px; margin: 5px; font-weight: 300;'> [Note: Inference on CPU may take up to 2 minutes. On a GPU, inference time is approximately 1s.]</p>"
#                     + "<p style='text-align: center; font-size: 14px; margin: 5px; font-weight: 300;'> Demo coming soon. Stay tuned!</p>"
#         # Use gr.Markdown or gr.HTML to render the description
#         # gr.HTML(description)
#         gr.Markdown(description)

with gr.Blocks() as demo:
    with gr.Column():
        title = "<h1 style='margin-bottom: -10px; text-align: center'>D-MASTER: Mask Annealed Transformer for Unsupervised Domain Adaptation in Breast Cancer Detection from Mammograms</h1>"
        gr.HTML(title)  # Corrected to use gr.HTML directly with title

        description = """
        <p style='font-size: 14px; margin: 5px; font-weight: 300; text-align: center'>
            <a href='' style='text-decoration:none' target='_blank'>Tajamul Ashraff<sup>*</sup></a>, 
            <a href='' style='text-decoration:none' target='_blank'>Chetan Arora<sup>*</sup></a> 
        </p>
        <p style='font-size: 16px; margin: 5px; font-weight: 600; text-align: center'>
            <a href='' target='_blank'>Publication</a> | 
            <a href='' target='_blank'>Website</a> | 
            <a href='' target='_blank'>Github Repo</a>
        </p>
        <p style='text-align: center; margin: 5px; font-size: 14px; font-weight: 300;'>
            We focus on the problem of Unsupervised Domain Adaptation (UDA) for breast cancer detection from mammograms (BCDM) problem. Recent advancements have shown that masked image modeling serves as a robust pretext task for UDA. However, when applied to cross-domain BCDM, these techniques struggle with breast abnormalities such as masses, asymmetries, and micro-calcifications, in part due to the typically much smaller size of region of interest in comparison to natural images. This often results in more false positives per image (FPI) and significant noise in pseudo-labels typically used to bootstrap such techniques. Recognizing these challenges, we introduce a transformer-based Domain-invariant Mask Annealed Student Teacher autoencoder (D-MASTER) framework. D-MASTER adaptively masks and reconstructs multi-scale feature maps, enhancing the model’s ability to capture reliable target domain features. D-MASTER also includes adaptive confidence refinement to filter pseudo-labels, ensuring only high-quality detections are considered. We also provide a bounding box annotated subset of 1000 mammograms from the RSNA Breast Screening Dataset (referred to as RSNA-BSD1K) to support further research in BCDM. We evaluate D-MASTER on multiple BCDM datasets acquired from diverse domains. Experimental results show a significant improvement of 9% and 13% in sensitivity at 0.3 FPI over state-of-the-art UDA techniques on publicly available benchmark INBreast and DDSM datasets respectively. We also report an improvement of 11% and 17% on In-house and RSNA-BSD1K datasets respectively. To promote reproducible research and address the scarcity of accessible resources in BCDM, we will publicly release source code, and pre-trained D-MASTER model, along with RSNA-BSD1K annotations. To get started, you can try one of the present examples.
        </p>
        <p style='text-align: center; font-size: 14px; margin: 5px; font-weight: 300;'> 
            [Note: Inference on CPU may take up to 2 minutes. On a GPU, inference time is approximately 1s.]
        </p>
        <p style='text-align: center; font-size: 14px; margin: 5px; font-weight: 300;'> 
            Demo coming soon. Stay tuned!
        </p>
        """
        gr.HTML(description)  # Corrected to use gr.HTML directly with description

demo.launch()



        # head_html = gr.HTML('''
        #     <h1>
        #          Deep Learning for Detection of iso-dense, obscure masses in mammographically dense breasts
        #     </h1>
        #     <p style='text-align: center;'>
        #         Give bilateral mammograms(both left and right sides), and let our model find the cancers!
        #     </p>
            
        #     <p style='text-align: center;'>
        #         This is an official demo for our paper: 
        #          `Deep Learning for Detection of iso-dense, obscure masses in mammographically dense breasts`.
        #          Check out the paper and code for details! 
        #     </p>
        # ''')

        # gr.Markdown(
        # """
        #     [![report](https://img.shields.io/badge/arxiv-report-red)](https://arxiv.org/abs/) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/) 
        # """)

        # def generate_preds(img1, img2):
        #     print(img1, img2)
        #     print(img1, img2)
        #     img_out1 = predict(img1, img2)
        #     if img_out1.shape[1] < img_out1.shape[2]:
        #         ratio = img_out1.shape[2] / 800
        #     else:
        #         ratio = img_out1.shape[1] / 800
        #     img_out1 = cv2.resize(img_out1, (0,0), fx=1 / ratio, fy=1 / ratio) 
        #     img_out2 = predict(img2, img1, baseIsLeft = False) 
        #     if img_out2.shape[1] < img_out2.shape[2]:
        #         ratio = img_out2.shape[2] / 800
        #     else:
        #         ratio = img_out2.shape[1] / 800
        #     img_out2 = cv2.resize(img_out2, (0,0), fx= 1 / ratio, fy= 1 / ratio) 

        #     cv2.imwrite('img_out1.jpg', img_out1)
        #     cv2.imwrite('img_out2.jpg', img_out2)


        #     return 'img_out1.jpg', 'img_out2.jpg'

        # with gr.Column():
        #     with gr.Row(variant = 'panel'):
                
        #         with gr.Column(variant = 'panel'):
        #             img1 = gr.Image(type="filepath", label="Left Image" )
        #             img2 = gr.Image(type="filepath", label="Right Image")
        #             # with gr.Row():
        #             #     sub_btn = gr.Button("Predict!", variant="primary")

        #         with gr.Column(variant = 'panel'):
        #             # img_out1 = gr.inputs.Image(type="file", label="Output Left Image")
        #             # img_out2 = gr.inputs.Image(type="file", label="Output for Right Image")
        #             img_out1 = gr.Image(type="filepath", label="Output for Left Image", shape = None)
        #             img_out1.style(height=250 * 2)

        #         with gr.Column(variant = 'panel'):
        #             img_out2 = gr.Image(type="filepath", label="Output for Right Image", shape = None)
        #             img_out2.style(height=250 * 2)

        #     with gr.Row():
        #         sub_btn = gr.Button("Predict!", variant="primary")

        # gr.Examples([[f'sample_images/img{idx}_l.jpg', f'sample_images/img{idx}_r.jpg'] for idx in range(1,6)], inputs = [img1, img2])

        # sub_btn.click(fn = lambda x,y: generate_preds(x,y), inputs = [img1, img2], outputs = [img_out1, img_out2])




if __name__ == '__main__':
    demo.launch(show_api=False)