Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,7 +58,7 @@ def plot_ui():
|
|
| 58 |
)
|
| 59 |
|
| 60 |
@module.server
|
| 61 |
-
def plot_server(input, output, session, r):
|
| 62 |
opacity = reactive.value(0.5)
|
| 63 |
|
| 64 |
@reactive.effect
|
|
@@ -69,18 +69,6 @@ def plot_server(input, output, session, r):
|
|
| 69 |
@render.plot
|
| 70 |
def plot_prediction():
|
| 71 |
fig, ax = plt.subplots()
|
| 72 |
-
|
| 73 |
-
v = Visualizer(r["image"][:, :, ::-1],
|
| 74 |
-
scale=1, instance_mode=ColorMode.SEGMENTATION, font_size_scale=1)
|
| 75 |
-
|
| 76 |
-
colours = []
|
| 77 |
-
for cls in r["instances"].pred_classes:
|
| 78 |
-
if cls == 0:
|
| 79 |
-
colours.append([1,0,0])
|
| 80 |
-
elif cls == 1:
|
| 81 |
-
colours.append([1,1,0])
|
| 82 |
-
elif cls == 2:
|
| 83 |
-
colours.append([0,0,0])
|
| 84 |
|
| 85 |
out = v.overlay_instances(masks = r["instances"].pred_masks.to("cpu"),
|
| 86 |
assigned_colors = colours,
|
|
@@ -147,9 +135,21 @@ def server(input, output, session: Session):
|
|
| 147 |
class_="text-muted")
|
| 148 |
|
| 149 |
ui_output = []
|
| 150 |
-
for idx, r in enumerate(results):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
-
plot_server(f"plot_{idx}", r=r)
|
| 153 |
|
| 154 |
ui_output.append(
|
| 155 |
ui.div(
|
|
|
|
| 58 |
)
|
| 59 |
|
| 60 |
@module.server
|
| 61 |
+
def plot_server(input, output, session, r, v, colours):
|
| 62 |
opacity = reactive.value(0.5)
|
| 63 |
|
| 64 |
@reactive.effect
|
|
|
|
| 69 |
@render.plot
|
| 70 |
def plot_prediction():
|
| 71 |
fig, ax = plt.subplots()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
out = v.overlay_instances(masks = r["instances"].pred_masks.to("cpu"),
|
| 74 |
assigned_colors = colours,
|
|
|
|
| 135 |
class_="text-muted")
|
| 136 |
|
| 137 |
ui_output = []
|
| 138 |
+
for idx, r in enumerate(results):
|
| 139 |
+
|
| 140 |
+
v = Visualizer(r["image"][:, :, ::-1],
|
| 141 |
+
scale=1, instance_mode=ColorMode.SEGMENTATION, font_size_scale=1)
|
| 142 |
+
|
| 143 |
+
colours = []
|
| 144 |
+
for cls in r["instances"].pred_classes:
|
| 145 |
+
if cls == 0:
|
| 146 |
+
colours.append([1,0,0])
|
| 147 |
+
elif cls == 1:
|
| 148 |
+
colours.append([1,1,0])
|
| 149 |
+
elif cls == 2:
|
| 150 |
+
colours.append([0,0,0])
|
| 151 |
|
| 152 |
+
plot_server(f"plot_{idx}", r=r, v=v, colours=colours)
|
| 153 |
|
| 154 |
ui_output.append(
|
| 155 |
ui.div(
|