Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MatousE/rot-invariance-analysis

Repository files navigation

Are the Latent Representations of Foundation Models for Pathology Invarient to Rotation?

Requirements

Developed on

python = 3.11 PyTorch = 2.1.0

Clone the repository locally

git clone https://github.com/MatousE/rot-invariance-analysis.git
cd rot-invariance-analysis

And install the remaining requirements with

pip install -r requirements.txt

Extracting embeddings

To extract the features of these models for a dataset under different rotations one must first define a YAML file with the parameters of the experiment. An example is shown at args/get_rot_embeddings.yaml.

To see all supported models run

python -c 'from utils import SUPPORTED_MODELS; print(SUPPORTED_MODELS)'

To run the experiment you simply run the following code

python get_rot_embeddings.py --yaml /path/to/yaml/file.yaml

The resulting features will be stored as a single .pth file

Measuring mutual $k$-NN

To extract the mutual $k$-NN between the embeddings with no-rotation and with rotation one simply runs the following

python m_knn_distance.py --embd_path /results/embeddings.pth --k 10 --batch_size 1024

The results of which will be stored in a CSV file called m_knn.csv

Measuring cosine distance

To extract the cosine distance between the embeddings with no-rotation and with rotation one simply runs

python cosine_distance.py --embd_path /results/embeddings.pth

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published