Skip to content

A GitHub repository accompanying a "Dissecting CLIP: Decomposition with a Schur Complement-based Approach" paper

Notifications You must be signed in to change notification settings

aziksh-ospanov/scendi-score

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scendi Score for Prompt-Aware Diversity Evaluation


Installation | Initializing Scendi Score | Computing Scendi Score | Clustering with Scendi | Datasets used | Citation |

A GitHub repository accompanying a "Scendi Score: Prompt-Aware Diversity Evaluation via Schur Complement of CLIP Embeddings" paper

Scendi Score

1. Installation

  1. Clone the repository
git clone https://github.com/aziksh-ospanov/scendi-score.git
cd scendi-score
  1. Install dependencies
pip install -r requirements.txt

2. Initializing Scendi Score

To compute Scendi score presented in the paper, initialize Scendi with the following:

from scendi.score import ScendiEvaluator
from scendi.datasets.ImageFilesDataset import ImageFilesDataset

#%%
sigma = 3.5 # Gaussian kernel bandwidth parameter
fe = 'clip' # Embedding that supports both text and image modalities 

result_name = 'your_result_name'

img_pth = 'path_to_images'
text_pth = 'path_to_text.txt'

with open(text_pth, 'r') as f:
    prompts = f.readlines()
image_dataset = ImageFilesDataset(img_pth, name=result_name, extension='png')

scendi = ScendiEvaluator(logger_path='./logs', batchsize=64, sigma=sigma, num_samples=num_samples, result_name=result_name, rff_dim=2500, save_visuals_path=f'visuals_{result_name}')

scendi.set_schur_feature_extractor(fe, save_path='./save')  

In this snippet, parameter sigma controls the bandwidth of the Gaussian Kernel and fe allows to choose a specific feature extractor. In this repository we provide an implementation for CLIP, but other feature extractors may be used. We note that to access T2I and I2T evaluations, the feature extractor should support encoding of both text and image domains.

3. Computing Scendi Score

To calculate the Scendi Score for a paired text-image dataset, use the following function:

# Get Scendi Scores
score = scendi.scendi_score(prompts, image_dataset)

4. Clustering with Scendi

Scendi Clusters The script enables clustering of images after applying Scendi CLIP embedding correction based on prompts. Use the following function:

# Cluster Results
scendi.scendi_clustering_of_dataset(prompts, image_dataset)

Note that top images, number of modes and sensitivity (sigma parameter) are adjustable. The results are stored in location specified in save_visuals_path.

5. Datasets used

We provide access to datasets as follows:

6. Citation

@inproceedings{
      ospanov2025scendi,
      title = {Scendi Score: Prompt-Aware Diversity Evaluation via Schur Complement of CLIP Embeddings},
      author = {Azim Ospanov and Mohammad Jalali and Farzan Farnia},
      booktitle = {International Conference on Computer Vision},
      year = {2025}
}

This README.md file provides a clear and concise guide for users to understand and run the demo script, including installation instructions, usage examples, and parameter explanations. Adjust the paths and filenames in the script to match your specific environment and dataset.

About

A GitHub repository accompanying a "Dissecting CLIP: Decomposition with a Schur Complement-based Approach" paper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages