fovi.arch.wrapper

class fovi.arch.wrapper.BackboneProjectorWrapper(backbone, projector, projector_ssl=None)[source]

Bases: Module

Wrapper for backbone models with optional projection heads.

Includes support for self-supervised learning projections

Parameters:
  • backbone (nn.Module) – The main backbone.

  • projector (nn.Module) – Projection head for downstream tasks.

  • projector_ssl (nn.Module, optional) – Projection head for self-supervised learning.

__init__(backbone, projector, projector_ssl=None)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x, return_layer_outputs=False, apply_mlp=True)[source]
Parameters:
  • x (torch.Tensor) – Input tensor.

  • return_layer_outputs (bool) – Whether to return intermediate layer outputs.

  • apply_mlp (bool) – Whether to apply the projection head.

Returns:

Output features and optionally layer outputs.

Return type:

torch.Tensor or tuple