haritsahm
commited on
Commit
·
9db4a7b
1
Parent(s):
48bf1ef
Fix display info with html
Browse files- app.py +8 -4
- index.html +123 -49
- style.css +0 -79
app.py
CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
|
|
2 |
|
3 |
st.set_page_config(layout="wide")
|
4 |
|
|
|
5 |
import random
|
6 |
|
7 |
import numpy as np
|
@@ -10,6 +11,11 @@ from PIL import Image
|
|
10 |
from streamlit_drawable_canvas import st_canvas
|
11 |
from utils import utils
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
PREDICTOR_MODEL, AUTOMASK_MODEL = utils.get_model(checkpoint='checkpoint/medsam_vit_b.pth')
|
14 |
|
15 |
|
@@ -252,11 +258,9 @@ def image_preprocess_callback(predictor_model, option):
|
|
252 |
def main():
|
253 |
with open('index.html', encoding='utf-8') as f:
|
254 |
html_content = f.read()
|
|
|
255 |
|
256 |
-
st.
|
257 |
-
st.markdown('### Model Architecture')
|
258 |
-
st.image('figures/medsam.png', caption="Segment Anything - MedSAM", width=600)
|
259 |
-
st.markdown('### Demo')
|
260 |
|
261 |
with st.container():
|
262 |
col1, col2, col3, col4 = st.columns(4)
|
|
|
2 |
|
3 |
st.set_page_config(layout="wide")
|
4 |
|
5 |
+
import base64
|
6 |
import random
|
7 |
|
8 |
import numpy as np
|
|
|
11 |
from streamlit_drawable_canvas import st_canvas
|
12 |
from utils import utils
|
13 |
|
14 |
+
DEFAULT_IMG_TAG = '<img class="content-image" src="" alt="model-architecture">'
|
15 |
+
with open("figures/medsam.png", "rb") as image_file:
|
16 |
+
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
|
17 |
+
IMAGE_TAG_BASE64 = f'<img class="content-image" src="data:image/png;base64,{encoded_string}" alt="model-architecture">'
|
18 |
+
|
19 |
PREDICTOR_MODEL, AUTOMASK_MODEL = utils.get_model(checkpoint='checkpoint/medsam_vit_b.pth')
|
20 |
|
21 |
|
|
|
258 |
def main():
|
259 |
with open('index.html', encoding='utf-8') as f:
|
260 |
html_content = f.read()
|
261 |
+
html_content = html_content.replace(DEFAULT_IMG_TAG, IMAGE_TAG_BASE64)
|
262 |
|
263 |
+
st.components.v1.html(html_content, width=None, height=925, scrolling=False)
|
|
|
|
|
|
|
264 |
|
265 |
with st.container():
|
266 |
col1, col2, col3, col4 = st.columns(4)
|
index.html
CHANGED
@@ -1,54 +1,128 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
|
|
|
|
|
|
|
|
|
|
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 |
</div>
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
48 |
</div>
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
</
|
53 |
-
|
54 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<style type="text/css">
|
5 |
+
* {
|
6 |
+
box-sizing: border-box;
|
7 |
+
}
|
8 |
|
9 |
+
.body {
|
10 |
+
font-family: 'Source Sans Pro', sans-serif;
|
11 |
+
font-size: 16px;
|
12 |
+
}
|
13 |
+
|
14 |
+
.container {
|
15 |
+
width: 100%;
|
16 |
+
margin: 0 auto;
|
17 |
+
}
|
18 |
+
|
19 |
+
.title {
|
20 |
+
font-size: 24px !important;
|
21 |
+
font-weight: 600 !important;
|
22 |
+
font-family: 'Source Sans Pro', sans-serif;
|
23 |
+
letter-spacing: 0em;
|
24 |
+
text-align: center;
|
25 |
+
color: #374159 !important;
|
26 |
+
}
|
27 |
+
|
28 |
+
.subtitle {
|
29 |
+
font-size: 24px !important;
|
30 |
+
font-style: italic;
|
31 |
+
font-weight: 400 !important;
|
32 |
+
font-family: 'Source Sans Pro', sans-serif;
|
33 |
+
letter-spacing: 0em;
|
34 |
+
text-align: center;
|
35 |
+
color: #1d652a !important;
|
36 |
+
padding-bottom: 0.5em;
|
37 |
+
}
|
38 |
+
|
39 |
+
.overview-heading {
|
40 |
+
font-size: 24px !important;
|
41 |
+
font-weight: 600 !important;
|
42 |
+
font-family: 'Source Sans Pro', sans-serif;
|
43 |
+
letter-spacing: 0em;
|
44 |
+
text-align: left;
|
45 |
+
}
|
46 |
+
|
47 |
+
.overview-content {
|
48 |
+
font-size: 14px !important;
|
49 |
+
font-weight: 400 !important;
|
50 |
+
font-family: 'Source Sans Pro', sans-serif;
|
51 |
+
line-height: 30px !important;
|
52 |
+
letter-spacing: 0em;
|
53 |
+
text-align: left;
|
54 |
+
}
|
55 |
+
|
56 |
+
.content-image {
|
57 |
+
width: 100% !important;
|
58 |
+
height: auto !important;
|
59 |
+
}
|
60 |
+
|
61 |
+
.vl {
|
62 |
+
border-left: 5px solid #1d652a;
|
63 |
+
padding-left: 20px;
|
64 |
+
color: #1d652a !important;
|
65 |
+
}
|
66 |
+
|
67 |
+
.grid-container {
|
68 |
+
display: grid;
|
69 |
+
grid-template-columns: 1fr 2fr;
|
70 |
+
gap: 20px;
|
71 |
+
align-items: flex-start;
|
72 |
+
margin-bottom: 0.7em;
|
73 |
+
}
|
74 |
+
|
75 |
+
@media screen and (max-width: 768px) {
|
76 |
+
.container {
|
77 |
+
width: 90%;
|
78 |
+
}
|
79 |
+
|
80 |
+
.grid-container {
|
81 |
+
display: block;
|
82 |
+
}
|
83 |
+
|
84 |
+
.overview-heading {
|
85 |
+
font-size: 18px !important;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
</style>
|
89 |
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
90 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
91 |
+
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap" rel="stylesheet" />
|
92 |
+
</head>
|
93 |
+
<body>
|
94 |
+
<div class="container">
|
95 |
+
<h1 class="title">MedSAM: Segment Anything in Medical Images</h1>
|
96 |
+
<h2 class="subtitle">Kalbe Digital Lab</h2>
|
97 |
+
<section class="overview">
|
98 |
+
<div class="grid-container">
|
99 |
+
<h3 class="overview-heading"><span class="vl">Overview</span></h3>
|
100 |
+
<p class="overview-content">
|
101 |
+
MedSAM, a foundation model for universal medical image segmentation. MedSAM is adapted from the SAM model on an unprecedented scale, with more than one million medical image-mask pairs.
|
102 |
+
<br />
|
103 |
+
Reference: <a href="https://arxiv.org/abs/2304.12306" target="_blank">https://arxiv.org/abs/2204.05798</a>
|
104 |
+
</p>
|
105 |
</div>
|
106 |
+
<div class="grid-container">
|
107 |
+
<h3 class="overview-heading"><span class="vl">Dataset</span></h3>
|
108 |
+
<div>
|
109 |
+
<p class="overview-content">The model is trained using a diverse and large-scale medical image segmentation dataset with 1,090,486 medical image-mask pairs, covering 15 imaging modalities, over 30 cancer types, and a multitude of imaging protocols.</p>
|
110 |
+
<ul class="overview-content">
|
111 |
+
<li>Target: Capturing a broad spectrum of anatomies and lesions across different modalities.</li>
|
112 |
+
<li>Task: Segmentation</li>
|
113 |
+
<li>Modality: Computed Tomography (CT), Magnetic Resonance Imaging (MRI), Endoscopy, Ultrasound, Pathology, Fundus, Dermoscopy, Mammography, and Optical Coherence Tomography (OCT).</li>
|
114 |
+
</ul>
|
115 |
+
</div>
|
116 |
</div>
|
117 |
+
<div class="grid-container">
|
118 |
+
<h3 class="overview-heading"><span class="vl">Model Architecture</span></h3>
|
119 |
+
<div>
|
120 |
+
<p class="overview-content">Segment Anything - MedSAM</p>
|
121 |
+
<img class="content-image" src="" alt="model-architecture">
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
</section>
|
125 |
+
<h3 class="overview-heading"><span class="vl">Demo</span></h3>
|
126 |
+
</div>
|
127 |
+
</body>
|
128 |
+
</html>
|
style.css
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
* {
|
2 |
-
box-sizing: border-box;
|
3 |
-
}
|
4 |
-
|
5 |
-
body {
|
6 |
-
font-family: 'Source Sans Pro', sans-serif;
|
7 |
-
font-size: 16px;
|
8 |
-
}
|
9 |
-
|
10 |
-
.container {
|
11 |
-
width: 100%;
|
12 |
-
margin: 0 auto;
|
13 |
-
}
|
14 |
-
|
15 |
-
.title {
|
16 |
-
font-size: 24px !important;
|
17 |
-
font-weight: 600 !important;
|
18 |
-
letter-spacing: 0em;
|
19 |
-
text-align: center;
|
20 |
-
color: #374159 !important;
|
21 |
-
}
|
22 |
-
|
23 |
-
.subtitle {
|
24 |
-
font-size: 24px !important;
|
25 |
-
font-style: italic;
|
26 |
-
font-weight: 400 !important;
|
27 |
-
letter-spacing: 0em;
|
28 |
-
text-align: center;
|
29 |
-
color: #1d652a !important;
|
30 |
-
padding-bottom: 0.5em;
|
31 |
-
}
|
32 |
-
|
33 |
-
.overview-heading {
|
34 |
-
font-size: 24px !important;
|
35 |
-
font-weight: 600 !important;
|
36 |
-
letter-spacing: 0em;
|
37 |
-
text-align: left;
|
38 |
-
}
|
39 |
-
|
40 |
-
.overview-content {
|
41 |
-
font-size: 14px !important;
|
42 |
-
font-weight: 400 !important;
|
43 |
-
line-height: 30px !important;
|
44 |
-
letter-spacing: 0em;
|
45 |
-
text-align: left;
|
46 |
-
}
|
47 |
-
|
48 |
-
.content-image {
|
49 |
-
width: 100% !important;
|
50 |
-
height: auto !important;
|
51 |
-
}
|
52 |
-
|
53 |
-
.vl {
|
54 |
-
border-left: 5px solid #1d652a;
|
55 |
-
padding-left: 20px;
|
56 |
-
color: #1d652a !important;
|
57 |
-
}
|
58 |
-
|
59 |
-
.grid-container {
|
60 |
-
display: grid;
|
61 |
-
grid-template-columns: 1fr 2fr;
|
62 |
-
gap: 20px;
|
63 |
-
align-items: flex-start;
|
64 |
-
margin-bottom: 0.7em;
|
65 |
-
}
|
66 |
-
|
67 |
-
@media screen and (max-width: 768px) {
|
68 |
-
.container {
|
69 |
-
width: 90%;
|
70 |
-
}
|
71 |
-
|
72 |
-
.grid-container {
|
73 |
-
display: block;
|
74 |
-
}
|
75 |
-
|
76 |
-
.overview-heading {
|
77 |
-
font-size: 18px !important;
|
78 |
-
}
|
79 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|