Pausing for now, train loop should now work and adding some tests

This commit is contained in:
Craig
2025-04-12 12:01:13 +01:00
parent 2b38c04a57
commit be70c4e160
13 changed files with 967 additions and 58 deletions

View File

@@ -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