russellotniel
commited on
Commit
•
ac08f0e
1
Parent(s):
47597c7
Updated main.py file and added page_utils.py file to store color schema
Browse files- main.py +11 -21
- utils/page_utils.py +51 -0
main.py
CHANGED
@@ -8,7 +8,7 @@ import torch
|
|
8 |
from PIL import Image
|
9 |
|
10 |
from models import phc_models
|
11 |
-
from utils import utils
|
12 |
|
13 |
device = torch.device('cpu')
|
14 |
if torch.cuda.is_available():
|
@@ -193,26 +193,16 @@ def predict_bilateral(cc_file, mlo_file):
|
|
193 |
|
194 |
def run():
|
195 |
"""Run Gradio App."""
|
196 |
-
with open('
|
197 |
-
|
198 |
-
|
199 |
-
with gr.Blocks()
|
|
|
|
|
|
|
|
|
200 |
with gr.Column():
|
201 |
-
gr.
|
202 |
-
"""
|
203 |
-
<h1 style="text-align: center;">Bilateral View Hypercomplex Breast Classification</h1>
|
204 |
-
"""
|
205 |
-
)
|
206 |
-
with gr.Row():
|
207 |
-
gr.Markdown(description)
|
208 |
-
gr.Markdown(
|
209 |
-
"""
|
210 |
-
## Model Architecture
|
211 |
-
<img src="file/figures/phresnet18.png" width=auto>
|
212 |
-
|
213 |
-
Parameterized Hypercomplex ResNets-18 Variants (PHYResNet).
|
214 |
-
"""
|
215 |
-
)
|
216 |
with gr.Row():
|
217 |
with gr.Column():
|
218 |
cc_file = gr.File(file_count='single',
|
@@ -220,8 +210,8 @@ def run():
|
|
220 |
mlo_file = gr.File(file_count='single',
|
221 |
file_types=SUPPORTED_IMG_EXT, label='MLO View')
|
222 |
with gr.Row():
|
223 |
-
process_btn = gr.Button('Process')
|
224 |
clear_btn = gr.Button('Clear')
|
|
|
225 |
with gr.Column():
|
226 |
output_gallery = gr.Gallery(
|
227 |
label='Highlighted Area').style(grid=[2], height='auto')
|
|
|
8 |
from PIL import Image
|
9 |
|
10 |
from models import phc_models
|
11 |
+
from utils import utils, page_utils
|
12 |
|
13 |
device = torch.device('cpu')
|
14 |
if torch.cuda.is_available():
|
|
|
193 |
|
194 |
def run():
|
195 |
"""Run Gradio App."""
|
196 |
+
with open('index.html', encoding='utf-8') as f:
|
197 |
+
html_content = f.read()
|
198 |
+
|
199 |
+
with gr.Blocks(theme=gr.themes.Default(primary_hue=page_utils.KALBE_THEME_COLOR, secondary_hue=page_utils.KALBE_THEME_COLOR).set(
|
200 |
+
button_primary_background_fill='*primary_600',
|
201 |
+
button_primary_background_fill_hover='*primary_500',
|
202 |
+
button_primary_text_color='white',
|
203 |
+
)) as demo:
|
204 |
with gr.Column():
|
205 |
+
gr.HTML(html_content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
with gr.Row():
|
207 |
with gr.Column():
|
208 |
cc_file = gr.File(file_count='single',
|
|
|
210 |
mlo_file = gr.File(file_count='single',
|
211 |
file_types=SUPPORTED_IMG_EXT, label='MLO View')
|
212 |
with gr.Row():
|
|
|
213 |
clear_btn = gr.Button('Clear')
|
214 |
+
process_btn = gr.Button('Process', variant="primary")
|
215 |
with gr.Column():
|
216 |
output_gallery = gr.Gallery(
|
217 |
label='Highlighted Area').style(grid=[2], height='auto')
|
utils/page_utils.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Optional
|
2 |
+
|
3 |
+
|
4 |
+
class ColorPalette:
|
5 |
+
"""Color Palette Container."""
|
6 |
+
all = []
|
7 |
+
|
8 |
+
def __init__(
|
9 |
+
self,
|
10 |
+
c50: str,
|
11 |
+
c100: str,
|
12 |
+
c200: str,
|
13 |
+
c300: str,
|
14 |
+
c400: str,
|
15 |
+
c500: str,
|
16 |
+
c600: str,
|
17 |
+
c700: str,
|
18 |
+
c800: str,
|
19 |
+
c900: str,
|
20 |
+
c950: str,
|
21 |
+
name: Optional[str] = None,
|
22 |
+
):
|
23 |
+
self.c50 = c50
|
24 |
+
self.c100 = c100
|
25 |
+
self.c200 = c200
|
26 |
+
self.c300 = c300
|
27 |
+
self.c400 = c400
|
28 |
+
self.c500 = c500
|
29 |
+
self.c600 = c600
|
30 |
+
self.c700 = c700
|
31 |
+
self.c800 = c800
|
32 |
+
self.c900 = c900
|
33 |
+
self.c950 = c950
|
34 |
+
self.name = name
|
35 |
+
ColorPalette.all.append(self)
|
36 |
+
|
37 |
+
|
38 |
+
KALBE_THEME_COLOR = ColorPalette(
|
39 |
+
name='kalbe',
|
40 |
+
c50='#f2f9e8',
|
41 |
+
c100='#dff3c4',
|
42 |
+
c200='#c2e78d',
|
43 |
+
c300='#9fd862',
|
44 |
+
c400='#7fc93f',
|
45 |
+
c500='#3F831C',
|
46 |
+
c600='#31661a',
|
47 |
+
c700='#244c13',
|
48 |
+
c800='#18340c',
|
49 |
+
c900='#0c1b06',
|
50 |
+
c950='#050a02',
|
51 |
+
)
|