Targets scaling bug fix (#1529)
This commit is contained in:
1 parent
2c3efa430b
commit
0f2057ed33
2 files changed
+9
-8
No files matched your search
@@ -15,7 +15,7 @@ from utils.general import coco80_to_coco91_class, check_dataset, check_file, che
|
||||
non_max_suppression, scale_coords, xyxy2xywh, xywh2xyxy, set_logging, increment_path
|
||||
from utils.loss import compute_loss
|
||||
from utils.metrics import ap_per_class, ConfusionMatrix
|
||||
from utils.plots import plot_images, output_to_target
|
||||
from utils.plots import plot_images, output_to_target, plot_study_txt
|
||||
from utils.torch_utils import select_device, time_synchronized
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ def test(data,
|
||||
img /= 255.0 # 0 - 255 to 0.0 - 1.0
|
||||
targets = targets.to(device)
|
||||
nb, _, height, width = img.shape # batch size, channels, height, width
|
||||
targets[:, 2:] *= torch.Tensor([width, height, width, height]).to(device)
|
||||
|
||||
with torch.no_grad():
|
||||
# Run model
|
||||
@@ -115,8 +114,9 @@ def test(data,
|
||||
loss += compute_loss([x.float() for x in train_out], targets, model)[1][:3] # box, obj, cls
|
||||
|
||||
# Run NMS
|
||||
t = time_synchronized()
|
||||
targets[:, 2:] *= torch.Tensor([width, height, width, height]).to(device) # to pixels
|
||||
lb = [targets[targets[:, 0] == i, 1:] for i in range(nb)] if save_txt else [] # for autolabelling
|
||||
t = time_synchronized()
|
||||
output = non_max_suppression(inf_out, conf_thres=conf_thres, iou_thres=iou_thres, labels=lb)
|
||||
t1 += time_synchronized() - t
|
||||
|
||||
@@ -324,8 +324,9 @@ if __name__ == '__main__':
|
||||
y = [] # y axis
|
||||
for i in x: # img-size
|
||||
print('\nRunning %s point %s...' % (f, i))
|
||||
r, _, t = test(opt.data, weights, opt.batch_size, i, opt.conf_thres, opt.iou_thres, opt.save_json)
|
||||
r, _, t = test(opt.data, weights, opt.batch_size, i, opt.conf_thres, opt.iou_thres, opt.save_json,
|
||||
plots=False)
|
||||
y.append(r + t) # results and times
|
||||
np.savetxt(f, y, fmt='%10.4g') # save
|
||||
os.system('zip -r study.zip study_*.txt')
|
||||
# utils.plots.plot_study_txt(f, x) # plot
|
||||
plot_study_txt(f, x) # plot
|
||||
Reference in new issue
Block a user