Fix indentation in `log_training_progress()` (#4126)
Browse files
utils/wandb_logging/wandb_utils.py
CHANGED
@@ -293,26 +293,26 @@ class WandbLogger():
|
|
293 |
return artifact
|
294 |
|
295 |
def log_training_progress(self, predn, path, names):
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
|
317 |
def val_one_image(self, pred, predn, path, names, im):
|
318 |
if self.val_table and self.result_table: # Log Table if Val dataset is uploaded as artifact
|
|
|
293 |
return artifact
|
294 |
|
295 |
def log_training_progress(self, predn, path, names):
|
296 |
+
class_set = wandb.Classes([{'id': id, 'name': name} for id, name in names.items()])
|
297 |
+
box_data = []
|
298 |
+
total_conf = 0
|
299 |
+
for *xyxy, conf, cls in predn.tolist():
|
300 |
+
if conf >= 0.25:
|
301 |
+
box_data.append(
|
302 |
+
{"position": {"minX": xyxy[0], "minY": xyxy[1], "maxX": xyxy[2], "maxY": xyxy[3]},
|
303 |
+
"class_id": int(cls),
|
304 |
+
"box_caption": "%s %.3f" % (names[cls], conf),
|
305 |
+
"scores": {"class_score": conf},
|
306 |
+
"domain": "pixel"})
|
307 |
+
total_conf = total_conf + conf
|
308 |
+
boxes = {"predictions": {"box_data": box_data, "class_labels": names}} # inference-space
|
309 |
+
id = self.val_table_path_map[Path(path).name]
|
310 |
+
self.result_table.add_data(self.current_epoch,
|
311 |
+
id,
|
312 |
+
self.val_table.data[id][1],
|
313 |
+
wandb.Image(self.val_table.data[id][1], boxes=boxes, classes=class_set),
|
314 |
+
total_conf / max(1, len(box_data))
|
315 |
+
)
|
316 |
|
317 |
def val_one_image(self, pred, predn, path, names, im):
|
318 |
if self.val_table and self.result_table: # Log Table if Val dataset is uploaded as artifact
|