if __name__ == '__main__': | if __name__ == '__main__': | ||||
parser = argparse.ArgumentParser(prog='test.py') | |||||
parser = argparse.ArgumentParser(prog='eval.py') | |||||
parser.add_argument('--weights', nargs='+', type=str, default='yolov5s.pt', help='model.pt path(s)') | parser.add_argument('--weights', nargs='+', type=str, default='yolov5s.pt', help='model.pt path(s)') | ||||
parser.add_argument('--data', type=str, default='data/coco128.yaml', help='*.data path') | parser.add_argument('--data', type=str, default='data/coco128.yaml', help='*.data path') | ||||
parser.add_argument('--batch-size', type=int, default=32, help='size of each image batch') | parser.add_argument('--batch-size', type=int, default=32, help='size of each image batch') |
import torch.utils.data | import torch.utils.data | ||||
from torch.utils.tensorboard import SummaryWriter | from torch.utils.tensorboard import SummaryWriter | ||||
import test # import test.py to get mAP after each epoch | |||||
import eval # import eval.py to get mAP after each epoch | |||||
from models.yolo import Model | from models.yolo import Model | ||||
from utils import google_utils | from utils import google_utils | ||||
from utils.datasets import * | from utils.datasets import * | ||||
ema.update_attr(model, include=['md', 'nc', 'hyp', 'gr', 'names', 'stride']) | ema.update_attr(model, include=['md', 'nc', 'hyp', 'gr', 'names', 'stride']) | ||||
final_epoch = epoch + 1 == epochs | final_epoch = epoch + 1 == epochs | ||||
if not opt.notest or final_epoch: # Calculate mAP | if not opt.notest or final_epoch: # Calculate mAP | ||||
results, maps, times = test.test(opt.data, | |||||
results, maps, times = eval.test(opt.data, | |||||
batch_size=batch_size, | batch_size=batch_size, | ||||
imgsz=imgsz_test, | imgsz=imgsz_test, | ||||
save_json=final_epoch and opt.data.endswith(os.sep + 'coco.yaml'), | save_json=final_epoch and opt.data.endswith(os.sep + 'coco.yaml'), |
def plot_study_txt(f='study.txt', x=None): # from utils.utils import *; plot_study_txt() | def plot_study_txt(f='study.txt', x=None): # from utils.utils import *; plot_study_txt() | ||||
# Plot study.txt generated by test.py | |||||
# Plot study.txt generated by eval.py | |||||
fig, ax = plt.subplots(2, 4, figsize=(10, 6), tight_layout=True) | fig, ax = plt.subplots(2, 4, figsize=(10, 6), tight_layout=True) | ||||
ax = ax.ravel() | ax = ax.ravel() | ||||