diff --git a/README.md b/README.md index 83fbf691..b0b73bf2 100755 --- a/README.md +++ b/README.md @@ -45,7 +45,10 @@ HS**V** Intensity | +/- 50% # Inference -Checkpoints are saved in `/checkpoints` directory. Run `detect.py` to apply trained weights to an image, such as `zidane.jpg` from the `data/samples` folder, shown here. +Checkpoints are saved in `/checkpoints` directory. Run `detect.py` to apply trained weights to an image, such as `zidane.jpg` from the `data/samples` folder, shown here. Alternatively you can use the official YOLOv3 weights: + +-PyTorch format: https://storage.googleapis.com/ultralytics/yolov3.pt +-darknet format: https://pjreddie.com/media/files/yolov3.weights ![Alt](https://github.com/ultralytics/yolov3/blob/master/data/zidane_result.jpg "inference example") diff --git a/train.py b/train.py index 27074389..514195c2 100644 --- a/train.py +++ b/train.py @@ -68,7 +68,7 @@ def main(opt): # optimizer = torch.optim.SGD(model.parameters(), lr=.001, momentum=.9, weight_decay=5e-4, nesterov=True) # optimizer = torch.optim.Adam(filter(lambda p: p.requires_grad, model.parameters())) optimizer = torch.optim.Adam(model.parameters()) - optimizer.load_state_dict(checkpoint['optimizer']) + #optimizer.load_state_dict(checkpoint['optimizer']) start_epoch = checkpoint['epoch'] + 1 best_loss = checkpoint['best_loss'] @@ -79,6 +79,7 @@ def main(opt): print('Using ', torch.cuda.device_count(), ' GPUs') model = nn.DataParallel(model) model.to(device).train() + # optimizer = torch.optim.SGD(model.parameters(), lr=1e-4, momentum=.9, weight_decay=5e-4) optimizer = torch.optim.Adam(filter(lambda p: p.requires_grad, model.parameters()), lr=1e-4, weight_decay=5e-4) # Set scheduler diff --git a/utils/gcp.sh b/utils/gcp.sh index 71e790d8..2c9da943 100644 --- a/utils/gcp.sh +++ b/utils/gcp.sh @@ -4,9 +4,11 @@ sudo rm -rf yolov3 && git clone https://github.com/ultralytics/yolov3 && cd yolov3 && python3 train.py -img_size 416 -epochs 160 # Resume -cd yolov3 && python3 train.py -img_size 416 -resume 1 +python3 train.py -img_size 416 -resume 1 # Detect gsutil cp gs://ultralytics/fresh9_5_e201.pt yolov3/checkpoints -cd yolov3 && python3 detect.py +python3 detect.py +# Test +python3 test.py -img_size 416 -weights_path checkpoints/latest.pt diff --git a/utils/utils.py b/utils/utils.py index 17b8f9bd..abd42c76 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -367,11 +367,11 @@ def plotResults(): import matplotlib.pyplot as plt plt.figure(figsize=(16, 8)) s = ['X', 'Y', 'Width', 'Height', 'Objectness', 'Classification', 'Total Loss', 'Precision', 'Recall'] - for f in ('/Users/glennjocher/Downloads/results.txt', - '/Users/glennjocher/Downloads/resultsBCE.txt'): + for f in ('/Users/glennjocher/Downloads/results_CE.txt', + '/Users/glennjocher/Downloads/results_BCE.txt'): results = np.loadtxt(f, usecols=[2, 3, 4, 5, 6, 7, 8, 9, 10]).T for i in range(9): plt.subplot(2, 5, i + 1) - plt.plot(results[i, :], marker='.', label=f) + plt.plot(results[i, :19], marker='.', label=f) plt.title(s[i]) - plt.legend() + plt.legend \ No newline at end of file