diff --git a/detect.py b/detect.py index ab7772b6..09b45994 100755 --- a/detect.py +++ b/detect.py @@ -33,7 +33,7 @@ def detect(opt): # Load model model = Darknet(opt.cfg, opt.img_size) - weights_path = 'checkpoints/yolov3.pt' + weights_path = 'weights/yolov3.pt' if weights_path.endswith('.weights'): # saved in darknet format load_weights(model, weights_path) else: # endswith('.pt'), saved in pytorch format diff --git a/test.py b/test.py index e8ca3163..1fe87a77 100644 --- a/test.py +++ b/test.py @@ -8,7 +8,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='weights/yolov3.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/train.py b/train.py index 5a746407..a1d8f7d1 100644 --- a/train.py +++ b/train.py @@ -28,7 +28,7 @@ if cuda: def main(opt): - os.makedirs('checkpoints', exist_ok=True) + os.makedirs('weights', exist_ok=True) # Configure run data_config = parse_data_config(opt.data_config_path) @@ -48,7 +48,7 @@ def main(opt): start_epoch = 0 best_loss = float('inf') if opt.resume: - checkpoint = torch.load('checkpoints/latest.pt', map_location='cpu') + checkpoint = torch.load('weights/latest.pt', map_location='cpu') model.load_state_dict(checkpoint['model']) if torch.cuda.device_count() > 1: @@ -175,15 +175,15 @@ def main(opt): 'best_loss': best_loss, 'model': model.state_dict(), 'optimizer': optimizer.state_dict()} - torch.save(checkpoint, 'checkpoints/latest.pt') + torch.save(checkpoint, 'weights/latest.pt') # Save best checkpoint if best_loss == loss_per_target: - os.system('cp checkpoints/latest.pt checkpoints/best.pt') + os.system('cp weights/latest.pt weights/best.pt') - # Save backup checkpoints every 5 epochs + # Save backup weights every 5 epochs if (epoch > 0) & (epoch % 5 == 0): - os.system('cp checkpoints/latest.pt checkpoints/backup' + str(epoch) + '.pt') + os.system('cp weights/latest.pt weights/backup' + str(epoch) + '.pt') # Save final model dt = time.time() - t0 diff --git a/utils/gcp.sh b/utils/gcp.sh index 559bcdb1..f4acdf6f 100644 --- a/utils/gcp.sh +++ b/utils/gcp.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Start -sudo rm -rf yolov3 && git clone https://github.com/ultralytics/yolov3 && cd yolov3 && python3 train.py -img_size 416 -epochs 160 +sudo rm -rf yolov3 && git clone https://github.com/ultralytics/yolov3 && cd yolov3 && python3 train.py -img_size 416 # Resume python3 train.py -img_size 416 -resume 1 diff --git a/utils/utils.py b/utils/utils.py index 8b525437..0f26542f 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -410,7 +410,7 @@ def non_max_suppression(prediction, conf_thres=0.5, nms_thres=0.4): return output -def strip_optimizer_from_checkpoint(filename='checkpoints/best.pt'): +def strip_optimizer_from_checkpoint(filename='weights/best.pt'): # Strip optimizer from *.pt files for lighter files (reduced by 2/3 size) import torch a = torch.load(filename, map_location='cpu') diff --git a/checkpoints/download_yolov3_weights.sh b/weights/download_yolov3_weights.sh similarity index 100% rename from checkpoints/download_yolov3_weights.sh rename to weights/download_yolov3_weights.sh