Add ComputeLoss() class (#1950)
This commit is contained in:
1 parent
f4a78e1b40
commit
ca9babb8e6
3 files changed
+118
-102
No files matched your search
@@ -13,7 +13,6 @@ from models.experimental import attempt_load
|
||||
from utils.datasets import create_dataloader
|
||||
from utils.general import coco80_to_coco91_class, check_dataset, check_file, check_img_size, check_requirements, \
|
||||
box_iou, non_max_suppression, scale_coords, xyxy2xywh, xywh2xyxy, set_logging, increment_path, colorstr
|
||||
from utils.loss import compute_loss
|
||||
from utils.metrics import ap_per_class, ConfusionMatrix
|
||||
from utils.plots import plot_images, output_to_target, plot_study_txt
|
||||
from utils.torch_utils import select_device, time_synchronized
|
||||
@@ -36,7 +35,8 @@ def test(data,
|
||||
save_hybrid=False, # for hybrid auto-labelling
|
||||
save_conf=False, # save auto-label confidences
|
||||
plots=True,
|
||||
log_imgs=0): # number of logged images
|
||||
log_imgs=0, # number of logged images
|
||||
compute_loss=None):
|
||||
|
||||
# Initialize/load model and set device
|
||||
training = model is not None
|
||||
@@ -111,8 +111,8 @@ def test(data,
|
||||
t0 += time_synchronized() - t
|
||||
|
||||
# Compute loss
|
||||
if training:
|
||||
loss += compute_loss([x.float() for x in train_out], targets, model)[1][:3] # box, obj, cls
|
||||
if compute_loss:
|
||||
loss += compute_loss([x.float() for x in train_out], targets)[1][:3] # box, obj, cls
|
||||
|
||||
# Run NMS
|
||||
targets[:, 2:] *= torch.Tensor([width, height, width, height]).to(device) # to pixels
|
||||
|
||||
Reference in new issue
Block a user