Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,10 +50,13 @@ app_ui = ui.page_fluid(
|
|
| 50 |
|
| 51 |
@module.ui
|
| 52 |
def plot_ui():
|
| 53 |
-
return ui.
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
@module.server
|
| 56 |
-
def plot_server(input, output, session, r
|
| 57 |
@render.plot
|
| 58 |
def plot_prediction():
|
| 59 |
fig, ax = plt.subplots()
|
|
@@ -76,7 +79,7 @@ def plot_server(input, output, session, r, opacity):
|
|
| 76 |
|
| 77 |
out = v.overlay_instances(masks = r["instances"].pred_masks.to("cpu"),
|
| 78 |
assigned_colors = colours,
|
| 79 |
-
alpha = opacity)
|
| 80 |
|
| 81 |
ax.imshow(cv2.cvtColor(out.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
|
| 82 |
|
|
@@ -136,9 +139,8 @@ def server(input, output, session: Session):
|
|
| 136 |
for idx, r in enumerate(results):
|
| 137 |
|
| 138 |
id = "image_" + str(idx)
|
| 139 |
-
opacity = ui.input_slider(id, "Opacity", 0, 1.0, 0.5)
|
| 140 |
|
| 141 |
-
plot_server(f"plot_{idx}",r=r
|
| 142 |
|
| 143 |
ui_output.append(
|
| 144 |
ui.div(
|
|
@@ -146,7 +148,6 @@ def server(input, output, session: Session):
|
|
| 146 |
ui.column(4, ui.img(src=f"data:image/png;base64,{r['image_base64']}")),
|
| 147 |
plot_ui(f"plot_{idx}"),
|
| 148 |
),
|
| 149 |
-
opacity,
|
| 150 |
ui.h5(r['filename'], style="margin-top: 15px;"),
|
| 151 |
ui.div(
|
| 152 |
ui.span(f"Viable = {r.get('viable', '? ')}", style="margin: 0 15px;"),
|
|
|
|
| 50 |
|
| 51 |
@module.ui
|
| 52 |
def plot_ui():
|
| 53 |
+
return ui.div(
|
| 54 |
+
ui.input_slider("opacity", "Opacity", 0, 1.0, 0.5),
|
| 55 |
+
ui.column(4, ui.output_plot("plot_prediction"))
|
| 56 |
+
)
|
| 57 |
|
| 58 |
@module.server
|
| 59 |
+
def plot_server(input, output, session, r):
|
| 60 |
@render.plot
|
| 61 |
def plot_prediction():
|
| 62 |
fig, ax = plt.subplots()
|
|
|
|
| 79 |
|
| 80 |
out = v.overlay_instances(masks = r["instances"].pred_masks.to("cpu"),
|
| 81 |
assigned_colors = colours,
|
| 82 |
+
alpha = input.opacity())
|
| 83 |
|
| 84 |
ax.imshow(cv2.cvtColor(out.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
|
| 85 |
|
|
|
|
| 139 |
for idx, r in enumerate(results):
|
| 140 |
|
| 141 |
id = "image_" + str(idx)
|
|
|
|
| 142 |
|
| 143 |
+
plot_server(f"plot_{idx}", r=r)
|
| 144 |
|
| 145 |
ui_output.append(
|
| 146 |
ui.div(
|
|
|
|
| 148 |
ui.column(4, ui.img(src=f"data:image/png;base64,{r['image_base64']}")),
|
| 149 |
plot_ui(f"plot_{idx}"),
|
| 150 |
),
|
|
|
|
| 151 |
ui.h5(r['filename'], style="margin-top: 15px;"),
|
| 152 |
ui.div(
|
| 153 |
ui.span(f"Viable = {r.get('viable', '? ')}", style="margin: 0 15px;"),
|