synthval.features_extraction.DinoV2FeatureExtractor#
- class synthval.features_extraction.DinoV2FeatureExtractor(model_id)#
Bases:
FeatureExtractorFeature extractor using models from the HuggingFace DinoV2 family (https://huggingface.co/collections/facebook/dinov2-6526c98554b3d2576e071ce3).
Note: As of December 16, 2024, Dino models utilize the operator aten::upsample_bicubic2d.out, which is not currently supported on the MPS backend. To use these models as feature extractors on MPS, users must set the environment variable PYTORCH_ENABLE_MPS_FALLBACK to 1.
- Parameters:
model_id (str)
- batch_feature_extraction(images)#
Extract features from a batch of images using the HuggingFace DinoV2 model.
- Parameters:
images (List[PIL.Image.Image]) – List of PIL images to extract features from.
- Returns:
A NumPy array where each row corresponds to the feature vector of an image.
- Return type:
numpy.ndarray