|
1 | 1 | # Copyright (C) 2025 Intel Corporation |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | | -"""Loader for DINOv2 Vision Transformer models. |
| 4 | +"""Loading pre-trained DINOv2 Vision Transformer models. |
5 | 5 |
|
6 | | -This module provides a simple interface for loading pre-trained DINOv2 Vision Transformer models for the |
7 | | -Dinomaly anomaly detection framework. |
| 6 | +This module provides the :class:`DinoV2Loader` class for constructing and loading |
| 7 | +pre-trained DINOv2 Vision Transformer models used in the Dinomaly anomaly detection |
| 8 | +framework. It supports both standard DINOv2 models and register-token variants, and |
| 9 | +allows custom Vision Transformer factories to be supplied. |
8 | 10 |
|
9 | 11 | Example: |
10 | | - model = DinoV2Loader.from_name("dinov2_vit_base_14") |
11 | | - model = DinoV2Loader.from_name("vit_base_14") |
12 | | - model = DinoV2Loader(vit_factory=my_custom_vit_module).load("dinov2reg_vit_base_14") |
| 12 | + >>> from anomalib.models.components.dinov2 import DinoV2Loader |
| 13 | + >>> loader = DinoV2Loader() |
| 14 | + >>> model = loader.load("dinov2_vit_base_14") |
| 15 | + >>> model = loader.load("vit_base_14") |
| 16 | + >>> custom_loader = DinoV2Loader(vit_factory=my_custom_vit_module) |
| 17 | + >>> model = custom_loader.load("dinov2reg_vit_base_14") |
| 18 | +
|
| 19 | +The DINOv2 loader handles: |
| 20 | +
|
| 21 | +- Parsing model names and validating architecture types |
| 22 | +- Constructing the appropriate Vision Transformer model |
| 23 | +- Locating or downloading the corresponding pre-trained weights |
| 24 | +- Supporting custom ViT implementations via a pluggable factory |
| 25 | +
|
| 26 | +This enables a simple, unified interface for accessing DINOv2-based backbones in |
| 27 | +downstream anomaly detection tasks. |
13 | 28 | """ |
14 | 29 |
|
15 | 30 | from __future__ import annotations |
|
0 commit comments