test/train jpg for png

This commit is contained in:
Glenn Jocher 2020-04-28 13:45:27 -07:00
parent 992d8af242
commit 37cbe89ef0
2 changed files with 8 additions and 6 deletions

View File

@ -26,7 +26,7 @@ def test(cfg,
verbose = opt.task == 'test' verbose = opt.task == 'test'
# Remove previous # Remove previous
for f in glob.glob('test_batch*.png'): for f in glob.glob('test_batch*.jpg'):
os.remove(f) os.remove(f)
# Initialize model # Initialize model
@ -83,7 +83,7 @@ def test(cfg,
whwh = torch.Tensor([width, height, width, height]).to(device) whwh = torch.Tensor([width, height, width, height]).to(device)
# Plot images with bounding boxes # Plot images with bounding boxes
f = 'test_batch%g.png' % batch_i # filename f = 'test_batch%g.jpg' % batch_i # filename
if batch_i < 1 and not os.path.exists(f): if batch_i < 1 and not os.path.exists(f):
plot_images(imgs=imgs, targets=targets, paths=paths, fname=f) plot_images(imgs=imgs, targets=targets, paths=paths, fname=f)

View File

@ -53,6 +53,7 @@ if f:
if hyp['fl_gamma']: if hyp['fl_gamma']:
print('Using FocalLoss(gamma=%g)' % hyp['fl_gamma']) print('Using FocalLoss(gamma=%g)' % hyp['fl_gamma'])
def train(): def train():
cfg = opt.cfg cfg = opt.cfg
data = opt.data data = opt.data
@ -83,7 +84,7 @@ def train():
hyp['cls'] *= nc / 80 # update coco-tuned hyp['cls'] to current dataset hyp['cls'] *= nc / 80 # update coco-tuned hyp['cls'] to current dataset
# Remove previous results # Remove previous results
for f in glob.glob('*_batch*.png') + glob.glob(results_file): for f in glob.glob('*_batch*.jpg') + glob.glob(results_file):
os.remove(f) os.remove(f)
# Initialize model # Initialize model
@ -289,7 +290,7 @@ def train():
# Plot # Plot
if ni < 1: if ni < 1:
f = 'train_batch%g.png' % i # filename f = 'train_batch%g.jpg' % i # filename
plot_images(imgs=imgs, targets=targets, paths=paths, fname=f) plot_images(imgs=imgs, targets=targets, paths=paths, fname=f)
if tb_writer: if tb_writer:
tb_writer.add_image(f, cv2.imread(f)[:, :, ::-1], dataformats='HWC') tb_writer.add_image(f, cv2.imread(f)[:, :, ::-1], dataformats='HWC')
@ -388,7 +389,8 @@ if __name__ == '__main__':
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='*.cfg path') parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='*.cfg path')
parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data path') parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data path')
parser.add_argument('--multi-scale', action='store_true', help='adjust (67%% - 150%%) img_size every 10 batches') parser.add_argument('--multi-scale', action='store_true', help='adjust (67%% - 150%%) img_size every 10 batches')
parser.add_argument('--img-size', nargs='+', type=int, default=[320, 640], help='[min_train, max-train, test] img sizes') parser.add_argument('--img-size', nargs='+', type=int, default=[320, 640],
help='[min_train, max-train, test] img sizes')
parser.add_argument('--rect', action='store_true', help='rectangular training') parser.add_argument('--rect', action='store_true', help='rectangular training')
parser.add_argument('--resume', action='store_true', help='resume training from last.pt') parser.add_argument('--resume', action='store_true', help='resume training from last.pt')
parser.add_argument('--nosave', action='store_true', help='only save final checkpoint') parser.add_argument('--nosave', action='store_true', help='only save final checkpoint')