diff --git a/models.py b/models.py index ca5f07d2..2bb8719b 100755 --- a/models.py +++ b/models.py @@ -170,8 +170,8 @@ class YOLOLayer(nn.Module): # lconf = k * BCEWithLogitsLoss(pred_conf[mask], mask[mask].float()) lconf = k * BCEWithLogitsLoss(pred_conf, mask.float()) - lcls = k * CrossEntropyLoss(pred_cls[mask], torch.argmax(tcls, 1)) - # lcls = k * BCEWithLogitsLoss(pred_cls[mask], tcls.float()) + # lcls = k * CrossEntropyLoss(pred_cls[mask], torch.argmax(tcls, 1)) + lcls = k * BCEWithLogitsLoss(pred_cls[mask], tcls.float()) else: lx, ly, lw, lh, lcls, lconf = FT([0]), FT([0]), FT([0]), FT([0]), FT([0]), FT([0]) diff --git a/test.py b/test.py index b88faf0a..5ab46bb8 100644 --- a/test.py +++ b/test.py @@ -7,7 +7,7 @@ parser = argparse.ArgumentParser() parser.add_argument('-batch_size', type=int, default=32, help='size of each image batch') parser.add_argument('-cfg', type=str, default='cfg/yolov3.cfg', help='path to model config file') parser.add_argument('-data_config_path', type=str, default='cfg/coco.data', help='path to data config file') -parser.add_argument('-weights_path', type=str, default='checkpoints/yolov3.pt', help='path to weights file') +parser.add_argument('-weights_path', type=str, default='checkpoints/latest.pt', help='path to weights file') parser.add_argument('-class_path', type=str, default='data/coco.names', help='path to class label file') parser.add_argument('-iou_thres', type=float, default=0.5, help='iou threshold required to qualify as detected') parser.add_argument('-conf_thres', type=float, default=0.5, help='object confidence threshold') diff --git a/utils/utils.py b/utils/utils.py index 08692c5f..4c677dfa 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -264,8 +264,8 @@ def build_targets(pred_boxes, pred_conf, pred_cls, target, anchor_wh, nA, nC, nG ty[b, a, gj, gi] = gy - gj.float() # Width and height (yolo method) - tw[b, a, gj, gi] = torch.log(gw / anchor_wh[a, 0] + 1e-16) - th[b, a, gj, gi] = torch.log(gh / anchor_wh[a, 1] + 1e-16) + tw[b, a, gj, gi] = torch.log(gw / anchor_wh[a, 0]) + th[b, a, gj, gi] = torch.log(gh / anchor_wh[a, 1]) # Width and height (power method) # tw[b, a, gj, gi] = torch.sqrt(gw / anchor_wh[a, 0]) / 2