Add save_dir arg to test.test, use arg as location for saving batch jpgs
This commit is contained in:
1 parent
945307beba
commit
9b7386f603
2 files changed
+7
-5
No files matched your search
@@ -20,7 +20,8 @@ def test(data,
|
|||||||
model=None,
|
model=None,
|
||||||
dataloader=None,
|
dataloader=None,
|
||||||
fast=False,
|
fast=False,
|
||||||
verbose=False):
|
verbose=False,
|
||||||
|
save_dir='.'):
|
||||||
# Initialize/load model and set device
|
# Initialize/load model and set device
|
||||||
if model is None:
|
if model is None:
|
||||||
training = False
|
training = False
|
||||||
@@ -28,7 +29,7 @@ def test(data,
|
|||||||
half = device.type != 'cpu' # half precision only supported on CUDA
|
half = device.type != 'cpu' # half precision only supported on CUDA
|
||||||
|
|
||||||
# Remove previous
|
# Remove previous
|
||||||
for f in glob.glob('test_batch*.jpg'):
|
for f in glob.glob(f'{save_dir}/test_batch*.jpg'):
|
||||||
os.remove(f)
|
os.remove(f)
|
||||||
|
|
||||||
# Load model
|
# Load model
|
||||||
@@ -177,9 +178,9 @@ def test(data,
|
|||||||
|
|
||||||
# Plot images
|
# Plot images
|
||||||
if batch_i < 1:
|
if batch_i < 1:
|
||||||
f = 'test_batch%g_gt.jpg' % batch_i # filename
|
f = os.path.join(save_dir, 'test_batch%g_gt.jpg' % batch_i) # filename
|
||||||
plot_images(img, targets, paths, f, names) # ground truth
|
plot_images(img, targets, paths, f, names) # ground truth
|
||||||
f = 'test_batch%g_pred.jpg' % batch_i
|
f = os.path.join(save_dir,'test_batch%g_pred.jpg' % batch_i)
|
||||||
plot_images(img, output_to_target(output, width, height), paths, f, names) # predictions
|
plot_images(img, output_to_target(output, width, height), paths, f, names) # predictions
|
||||||
|
|
||||||
# Compute statistics
|
# Compute statistics
|
||||||
|
|||||||
@@ -303,7 +303,8 @@ def train(hyp):
|
|||||||
model=ema.ema,
|
model=ema.ema,
|
||||||
single_cls=opt.single_cls,
|
single_cls=opt.single_cls,
|
||||||
dataloader=testloader,
|
dataloader=testloader,
|
||||||
fast=epoch < epochs / 2)
|
fast=epoch < epochs / 2
|
||||||
|
save_dir=log_dir)
|
||||||
|
|
||||||
# Write
|
# Write
|
||||||
with open(results_file, 'a') as f:
|
with open(results_file, 'a') as f:
|
||||||
|
|||||||
Reference in new issue
Block a user