Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,7 +50,7 @@ app_ui = ui.page_fluid(
|
|
| 50 |
|
| 51 |
@module.ui
|
| 52 |
def plot_ui():
|
| 53 |
-
opacity_slider = ui.input_slider("
|
| 54 |
return ui.row(
|
| 55 |
ui.output_plot("plot_prediction"),
|
| 56 |
opacity_slider
|
|
@@ -58,8 +58,15 @@ def plot_ui():
|
|
| 58 |
|
| 59 |
@module.server
|
| 60 |
def plot_server(input, output, session, r):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
@render.plot
|
| 62 |
-
|
| 63 |
fig, ax = plt.subplots()
|
| 64 |
|
| 65 |
# ax = plt.Axes(fig, [0., 0., 1., 1.])
|
|
@@ -80,9 +87,11 @@ def plot_server(input, output, session, r):
|
|
| 80 |
|
| 81 |
out = v.overlay_instances(masks = r["instances"].pred_masks.to("cpu"),
|
| 82 |
assigned_colors = colours,
|
| 83 |
-
alpha =
|
| 84 |
|
| 85 |
-
ax.imshow(cv2.cvtColor(out.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
|
|
|
|
|
|
|
| 86 |
|
| 87 |
def server(input, output, session: Session):
|
| 88 |
analysis_results = reactive.Value([])
|
|
|
|
| 50 |
|
| 51 |
@module.ui
|
| 52 |
def plot_ui():
|
| 53 |
+
opacity_slider = ui.input_slider("opacity_slider", "Opacity", 0, 1.0, 0.5)
|
| 54 |
return ui.row(
|
| 55 |
ui.output_plot("plot_prediction"),
|
| 56 |
opacity_slider
|
|
|
|
| 58 |
|
| 59 |
@module.server
|
| 60 |
def plot_server(input, output, session, r):
|
| 61 |
+
opacity = reactive.value(0.5)
|
| 62 |
+
|
| 63 |
+
@reactive.effect
|
| 64 |
+
@reactive.event(input.opacity_slider)
|
| 65 |
+
def _():
|
| 66 |
+
opacity.set(input.opacity_slider())
|
| 67 |
+
|
| 68 |
@render.plot
|
| 69 |
+
def plot_prediction():
|
| 70 |
fig, ax = plt.subplots()
|
| 71 |
|
| 72 |
# ax = plt.Axes(fig, [0., 0., 1., 1.])
|
|
|
|
| 87 |
|
| 88 |
out = v.overlay_instances(masks = r["instances"].pred_masks.to("cpu"),
|
| 89 |
assigned_colors = colours,
|
| 90 |
+
alpha = opacity())
|
| 91 |
|
| 92 |
+
annotations = ax.imshow(cv2.cvtColor(out.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
|
| 93 |
+
fig.canvas.draw()
|
| 94 |
+
fig.canvas.flush_events()
|
| 95 |
|
| 96 |
def server(input, output, session: Session):
|
| 97 |
analysis_results = reactive.Value([])
|