Spaces:
Runtime error
Runtime error
Upload utils.py
Browse files- model/utils.py +21 -22
model/utils.py
CHANGED
|
@@ -155,28 +155,27 @@ def plot_bev_detections(
|
|
| 155 |
# 5) Draw each box
|
| 156 |
seen_labels = set()
|
| 157 |
for box, score, label in zip(boxes, scores, labels):
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
seen_labels.add(cls_idx)
|
| 180 |
|
| 181 |
# 6) Legend only for seen classes
|
| 182 |
legend_handles = []
|
|
|
|
| 155 |
# 5) Draw each box
|
| 156 |
seen_labels = set()
|
| 157 |
for box, score, label in zip(boxes, scores, labels):
|
| 158 |
+
x, y, z, dx, dy, dz, yaw, *_ = box.cpu().numpy()
|
| 159 |
+
cls_idx = int(label)
|
| 160 |
+
cls_name = class_names[cls_idx]
|
| 161 |
+
color = colors[cls_idx]
|
| 162 |
+
|
| 163 |
+
# example of stretching length for 'car' if you still want it
|
| 164 |
+
if cls_name.lower() == 'car':
|
| 165 |
+
dx *= 1.2
|
| 166 |
+
|
| 167 |
+
rect = patches.Rectangle(
|
| 168 |
+
(x - dx/2, y - dy/2),
|
| 169 |
+
dx, dy,
|
| 170 |
+
angle=np.degrees(yaw),
|
| 171 |
+
linewidth=1.5,
|
| 172 |
+
edgecolor=color,
|
| 173 |
+
facecolor='none'
|
| 174 |
+
)
|
| 175 |
+
ax.add_patch(rect)
|
| 176 |
+
|
| 177 |
+
# remember we saw this label so we can add it to legend once
|
| 178 |
+
seen_labels.add(cls_idx)
|
|
|
|
| 179 |
|
| 180 |
# 6) Legend only for seen classes
|
| 181 |
legend_handles = []
|