training_step_adapter
orchard.tasks.detection.training_step_adapter
¶
Detection Training Step Adapter.
Wraps the detection forward pass (model returns loss dict) to satisfy
:class:~orchard.core.task_protocols.TaskTrainingStep.
Detection models like Faster R-CNN expect list[Tensor] images and
list[dict] targets in training mode, and return a dict of losses
that must be summed for backpropagation.
DetectionTrainingStepAdapter
¶
Computes detection training loss by summing model-internal losses.
compute_training_loss(model, inputs, targets, criterion, mixup_fn=None, device=None)
¶
Execute detection forward pass and compute total loss.
Moves images and target dicts to device, calls the model in training mode (which returns a loss dict), and sums all loss components into a single scalar for backpropagation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Detection model (e.g. Faster R-CNN) in training mode. |
required |
inputs
|
Any
|
List of image tensors, one per image in the batch. |
required |
targets
|
Any
|
List of target dicts, each with |
required |
criterion
|
Module
|
Ignored (detection models compute losses internally). |
required |
mixup_fn
|
Callable[..., Any] | None
|
Ignored (MixUp is not applicable to detection). |
None
|
device
|
device | None
|
Target device for tensor placement. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Scalar loss tensor (sum of all loss components). |