test/train jpg for png
This commit is contained in:
parent
992d8af242
commit
37cbe89ef0
4
test.py
4
test.py
|
@ -26,7 +26,7 @@ def test(cfg,
|
|||
verbose = opt.task == 'test'
|
||||
|
||||
# Remove previous
|
||||
for f in glob.glob('test_batch*.png'):
|
||||
for f in glob.glob('test_batch*.jpg'):
|
||||
os.remove(f)
|
||||
|
||||
# Initialize model
|
||||
|
@ -83,7 +83,7 @@ def test(cfg,
|
|||
whwh = torch.Tensor([width, height, width, height]).to(device)
|
||||
|
||||
# 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):
|
||||
plot_images(imgs=imgs, targets=targets, paths=paths, fname=f)
|
||||
|
||||
|
|
10
train.py
10
train.py
|
@ -53,6 +53,7 @@ if f:
|
|||
if hyp['fl_gamma']:
|
||||
print('Using FocalLoss(gamma=%g)' % hyp['fl_gamma'])
|
||||
|
||||
|
||||
def train():
|
||||
cfg = opt.cfg
|
||||
data = opt.data
|
||||
|
@ -83,7 +84,7 @@ def train():
|
|||
hyp['cls'] *= nc / 80 # update coco-tuned hyp['cls'] to current dataset
|
||||
|
||||
# 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)
|
||||
|
||||
# Initialize model
|
||||
|
@ -149,7 +150,7 @@ def train():
|
|||
# Scheduler https://arxiv.org/pdf/1812.01187.pdf
|
||||
lf = lambda x: (((1 + math.cos(x * math.pi / epochs)) / 2) ** 1.0) * 0.95 + 0.05 # cosine
|
||||
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf)
|
||||
scheduler.last_epoch=start_epoch - 1 # see link below
|
||||
scheduler.last_epoch = start_epoch - 1 # see link below
|
||||
# https://discuss.pytorch.org/t/a-problem-occured-when-resuming-an-optimizer/28822
|
||||
|
||||
# Plot lr schedule
|
||||
|
@ -289,7 +290,7 @@ def train():
|
|||
|
||||
# Plot
|
||||
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)
|
||||
if tb_writer:
|
||||
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('--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('--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('--resume', action='store_true', help='resume training from last.pt')
|
||||
parser.add_argument('--nosave', action='store_true', help='only save final checkpoint')
|
||||
|
|
Loading…
Reference in New Issue