v0.10.2¶
Upgrade Notes¶
ExternalSearchIndexis removed, and with it the support for indexes of libraries other than FAISS. Pass the FAISS index itself assearch_indextoInMemoryImageEmbeddingStoreand to itsload_from_disk.A store on a FAISS index is named after the index type, such as
faiss.IndexHNSWFlat, and takes itsspacefrom the index metric.index_paramsand FAISS metrics other thanMETRIC_L2andMETRIC_INNER_PRODUCTraiseValueError.A store on a FAISS inner-product index now scores by
1 - inner_productlike the built-in"ip"space, so lower is more similar.1 - candidate.scoregives the inner product back.
New Features¶
KReciprocalRerankeraccepts a store on a FAISS index.Added
to_single_imagehelper inpyvisim.utils.image_utils, which converts one image into the canonicaluint8array described bydimsandvalue_range. An example is shown below.import numpy as np from pyvisim.utils.image_utils import to_single_image rng = np.random.default_rng(0) # A uint8 image in the NumPy layout (height, width, channels), values in [0, 255] image_hwc = rng.integers(0, 256, size=(64, 80, 3), dtype=np.uint8) # The same pixels as a float image in the PyTorch layout # (channels, height, width), values in [0, 1] image_chw = image_hwc.transpose(2, 0, 1) / 255.0 # dims and value_range describe each input, and both come back as a # uint8 array of shape (64, 80, 3) with values in [0, 255] canonical_hwc = to_single_image(image_hwc, dims="HWC") canonical_chw = to_single_image(image_chw, dims="CHW", value_range=(0.0, 1.0)) print(canonical_chw.shape, canonical_chw.dtype) # (64, 80, 3) uint8 print(np.array_equal(canonical_hwc, canonical_chw)) # True
Added
set_pca_from_sklearntoVLADEmbedderandFisherVectorEmbedder. It replaces the embedder’s PCA with one created from asklearn.decomposition.PCAestimator, fitted or not.
Enhancement Notes¶
The new tutorial
Custom Feature Extractor with RootSIFTunder the classical methods implementsRootSIFTon top of theSIFTofOpenCV, which is the recommended way to useRootSIFTsince it is much faster than the built-inRootSIFT.The new tutorial
Introduction to VLAD and Fisher Vectorsunder the classical methods trains both embedders onRootSIFTfeatures, once withlearnand once from fittedscikit-learnestimators, which have more training options.
Bug Fixes¶
A store saved on an
ExternalSearchIndexnamed"hnsw"was loaded onto a newly built HNSW graph without a warning. Index names now come from the index type, so they cannot collide with a built-in index.A store saved on a FAISS index and loaded without it falls back to a brute-force scan in the metric of that index, and no longer in
"cosine".VLADEmbedderandFisherVectorEmbeddernow raiseRuntimeErrorfor a fitted PCA whose dimensions do not match the feature extractor or the clustering model, like their other dimension checks.learn(dim_reduction_factor=...)now emits aFutureWarningwhen it replaces a PCA the embedder already has.