ClipModelLoader

Helpers & Utilities · AiDotNet.NeuralNetworks

Loads CLIP models from HuggingFace Hub or local directories.

For Beginners

Instead of manually downloading files, this loader automatically fetches CLIP models from HuggingFace Hub:

The model files are cached locally so subsequent loads are fast.

How It Works

This loader handles downloading and caching CLIP model files from HuggingFace, including ONNX model files for image and text encoders, tokenizer files, and model configuration.

Methods

Method Summary
ClipNeuralNetwork<T> FromDirectory(string modelPath, ClipModelConfig config) Loads a CLIP model from a local directory.
ClipNeuralNetwork<T> FromPretrained(string modelId, string cacheDir) Loads a CLIP model from HuggingFace Hub synchronously.
Task<ClipNeuralNetwork<T>> FromPretrainedAsync(string modelId, string cacheDir, IProgress<double> progress, CancellationToken cancellationToken) Loads a CLIP model from HuggingFace Hub asynchronously.
bool IsModelCached(string modelId, string cacheDir) Checks if a model is downloaded and cached locally.
void ClearCache(string modelId, string cacheDir) Clears the cached model files.

Fields

Field Summary
IReadOnlyDictionary<string, ClipModelConfig> KnownModels Known CLIP model configurations on HuggingFace Hub.