Browse Source

W&B feature improvements (#1258)

* W&B feature improvements

This PR add:
* Class to id labels. Now, the caption of bounding boxes will display the class name and the class confidence score.
* The project name is set to "Yolov5" and the run name will be set to opt.logdir

* cleanup

* remove parenthesis on caption

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
5.0
Ayush Chaurasia GitHub 4 years ago
parent
commit
96fcde40b8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions
  1. +8
    -6
      test.py
  2. +1
    -1
      train.py

+ 8
- 6
test.py View File

hyp=None, augment=False, cache=False, pad=0.5, rect=True)[0] hyp=None, augment=False, cache=False, pad=0.5, rect=True)[0]


seen = 0 seen = 0
names = model.names if hasattr(model, 'names') else model.module.names
names = {k: v for k, v in enumerate(model.names if hasattr(model, 'names') else model.module.names)}
coco91class = coco80_to_coco91_class() coco91class = coco80_to_coco91_class()
s = ('%20s' + '%12s' * 6) % ('Class', 'Images', 'Targets', 'P', 'R', 'mAP@.5', 'mAP@.5:.95') s = ('%20s' + '%12s' * 6) % ('Class', 'Images', 'Targets', 'P', 'R', 'mAP@.5', 'mAP@.5:.95')
p, r, f1, mp, mr, map50, map, t0, t1 = 0., 0., 0., 0., 0., 0., 0., 0., 0. p, r, f1, mp, mr, map50, map, t0, t1 = 0., 0., 0., 0., 0., 0., 0., 0., 0.


# W&B logging # W&B logging
if len(wandb_images) < log_imgs: if len(wandb_images) < log_imgs:
bbox_data = [{"position": {"minX": xyxy[0], "minY": xyxy[1], "maxX": xyxy[2], "maxY": xyxy[3]},
"class_id": int(cls),
"scores": {"class_score": conf},
"domain": "pixel"} for *xyxy, conf, cls in pred.clone().tolist()]
wandb_images.append(wandb.Image(img[si], boxes={"predictions": {"box_data": bbox_data}}))
box_data = [{"position": {"minX": xyxy[0], "minY": xyxy[1], "maxX": xyxy[2], "maxY": xyxy[3]},
"class_id": int(cls),
"box_caption": "%s %.3f" % (names[cls], conf),
"scores": {"class_score": conf},
"domain": "pixel"} for *xyxy, conf, cls in pred.clone().tolist()]
boxes = {"predictions": {"box_data": box_data, "class_labels": names}}
wandb_images.append(wandb.Image(img[si], boxes=boxes))


# Clip boxes to image bounds # Clip boxes to image bounds
clip_coords(pred, (height, width)) clip_coords(pred, (height, width))

+ 1
- 1
train.py View File

# Logging # Logging
if wandb and wandb.run is None: if wandb and wandb.run is None:
id = ckpt.get('wandb_id') if 'ckpt' in locals() else None id = ckpt.get('wandb_id') if 'ckpt' in locals() else None
wandb_run = wandb.init(config=opt, resume="allow", project=os.path.basename(log_dir), id=id)
wandb_run = wandb.init(config=opt, resume="allow", project="YOLOv5", name=os.path.basename(log_dir), id=id)


# Resume # Resume
start_epoch, best_fitness = 0, 0.0 start_epoch, best_fitness = 0, 0.0

Loading…
Cancel
Save