fovi.models.dinov3

fovi.models.dinov3.configure_dinov3_positions(model: Module, *, sensor_coords: SamplingCoords, patch_size: int, position_coordinate_space: str | None = None) → None[source]

Configure dense DINO RoPE using a Fovi sensor’s native or visual positions.

Parameters:
  • model – Loaded Hugging Face DINOv3 model with its dense patch embedding.

  • sensor_coords – Full-resolution grid sensor, before patch embedding.

  • patch_size – Square convolutional patch size in sensor pixels.

  • position_coordinate_space – cortical for ordinary image positions or cartesian for visual-field patch positions. None preserves saved model metadata, or selects cortical for an ordinary pretrained model.

The resolved setting and sensor parameters are saved in the model config. No model weights or patch convolution are changed by this function.

fovi.models.dinov3.load_dinov3(path, device='cuda', pretrained=True)[source]

Load a DinoV3 model and processor from Hugging Face.

Requires HF_TOKEN environment variable to be set for gated models.

Parameters:
  • path (str) – Path or model identifier for the DinoV3 model.

  • device (str, optional) – Device to load the model on. Defaults to ‘cuda’.

Returns:

A tuple containing (model, processor).

Return type:

tuple

fovi.models.dinov3.build_fovi_dinov3(cfg, device='cuda')[source]

Build a foveated DinoV3 model from configuration.

Parameters:
  • cfg – Configuration object containing model and training parameters.

  • device (str, optional) – Device to build the model on. Defaults to ‘cuda’.

Returns:

The configured DinoV3 model.

Return type:

torch.nn.Module

fovi.models.dinov3.prep_fovi_dinov3_finetuning(model, cfg, device='cuda', key='pretrained_model')[source]

Prepare a DinoV3 model for fine-tuning based on configuration.

Parameters:
  • model – The DinoV3 model to prepare.

  • cfg – Configuration object containing fine-tuning parameters.

  • device (str, optional) – Device to prepare the model on. Defaults to ‘cuda’.

  • key (str) – which key of the config to look for finetuning strategies

Returns:

The prepared model with appropriate parameters frozen/unfrozen.

Return type:

torch.nn.Module