Spaces:
Build error
Build error
Commit
·
2cf7aba
1
Parent(s):
d9d6b8b
Reformat Overview (#1)
Browse files- Added html and css file (7506fcb8a161b8387eac08fae7732472280d51b4)
- Update app.py and made utils folder for color schema (befdaa80f885d2760243028c622d00a3077d8c17)
Co-authored-by: Russell Otniel <[email protected]>
- app.py +12 -6
- index.html +54 -0
- style.css +79 -0
- utils/page_utils.py +51 -0
app.py
CHANGED
|
@@ -2,6 +2,8 @@ import torch
|
|
| 2 |
from monai.bundle import ConfigParser
|
| 3 |
import gradio as gr
|
| 4 |
|
|
|
|
|
|
|
| 5 |
parser = ConfigParser() # load configuration files that specify various parameters for running the MONAI workflow.
|
| 6 |
parser.read_config(f="configs/inference.json") # read the config from specified JSON file
|
| 7 |
parser.read_meta(f="configs/metadata.json") # read the metadata from specified JSON file
|
|
@@ -52,19 +54,23 @@ example_files2 = [
|
|
| 52 |
'sample_data/Labels/train_1_3_0020.png'],
|
| 53 |
]
|
| 54 |
|
| 55 |
-
with open('
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
with gr.Row():
|
| 61 |
with gr.Column():
|
| 62 |
with gr.Row():
|
| 63 |
inp_img = gr.Image(type="filepath", image_mode="RGB")
|
| 64 |
label_img = gr.Image(type="filepath", image_mode="L")
|
| 65 |
with gr.Row():
|
| 66 |
-
process_btn = gr.Button(value="Process")
|
| 67 |
clear_btn = gr.Button(value="Clear")
|
|
|
|
| 68 |
out_txt = gr.Label(label="Probabilities", num_top_classes=4)
|
| 69 |
|
| 70 |
process_btn.click(fn=classify_image, inputs=[inp_img, label_img], outputs=out_txt)
|
|
|
|
| 2 |
from monai.bundle import ConfigParser
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
from utils import page_utils
|
| 6 |
+
|
| 7 |
parser = ConfigParser() # load configuration files that specify various parameters for running the MONAI workflow.
|
| 8 |
parser.read_config(f="configs/inference.json") # read the config from specified JSON file
|
| 9 |
parser.read_meta(f="configs/metadata.json") # read the metadata from specified JSON file
|
|
|
|
| 54 |
'sample_data/Labels/train_1_3_0020.png'],
|
| 55 |
]
|
| 56 |
|
| 57 |
+
with open('index.html', encoding='utf-8') as file:
|
| 58 |
+
html_content = file.read()
|
| 59 |
+
|
| 60 |
+
with gr.Blocks(theme=gr.themes.Default(primary_hue=page_utils.KALBE_THEME_COLOR, secondary_hue=page_utils.KALBE_THEME_COLOR).set(
|
| 61 |
+
button_primary_background_fill='*primary_600',
|
| 62 |
+
button_primary_background_fill_hover='*primary_500',
|
| 63 |
+
button_primary_text_color='white',
|
| 64 |
+
)) as app:
|
| 65 |
+
gr.HTML(html_content)
|
| 66 |
with gr.Row():
|
| 67 |
with gr.Column():
|
| 68 |
with gr.Row():
|
| 69 |
inp_img = gr.Image(type="filepath", image_mode="RGB")
|
| 70 |
label_img = gr.Image(type="filepath", image_mode="L")
|
| 71 |
with gr.Row():
|
|
|
|
| 72 |
clear_btn = gr.Button(value="Clear")
|
| 73 |
+
process_btn = gr.Button(value="Process", variant="primary")
|
| 74 |
out_txt = gr.Label(label="Probabilities", num_top_classes=4)
|
| 75 |
|
| 76 |
process_btn.click(fn=classify_image, inputs=[inp_img, label_img], outputs=out_txt)
|
index.html
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<link rel="stylesheet" href="file/style.css" />
|
| 5 |
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
| 6 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap" rel="stylesheet" />
|
| 8 |
+
<title>Pathology Nuclei Classification</title>
|
| 9 |
+
</head>
|
| 10 |
+
<body>
|
| 11 |
+
<div class="container">
|
| 12 |
+
<h1 class="title">Pathology Nuclei Classification</h1>
|
| 13 |
+
<h2 class="subtitle">Kalbe Digital Lab</h2>
|
| 14 |
+
<section class="overview">
|
| 15 |
+
<div class="grid-container">
|
| 16 |
+
<h3 class="overview-heading"><span class="vl">Overview</span></h3>
|
| 17 |
+
<div>
|
| 18 |
+
<p class="overview-content">Nuclei classification within Haematoxylin & Eosi stained histology images. Classifying nuclei cells as the following types:</p>
|
| 19 |
+
<ul>
|
| 20 |
+
<li>Other</li>
|
| 21 |
+
<li>Inflammatory</li>
|
| 22 |
+
<li>Epithelial</li>
|
| 23 |
+
<li>Spindle-Shaped</li>
|
| 24 |
+
</ul>
|
| 25 |
+
<p class="overview-content">References: <a href="https://doi.org/10.1016/j.media.2019.101563" target="_blank">https://doi.org/10.1016/j.media.2019.101563</a></p>
|
| 26 |
+
</div>
|
| 27 |
+
</div>
|
| 28 |
+
<div class="grid-container">
|
| 29 |
+
<h3 class="overview-heading"><span class="vl">Dataset</span></h3>
|
| 30 |
+
<div>
|
| 31 |
+
<p class="overview-content">
|
| 32 |
+
The model is trained with Colorectal Nuclear Segmentation and Phenotypes (CoNSeP) dataset
|
| 33 |
+
<a href="https://warwick.ac.uk/fac/cross_fac/tia/data/hovernet" target="_blank">https://warwick.ac.uk/fac/cross_fac/tia/data/hovernet</a>. Images were extracted from 16 colorectal adenocarcinoma (CRA) WSIs.
|
| 34 |
+
</p>
|
| 35 |
+
<ul>
|
| 36 |
+
<li>Target: Nuclei</li>
|
| 37 |
+
<li>Task: Nuclei Cells Class Classification</li>
|
| 38 |
+
<li>Modality: Image (RGB)</li>
|
| 39 |
+
</ul>
|
| 40 |
+
</div>
|
| 41 |
+
</div>
|
| 42 |
+
<div class="grid-container">
|
| 43 |
+
<h3 class="overview-heading"><span class="vl">Model Architecture</span></h3>
|
| 44 |
+
<div>
|
| 45 |
+
<p class="overview-content">The model is trained using DenseNet121 over CoNSep dataset.</p>
|
| 46 |
+
<img class="content-image" src="file/figures/architecture.png" alt="model-architecture" />
|
| 47 |
+
</div>
|
| 48 |
+
</div>
|
| 49 |
+
</section>
|
| 50 |
+
<h3 class="overview-heading"><span class="vl">Demo</span></h3>
|
| 51 |
+
<p class="overview-content">Please select or upload a nuclei histology image and label image to see Nuclei Cells Classification capabilities of this model</p>
|
| 52 |
+
</div>
|
| 53 |
+
</body>
|
| 54 |
+
</html>
|
style.css
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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: 33px !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: 1em;
|
| 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 |
+
}
|
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 |
+
)
|