API reference · Kjarni 0.2.7
Class ImageIndex
Namespace: Kjarni
Assembly: Kjarni.dll
Photos searched by description, with CLIP. Searching is safe from several threads; adding is not.
public class ImageIndex : IDisposable
Inheritance
Implements
Examples
using var index = new ImageIndex();
index.AddDirectory("~/Pictures");
foreach (var hit in index.Search("a dog on a beach", 5))
Console.WriteLine(hit.Path);
Constructors
ImageIndex(string?)
Load a CLIP model.
public ImageIndex(string? modelDir = null)
Parameters
modelDir string?
A CLIP model directory; null uses clip-vit-base-32, downloaded on first use.
Properties
Count
Number of images indexed.
public int Count { get; }
Property Value
Methods
Add(string)
Index one JPEG or PNG.
public void Add(string path)
Parameters
path string
AddDirectory(string)
Index every JPEG and PNG under dir.
public ScanReport AddDirectory(string dir)
Parameters
dir string
Returns
Dispose()
Releases the native model. The object cannot be used afterwards.
public void Dispose()
~ImageIndex()
Releases the native model if
protected ~ImageIndex()
Load(string)
Restore vectors written by
public int Load(string path)
Parameters
path string
Returns
Save(string)
Write the vectors (not the images) to path.
public void Save(string path)
Parameters
path string
Search(string, int)
The topK images best matching query.
public ImageHit[] Search(string query, int topK = 10)
Parameters
query string
topK int
Returns
ImageHit[]
Kjarni runs the same engine on every platform: