rslearn.models.dinov3¶
dinov3 ¶
DinoV3 model.
This code loads the DINOv3 model. You must obtain the model separately from Meta to use it. See https://github.com/facebookresearch/dinov3 for applicable license and copyright information.
DinoV3Models ¶
Bases: StrEnum
Names for different DinoV3 images on torch hub.
Source code in rslearn/models/dinov3.py
DinoV3 ¶
Bases: FeatureExtractor
DinoV3 Backbones.
Must have the pretrained weights downloaded in checkpoint_dir for them to be loaded. See https://github.com/facebookresearch/dinov3?tab=readme-ov-file#pretrained-models
Only takes RGB as input. Expects normalized data (use the below normalizer).
Uses patch size 16. The input is resized to 256x256; when applying DinoV3 on segmentation or detection tasks with inputs larger than 256x256, it may be best to train and predict on 256x256 crops (using SplitConfig.patch_size argument).
Source code in rslearn/models/dinov3.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
forward ¶
forward(context: ModelContext) -> FeatureMaps
Forward pass for the dinov3 model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
ModelContext
|
the model context. Input dicts must include "image" key. |
required |
Returns:
| Type | Description |
|---|---|
FeatureMaps
|
a FeatureMaps with one feature map. |
Source code in rslearn/models/dinov3.py
get_backbone_channels ¶
Returns the output channels of this model when used as a backbone.
The output channels is a list of (downsample_factor, depth) that corresponds to the feature maps that the backbone returns. For example, an element [2, 32] indicates that the corresponding feature map is 1/2 the input resolution and has 32 channels.
Source code in rslearn/models/dinov3.py
DinoV3Normalize ¶
Bases: Transform
Normalize inputs using DinoV3 normalization.
Normalize "image" key in input according to Dino statistics from pretraining. Satellite pretraining has slightly different normalizing than the base image model so set 'satellite' depending on what pretrained model you are using.
Input "image" should be RGB-like image between 0-255.
Source code in rslearn/models/dinov3.py
forward ¶
forward(input_dict: dict[str, Any], target_dict: dict[str, Any]) -> tuple[dict[str, Any], dict[str, Any]]
Normalize the specified image with DinoV3 normalization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dict
|
dict[str, Any]
|
the input dictionary. |
required |
target_dict
|
dict[str, Any]
|
the target dictionary. |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], dict[str, Any]]
|
normalized (input_dicts, target_dicts) tuple |