Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,7 @@ import pandas as pd
|
|
| 18 |
import matplotlib.pyplot as plt
|
| 19 |
from PIL import Image
|
| 20 |
from shiny import App, ui, render, reactive, Session
|
|
|
|
| 21 |
|
| 22 |
from python_utils import load_model
|
| 23 |
# Load data and compute static values
|
|
@@ -105,7 +106,18 @@ def server(input, output, session: Session):
|
|
| 105 |
@render.plot
|
| 106 |
def plot_predicitons():
|
| 107 |
fig, ax = plt.subplots()
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
return fig
|
| 110 |
|
| 111 |
output.append(
|
|
|
|
| 18 |
import matplotlib.pyplot as plt
|
| 19 |
from PIL import Image
|
| 20 |
from shiny import App, ui, render, reactive, Session
|
| 21 |
+
from detectron2.utils.visualizer import Visualizer, ColorMode
|
| 22 |
|
| 23 |
from python_utils import load_model
|
| 24 |
# Load data and compute static values
|
|
|
|
| 106 |
@render.plot
|
| 107 |
def plot_predicitons():
|
| 108 |
fig, ax = plt.subplots()
|
| 109 |
+
|
| 110 |
+
v = Visualizer(r["image"[:, :, ::-1],
|
| 111 |
+
{"thing_classes": ['Seed', 'Viable', 'Non-Viable', 'Empty'],
|
| 112 |
+
"thing_colors": [(0, 0, 0), (0, 255, 0), (255, 0, 0), (0, 0, 255)]},
|
| 113 |
+
scale=1.2, instance_mode=ColorMode.SEGMENTATION, font_size_scale=1.5)
|
| 114 |
+
out = v.draw_instance_predictions(results["instances"].to("cpu"), jittering=False)
|
| 115 |
+
ax.imshow(cv2.cvtColor(out.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
|
| 116 |
+
|
| 117 |
+
ax = plt.Axes(fig, [0., 0., 1., 1.])
|
| 118 |
+
ax.set_axis_off()
|
| 119 |
+
fig.add_axes(ax)
|
| 120 |
+
|
| 121 |
return fig
|
| 122 |
|
| 123 |
output.append(
|