RegionCLIP<T>

Models & Types · AiDotNet.VisionLanguage.Encoders

RegionCLIP model extending CLIP to learn region-level (object-level) visual representations.

Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → RegionCLIP<T>

Implements: IContrastiveVisionLanguageModel<T>

For Beginners

RegionCLIP extends CLIP from whole-image understanding to individual object regions within images. While CLIP matches an entire image to text, RegionCLIP learns to match specific regions (bounding boxes) to text descriptions, enabling zero-shot object detection — finding objects in images by describing them in natural language. Default values follow the original paper settings.

How It Works

RegionCLIP (Zhong et al., CVPR 2022) generates region-text pairs from image captions using object proposals and learns to align individual image regions with text descriptions, enabling zero-shot and open-vocabulary object detection.

References:

  • Paper: “RegionCLIP: Region-based Language-Image Pretraining” (Zhong et al., CVPR 2022)

Example

var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.TwoDimensional,
    taskType: NeuralNetworkTaskType.ImageClassification,
    inputHeight: 224, inputWidth: 224, inputDepth: 3, outputSize: 512);
var trainModel = new RegionCLIP<double>(architecture, new RegionCLIPOptions());

Constructors

Constructor Summary
RegionCLIP(NeuralNetworkArchitecture<T> architecture, RegionCLIPOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
RegionCLIP(NeuralNetworkArchitecture<T> architecture, string imageEncoderModelPath, RegionCLIPOptions options)

Properties

Property Summary
T Temperature { get; }
int EmbeddingDimension { get; }
int MaxSequenceLength { get; }
int ProjectionDimension { get; }
int TextEmbeddingDimension { get; }

Methods

Method Summary
Dictionary<string, T> ZeroShotClassify(Tensor<T> image, string[] labels)
ModelMetadata<T> GetModelMetadata()
T ComputeSimilarity(Tensor<T> image, string text)
Tensor<T> EncodeImage(Tensor<T> image)
Tensor<T> EncodeText(string text)
Tensor<T>[] EncodeTexts(string[] texts)