OWLViT<T>
Models & Types · AiDotNet.VisionLanguage.Grounding
OWL-ViT: open-vocabulary object detection via ViT + CLIP alignment.
Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → OWLViT<T>
Implements: IVisualGroundingModel<T>
For Beginners
OWL-ViT is a vision-language model that detects objects using text descriptions by leveraging CLIP’s vision-language alignment at the patch level. Default values follow the original paper settings.
How It Works
OWL-ViT (Minderer et al., 2022) repurposes a CLIP ViT image encoder for open-vocabulary detection by treating each patch token as a candidate object. Per-patch MLP heads predict bounding boxes, while class scores come from cosine similarity between patch tokens and CLIP text embeddings of category names. This is a query-free approach where every ViT patch serves as a candidate detection, eliminating the need for learned object queries.
References:
- Paper: “Simple Open-Vocabulary Object Detection with Vision Transformers” (Google, 2022)
Example
// Create an OWL-ViT model for open-vocabulary object detection
// using CLIP-aligned patch-level detection without learned queries
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.TwoDimensional,
taskType: NeuralNetworkTaskType.ImageClassification,
inputHeight: 224, inputWidth: 224, inputDepth: 3, outputSize: 512);
// ONNX inference mode with pre-trained model
var model = new OWLViT<double>(architecture, "owlvit.onnx");
// Training mode with native layers
var trainModel = new OWLViT<double>(architecture, new OWLViTOptions());
Constructors
| Constructor | Summary |
|---|---|
OWLViT(NeuralNetworkArchitecture<T> architecture, OWLViTOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) |
|
OWLViT(NeuralNetworkArchitecture<T> architecture, string modelPath, OWLViTOptions options) |
Properties
| Property | Summary |
|---|---|
int EmbeddingDimension { get; } |
|
int MaxDetections { get; } |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
|
Tensor<T> DetectObjects(Tensor<T> image, IReadOnlyList<string> categories) |
|
Tensor<T> EncodeImage(Tensor<T> image) |
|
Tensor<T> GroundText(Tensor<T> image, string textQuery) |
Grounds text using OWL-ViT’s CLIP-aligned patch-level detection approach. |