This module contains all the code for extracting features and comparing features from SimCLR and SIFT models.

sift_frame_sim[source]

sift_frame_sim(features_i, features_j, codebook, df, vw)

simclr_frame_sim[source]

simclr_frame_sim(features_i, features_j, codebook, df, vw)

class SimCLRDataset[source]

SimCLRDataset(dataset) :: Dataset

An abstract class representing a :class:Dataset.

All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite :meth:__getitem__, supporting fetching a data sample for a given key. Subclasses could also optionally overwrite :meth:__len__, which is expected to return the size of the dataset by many :class:~torch.utils.data.Sampler implementations and the default options of :class:~torch.utils.data.DataLoader.

.. note:: :class:~torch.utils.data.DataLoader by default constructs a index sampler that yields integral indices. To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must be provided.

imagenet_normalize_transform[source]

imagenet_normalize_transform()

get_train_transforms[source]

get_train_transforms(size=224, color_jitter_prob=0.8, grayscale_prob=0.2)

get_val_transforms[source]

get_val_transforms(size=224)

class NTXEntCriterion[source]

NTXEntCriterion(temperature=0.5) :: Module

Normalized, temperature-scaled cross-entropy criterion, as suggested in the SimCLR paper.

Parameters: temperature (float, optional): temperature to scale the confidences. Defaults to 0.5.

class SimCLRModel[source]

SimCLRModel(model_name='resnet18', pretrained=True, projection_dim=64, temperature=0.5, batch_size=128, image_size=224, save_hparams=True) :: LightningModule

SimCLR training network for a generic torchvision model (restricted to allowed_models).