glenn-jocher
commited on
Commit
•
c3d3e6b
1
Parent(s):
cbe39a1
Update test.py
Browse files
test.py
CHANGED
@@ -18,8 +18,7 @@ def test(data,
|
|
18 |
verbose=False,
|
19 |
model=None,
|
20 |
dataloader=None,
|
21 |
-
|
22 |
-
save_dir='.',
|
23 |
merge=False):
|
24 |
|
25 |
# Initialize/load model and set device
|
@@ -29,7 +28,7 @@ def test(data,
|
|
29 |
device = torch_utils.select_device(opt.device, batch_size=batch_size)
|
30 |
|
31 |
# Remove previous
|
32 |
-
for f in glob.glob(
|
33 |
os.remove(f)
|
34 |
|
35 |
# Load model
|
@@ -163,10 +162,11 @@ def test(data,
|
|
163 |
|
164 |
# Plot images
|
165 |
if batch_i < 1:
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
170 |
|
171 |
# Compute statistics
|
172 |
stats = [np.concatenate(x, 0) for x in zip(*stats)] # to numpy
|
|
|
18 |
verbose=False,
|
19 |
model=None,
|
20 |
dataloader=None,
|
21 |
+
save_dir='',
|
|
|
22 |
merge=False):
|
23 |
|
24 |
# Initialize/load model and set device
|
|
|
28 |
device = torch_utils.select_device(opt.device, batch_size=batch_size)
|
29 |
|
30 |
# Remove previous
|
31 |
+
for f in glob.glob(str(Path(save_dir) / 'test_batch*.jpg')):
|
32 |
os.remove(f)
|
33 |
|
34 |
# Load model
|
|
|
162 |
|
163 |
# Plot images
|
164 |
if batch_i < 1:
|
165 |
+
|
166 |
+
f = Path(save_dir) / ('test_batch%g_gt.jpg' % batch_i) # filename
|
167 |
+
plot_images(img, targets, paths, str(f), names) # ground truth
|
168 |
+
f = Path(save_dir) / ('test_batch%g_pred.jpg' % batch_i)
|
169 |
+
plot_images(img, output_to_target(output, width, height), paths, str(f), names) # predictions
|
170 |
|
171 |
# Compute statistics
|
172 |
stats = [np.concatenate(x, 0) for x in zip(*stats)] # to numpy
|