Pausing for now, train loop should now work and adding some tests
This commit is contained in:
@@ -28,9 +28,13 @@ def evaluate(model, data_loader, device):
|
||||
images = list(image.to(device) for image in images)
|
||||
targets = [{k: v.to(device) for k, v in t.items()} for t in targets]
|
||||
|
||||
# In eval mode with targets, Mask R-CNN should still return losses
|
||||
# If it returned predictions, logic here would change to process predictions
|
||||
# To handle the different behavior of Mask R-CNN in eval mode,
|
||||
# we explicitly reset the model to training mode to compute losses,
|
||||
# then switch back to eval mode for the rest of the evaluation
|
||||
model.train()
|
||||
loss_dict = model(images, targets)
|
||||
model.eval()
|
||||
|
||||
losses = sum(loss for loss in loss_dict.values())
|
||||
loss_value = losses.item()
|
||||
total_loss += loss_value
|
||||
|
||||
Reference in New Issue
Block a user