Spaces:
Build error
Build error
Commit
·
befdaa8
1
Parent(s):
7506fcb
Update app.py and made utils folder for color schema
Browse files- app.py +12 -6
- 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)
|
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 |
+
)
|