Spaces:
Sleeping
Sleeping
alrichardbollans
commited on
Commit
·
ff1a4ee
1
Parent(s):
6dffedd
Improve footer styling
Browse files- app.py +24 -28
- styles.css +6 -1
app.py
CHANGED
|
@@ -24,10 +24,10 @@ from detectron2.utils.visualizer import Visualizer, ColorMode
|
|
| 24 |
from detectron2.data import Metadata
|
| 25 |
|
| 26 |
from python_utils import load_model, apply_nms
|
|
|
|
| 27 |
# Load data and compute static values
|
| 28 |
app_dir = Path(__file__).parent
|
| 29 |
|
| 30 |
-
|
| 31 |
# Load the prediction model
|
| 32 |
predictor = load_model()
|
| 33 |
app_ui = ui.page_fluid(
|
|
@@ -36,30 +36,30 @@ app_ui = ui.page_fluid(
|
|
| 36 |
ui.div(
|
| 37 |
ui.row(
|
| 38 |
ui.column(6,
|
| 39 |
-
|
| 40 |
-
|
| 41 |
),
|
| 42 |
class_="nav-bar"
|
| 43 |
),
|
| 44 |
|
| 45 |
ui.div(
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
),
|
| 49 |
-
class_="body-bar"
|
| 50 |
),
|
|
|
|
|
|
|
| 51 |
|
| 52 |
ui.div(
|
| 53 |
ui.layout_sidebar(
|
| 54 |
ui.sidebar(
|
| 55 |
ui.input_file("upload", "Upload Images",
|
| 56 |
-
|
| 57 |
-
|
| 58 |
ui.input_slider("threshold", "Threshold", 0, 1.0, 0.8),
|
| 59 |
ui.input_action_button("analyze", "Analyze", class_="btn-success"),
|
| 60 |
# ui.input_switch("mask", "Mask", False),
|
| 61 |
-
ui.column(4,ui.download_button("download", "Download Results", class_="btn-primary")),
|
| 62 |
-
width
|
| 63 |
|
| 64 |
),
|
| 65 |
ui.output_ui("results_container"),
|
|
@@ -69,12 +69,11 @@ app_ui = ui.page_fluid(
|
|
| 69 |
),
|
| 70 |
ui.div(
|
| 71 |
ui.layout_column_wrap(
|
| 72 |
-
ui.output_image("rbg_kew",
|
| 73 |
-
ui.output_image("bloomberg",
|
| 74 |
-
ui.output_image("brin",
|
| 75 |
-
ui.output_image("abg",
|
| 76 |
-
)
|
| 77 |
-
# class_="footer"
|
| 78 |
)
|
| 79 |
)
|
| 80 |
|
|
@@ -87,9 +86,9 @@ def plot_ui():
|
|
| 87 |
opacity_slider
|
| 88 |
)
|
| 89 |
|
|
|
|
| 90 |
@module.server
|
| 91 |
def plot_server(input, output, session, r):
|
| 92 |
-
|
| 93 |
@render.plot
|
| 94 |
def plot_prediction():
|
| 95 |
plt.ioff()
|
|
@@ -105,20 +104,21 @@ def plot_server(input, output, session, r):
|
|
| 105 |
colours = []
|
| 106 |
for cls in r["instances"].pred_classes:
|
| 107 |
if cls == 0:
|
| 108 |
-
colours.append([1,0,0])
|
| 109 |
elif cls == 1:
|
| 110 |
-
colours.append([1,1,0])
|
| 111 |
elif cls == 2:
|
| 112 |
-
colours.append([0,0,0])
|
| 113 |
|
| 114 |
-
out = v.overlay_instances(masks
|
| 115 |
-
assigned_colors
|
| 116 |
-
alpha
|
| 117 |
|
| 118 |
ax.imshow(cv2.cvtColor(out.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
|
| 119 |
fig.canvas.draw()
|
| 120 |
fig.canvas.flush_events()
|
| 121 |
|
|
|
|
| 122 |
def server(input, output, session: Session):
|
| 123 |
@render.image
|
| 124 |
def rbg_kew():
|
|
@@ -140,7 +140,6 @@ def server(input, output, session: Session):
|
|
| 140 |
img = {"src": "assets/abg.png"}
|
| 141 |
return img
|
| 142 |
|
| 143 |
-
|
| 144 |
analysis_results = reactive.Value([])
|
| 145 |
|
| 146 |
@reactive.Effect
|
|
@@ -196,7 +195,6 @@ def server(input, output, session: Session):
|
|
| 196 |
|
| 197 |
ui_output = []
|
| 198 |
for idx, r in enumerate(results):
|
| 199 |
-
|
| 200 |
plot_server(f"plot_{idx}", r=r)
|
| 201 |
|
| 202 |
ui_output.append(
|
|
@@ -238,8 +236,6 @@ def server(input, output, session: Session):
|
|
| 238 |
|
| 239 |
app = App(app_ui, server)
|
| 240 |
|
| 241 |
-
|
| 242 |
-
|
| 243 |
# --------------------------------------------------------
|
| 244 |
# Reactive calculations and effects
|
| 245 |
# --------------------------------------------------------
|
|
|
|
| 24 |
from detectron2.data import Metadata
|
| 25 |
|
| 26 |
from python_utils import load_model, apply_nms
|
| 27 |
+
|
| 28 |
# Load data and compute static values
|
| 29 |
app_dir = Path(__file__).parent
|
| 30 |
|
|
|
|
| 31 |
# Load the prediction model
|
| 32 |
predictor = load_model()
|
| 33 |
app_ui = ui.page_fluid(
|
|
|
|
| 36 |
ui.div(
|
| 37 |
ui.row(
|
| 38 |
ui.column(6,
|
| 39 |
+
ui.panel_title(ui.div("Orchid TZ Viability Analyzer", class_="navbar-title"))
|
| 40 |
+
),
|
| 41 |
),
|
| 42 |
class_="nav-bar"
|
| 43 |
),
|
| 44 |
|
| 45 |
ui.div(
|
| 46 |
+
ui.p(
|
| 47 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc ut laoreet placerat, urna purus rhoncus nisi, vel facilisis magna sem sed tellus."
|
|
|
|
|
|
|
| 48 |
),
|
| 49 |
+
class_="body-bar"
|
| 50 |
+
),
|
| 51 |
|
| 52 |
ui.div(
|
| 53 |
ui.layout_sidebar(
|
| 54 |
ui.sidebar(
|
| 55 |
ui.input_file("upload", "Upload Images",
|
| 56 |
+
multiple=True,
|
| 57 |
+
accept=[".png", ".jpg", ".jpeg"]),
|
| 58 |
ui.input_slider("threshold", "Threshold", 0, 1.0, 0.8),
|
| 59 |
ui.input_action_button("analyze", "Analyze", class_="btn-success"),
|
| 60 |
# ui.input_switch("mask", "Mask", False),
|
| 61 |
+
ui.column(4, ui.download_button("download", "Download Results", class_="btn-primary")),
|
| 62 |
+
width=300
|
| 63 |
|
| 64 |
),
|
| 65 |
ui.output_ui("results_container"),
|
|
|
|
| 69 |
),
|
| 70 |
ui.div(
|
| 71 |
ui.layout_column_wrap(
|
| 72 |
+
ui.output_image("rbg_kew", height='100%', fill=True),
|
| 73 |
+
ui.output_image("bloomberg", height='100%', fill=True),
|
| 74 |
+
ui.output_image("brin", height='100%', fill=True),
|
| 75 |
+
ui.output_image("abg", height='100%', fill=True),
|
| 76 |
+
), class_="footer"
|
|
|
|
| 77 |
)
|
| 78 |
)
|
| 79 |
|
|
|
|
| 86 |
opacity_slider
|
| 87 |
)
|
| 88 |
|
| 89 |
+
|
| 90 |
@module.server
|
| 91 |
def plot_server(input, output, session, r):
|
|
|
|
| 92 |
@render.plot
|
| 93 |
def plot_prediction():
|
| 94 |
plt.ioff()
|
|
|
|
| 104 |
colours = []
|
| 105 |
for cls in r["instances"].pred_classes:
|
| 106 |
if cls == 0:
|
| 107 |
+
colours.append([1, 0, 0])
|
| 108 |
elif cls == 1:
|
| 109 |
+
colours.append([1, 1, 0])
|
| 110 |
elif cls == 2:
|
| 111 |
+
colours.append([0, 0, 0])
|
| 112 |
|
| 113 |
+
out = v.overlay_instances(masks=r["instances"].pred_masks.to("cpu"),
|
| 114 |
+
assigned_colors=colours,
|
| 115 |
+
alpha=input.opacity_slider())
|
| 116 |
|
| 117 |
ax.imshow(cv2.cvtColor(out.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
|
| 118 |
fig.canvas.draw()
|
| 119 |
fig.canvas.flush_events()
|
| 120 |
|
| 121 |
+
|
| 122 |
def server(input, output, session: Session):
|
| 123 |
@render.image
|
| 124 |
def rbg_kew():
|
|
|
|
| 140 |
img = {"src": "assets/abg.png"}
|
| 141 |
return img
|
| 142 |
|
|
|
|
| 143 |
analysis_results = reactive.Value([])
|
| 144 |
|
| 145 |
@reactive.Effect
|
|
|
|
| 195 |
|
| 196 |
ui_output = []
|
| 197 |
for idx, r in enumerate(results):
|
|
|
|
| 198 |
plot_server(f"plot_{idx}", r=r)
|
| 199 |
|
| 200 |
ui_output.append(
|
|
|
|
| 236 |
|
| 237 |
app = App(app_ui, server)
|
| 238 |
|
|
|
|
|
|
|
| 239 |
# --------------------------------------------------------
|
| 240 |
# Reactive calculations and effects
|
| 241 |
# --------------------------------------------------------
|
styles.css
CHANGED
|
@@ -38,6 +38,11 @@ body {
|
|
| 38 |
text-align: left;
|
| 39 |
}
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
/* Sidebar styling */
|
| 42 |
.card.shiny-input-container {
|
| 43 |
background-color: #ffffff;
|
|
@@ -98,7 +103,7 @@ img {
|
|
| 98 |
max-height: 300px;
|
| 99 |
width: 100%;
|
| 100 |
margin: 10px 0;
|
| 101 |
-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1)
|
| 102 |
}
|
| 103 |
|
| 104 |
/* Results text styling */
|
|
|
|
| 38 |
text-align: left;
|
| 39 |
}
|
| 40 |
|
| 41 |
+
.footer {
|
| 42 |
+
border-top: 2px solid #ddd;
|
| 43 |
+
background: white;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
/* Sidebar styling */
|
| 47 |
.card.shiny-input-container {
|
| 48 |
background-color: #ffffff;
|
|
|
|
| 103 |
max-height: 300px;
|
| 104 |
width: 100%;
|
| 105 |
margin: 10px 0;
|
| 106 |
+
/*box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);*/
|
| 107 |
}
|
| 108 |
|
| 109 |
/* Results text styling */
|