Repository files navigation

BlackTestspre-commit

Note: This a development version of the code. The code in the main branch is a more stable version of the code.

Affinity-VAE

Affinity-VAE for disentanglement, clustering and classification of objects in multidimensional image data
Mirecka J, Famili M, Kotanska A, Juraschko N, Costa-Gomes B, Palmer CM, Thiyagalingam J, Burnley T, Basham M & Lowe AR
doi:10.48550/arXiv.2209.04517

Installation

Installing with pip + virtual environments

Note: This has been tested in the develop branch.

You can install the libraries needed for this package on a fresh virtual environment with the following:

python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ."[all]"

If you are developing code, you should be able to run pre-commits and tests, therefore the best installation option after setting up the virtual environment is:

python -m pip install -e ."[test]"

run tests locally from this same working directory as installation (root of this repository):

python -m pytest -s -W ignore

Note: This is the preferred option for running on macOS laptops.

Warning: M1 macOS can not do pytorch paralelisation. A temporary solution for this is to modify the code on the DataLoaders in data.py to num_workers=0 in order to run the code. Otherwise, you will get the error: AttributeError: Can't pickle local object 'ProteinDataset.__init__.<locals>.<lambda>'.

Installing with pyenv in Baskerville

The following is the recommended way of installing all libraries in Baskervile.


module purge
module load baskerville
module load bask-apps/live
module load PyTorch/2.0.1-foss-2022a-CUDA-11.7.0
module load torchvision/0.15.2-foss-2022a-CUDA-11.7.0
python -m venv pyenv_affinity
source pyenv_affinity/bin/activate
git clone https://github.com/alan-turing-institute/affinity-vae.git
cd affinity-vae/
python -m pip install -e ."[baskerville]"

you can send a SLURM job to the cluster using the script in tools, with the following command:

sbatch slurm_run.sh

Running Affinity-VAE: A quick start

We have a tutorial on how to run Affinity-VAE on the MNIST dataset. We recommend to start there for the first time you run Affinity-VAE.

Affinity-VAE configuration parameters

Affinity-VAE has a running script (run.py) that allows you to configure and run the code. You can look at the available configuration options by running:

python run.py --help

which will give you:

Usage: run.py [OPTIONS]
Options:
--config_file PATH
-d, --datapath TEXT Path to training data.
-dtype, --datatype TEXT Type of the data: mrc, npy
-dbg, --debug Run in debug mode.
-res, --restart Is the calculation restarting from a
checkpoint.
-st, --state TEXT The saved model state to be loaded for
evaluation/resume training.
-mt, --meta TEXT The saved meta file to be loaded for
regenerating dynamic plots.
-lm, --limit INTEGER Limit the number of samples loaded (default
None).
-sp, --split INTEGER Train/val split in %.
-newo, --new_out Create new output directory where to save
the results.
-nd, --no_val_drop Do not drop last validate batch if if it is
smaller than batch_size.
-af, --affinity TEXT Path to affinity matrix for training.
-cl, --classes TEXT Path to a CSV file containing a list of
classes for training.
-clf, --classifier TEXT Method to classify the latent space. Options
are: KNN (nearest neighbour), NN (neural
network), LR (Logistic Regression).
-ep, --epochs INTEGER Number of epochs (default 100).
-ba, --batch INTEGER Batch size (default 128).
-de, --depth INTEGER Depth of the convolutional layers (default
3).
-ch, --channels INTEGER First layer channels (default 64).
-fl, --filters TEXT Comma-separated list of filters for the
network. Either provide filters, or capacity
and depth.
-ld, --latent_dims INTEGER Latent space dimension (default 10).
-pd, --pose_dims INTEGER If pose on, number of pose dimensions. If 0
and gamma=0 it becomesa standard beta-VAE.
-bn_enc, --bnorm_encoder Batch normalisation in encoder is on if
True.
-bn_dec, --bnorm_decoder Batch normalisation in encoder is on if
True.
-gsdcl, --gsd_conv_layers INTEGER
The number of output channels for the
convolution layers at the end of the GSD
decoder
-spl, --n_splats INTEGER Number of Gaussian splats.
-kr, --klreduction TEXT Mean or sum reduction on KLD term.
-be, --beta FLOAT Beta maximum in the case of cyclical
annealing schedule
-bl, --beta_load The path to the saved beta array file to be
loaded if this file is provided, all other
beta related variables would be ignored
-g, --gamma FLOAT Scale factor for the loss component
corresponding to shape similarity. If 0 and
pd=0 it becomes a standardbeta-VAE.
-gl, --gamma_load The path to the saved gamma array file to be
loadedif this file is provided, all other
gamma related variables would be ignored
-lr, --learning FLOAT Learning rate.
-lf, --loss_fn TEXT Loss type: 'MSE' or 'BCE' (default 'MSE').
-bs, --beta_min FLOAT Beta minimum in the case of cyclical
annealing schedule
-bc, --beta_cycle INTEGER Number of cycles for beta during training in
the case of cyclical annealing schedule
-br, --beta_ratio FLOAT The ratio for steps in beta
-cycmb, --cyc_method_beta TEXT The schedule for : for constant beta : flat,
other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-gs, --gamma_min FLOAT gamma minimum in the case of cyclical
annealing schedule
-gc, --gamma_cycle INTEGER Number of cycles for gamma during training
in the case of cyclical annealing schedule
-gr, --gamma_ratio FLOAT The ratio for steps in gamma
-cycmg, --cyc_method_gamma TEXT
The schedule for gamma: for constant gamma :
flat, other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-g, --gpu Use GPU for training.
-ev, --eval Evaluate test data.
-dn, --dynamic Enable collecting meta and dynamic latent
space plots.
-m, --model TEXT Choose model to run. The choice of models
are a, b, u and gsd
-vl, --vis_los Visualise loss (every epoch starting at
epoch 2).
-vac, --vis_acc Visualise confusion matrix and F1 scores
(frequency controlled).
-vr, --vis_rec Visualise reconstructions (frequency
controlled).
-ve, --vis_emb Visualise latent space embedding (frequency
controlled).
-vi, --vis_int Visualise interpolations (frequency
controlled).
-vt, --vis_dis Visualise latent disentanglement (frequency
controlled).
-vps, --vis_pos Visualise pose disentanglement (frequency
controlled).
-vpsc, --vis_pose_class TEXT Example: A,B,C. your deliminator should be
commas and no spaces. Classes to be used for
pose interpolation (a seperate pose
interpolation figure would be created for
each class).
-vzni, --vis_z_n_int TEXT Number of Latent interpolation classes to to
be printed, number of interpolation steps in
each plot. Example: 1,10. 1 plot with 10
interpolation steps between two classes.
your deliminator should be commas and no
spaces.
-vc, --vis_cyc Visualise cyclical parameters (once per
run).
-va, --vis_aff Visualise affinity matrix (once per run).
-his, --vis_his Visualise train-val class distribution (once
per run).
-similarity, --vis_sim Visualise train-val model similarity matrix.
-va, --vis_all Visualise all above.
-vf, --vis_format TEXT The format of saved images. Options: png ,
pdf
-fev, --freq_eval INTEGER Frequency at which to evaluate test set.
-fs, --freq_sta INTEGER Frequency at which to save state
-fac, --freq_acc INTEGER Frequency at which to visualise confusion
matrix.
-fr, --freq_rec INTEGER Frequency at which to visualise
reconstructions
-fe, --freq_emb INTEGER Frequency at which to visualise the latent
space embedding.
-fi, --freq_int INTEGER Frequency at which to visualise latent
spaceinterpolations (default every 10
epochs).
-ft, --freq_dis INTEGER Frequency at which to visualise single
transversals.
-fp, --freq_pos INTEGER Frequency at which to visualise pose.
-fsim, --freq_sim INTEGER Frequency at which to visualise similarity
matrix.
-fa, --freq_all INTEGER Frequency at which to visualise all plots
except loss.
-opt, --opt_method TEXT The method of optimisation. It can be
adam/sgd/asgd
-gb, --gaussian_blur Applying gaussian bluring to the image data
which should help removing noise. The
minimum and maximum for this is hardcoded.
-nrm, --normalise Normalise data
-sftm, --shift_min Shift the minimum of the data to one zero
and the maximum to one
-res, --rescale INTEGER Rescale images to given value (tuple, one
value per dim).
-tb, --tensorboard Log metrics and figures to tensorboard
during training
-st, --strategy TEXT Define the strategy for distributed
training. Options are: 'ddp', 'deepspeed' or
'fsdp
--help Show this message and exit.

Note that setting -g/--gamma to 0 and -pd/--pose_dims to 0 will run a vanilla beta-VAE.

Configuring from the command line

You can run on example data with the following command:

python affinity-vae/run.py -d data/subtomo_files --split 20 --epochs 10 -ba 128 -lr 0.001 -de 4 -ch 64 -ld 8 -pd 3 --beta 1 --gamma 2 --limit 1000 --freq_all 5 --vis_all --dynamic

where the subtomo_files is a directory with a number of .mcr proteine image files named with the protein keyword such as (1BXN_m0_156_Th0.mrc,5MRC_m8_1347_Th0.mrc, etc). The subtomo_files directory should also have be a classes.csv file with a list of the protein names and keywords to be considered (1BXN, 5MRC, etc.) and a affinity_scores.csv matrix with the initial values for the proteins named in the classes.csv.

Using a config submission file

You can also run the code using a submission config file (you can find an example with default values on configs/avae-test-config.yml). For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml

You can also use a mix of config file and command line arguments. For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml --epochs 10 --affinity /path/to/different_affinity.csv

this will rewrite the values for the epochs and affinity path in the config file.

At the end of the run, the code will save the final config file used for the run in the working directory. This will account for any changes made to the config file from the command line. Running the code again with that config file will reproduce the results.

In the tools folder you can find notebooks which will assist you in creating the input files for Affinity-VAE or analyse teh output of the model.

Considerations

Test folder : If test folder is present, the program will read the test files regardless of the eval flag
Evaluation: To run evaluation on a trained model you can turn the eval flag to True. This will load the last model present on the states directory (within the working directory path where you run the code) and run the evaluation on data set by the datapath flag. The evaluation will be saved in the plots and latents directory with the eval suffix on the names.
The name of the state file consist of avae_date_time_Epoch_latent_pose.pt

Inspecting the results from Affinity-VAE

You can interact with the latent space and access reconstruction from the train model using Napari. You can find more information on how to use the Napari plugin in the README.md file in the scripts folder.

About

Self-supervised method for disentanglement, clustering and classification of objects in multidimensional image data

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

BlackTestspre-commit

Note: This a development version of the code. The code in the main branch is a more stable version of the code.

Affinity-VAE

Affinity-VAE for disentanglement, clustering and classification of objects in multidimensional image data
Mirecka J, Famili M, Kotanska A, Juraschko N, Costa-Gomes B, Palmer CM, Thiyagalingam J, Burnley T, Basham M & Lowe AR
doi:10.48550/arXiv.2209.04517

Installation

Installing with pip + virtual environments

Note: This has been tested in the develop branch.

You can install the libraries needed for this package on a fresh virtual environment with the following:

python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ."[all]"

If you are developing code, you should be able to run pre-commits and tests, therefore the best installation option after setting up the virtual environment is:

python -m pip install -e ."[test]"

run tests locally from this same working directory as installation (root of this repository):

python -m pytest -s -W ignore

Note: This is the preferred option for running on macOS laptops.

Warning: M1 macOS can not do pytorch paralelisation. A temporary solution for this is to modify the code on the DataLoaders in data.py to num_workers=0 in order to run the code. Otherwise, you will get the error: AttributeError: Can't pickle local object 'ProteinDataset.__init__.<locals>.<lambda>'.

Installing with pyenv in Baskerville

The following is the recommended way of installing all libraries in Baskervile.


module purge
module load baskerville
module load bask-apps/live
module load PyTorch/2.0.1-foss-2022a-CUDA-11.7.0
module load torchvision/0.15.2-foss-2022a-CUDA-11.7.0
python -m venv pyenv_affinity
source pyenv_affinity/bin/activate
git clone https://github.com/alan-turing-institute/affinity-vae.git
cd affinity-vae/
python -m pip install -e ."[baskerville]"

you can send a SLURM job to the cluster using the script in tools, with the following command:

sbatch slurm_run.sh

Running Affinity-VAE: A quick start

We have a tutorial on how to run Affinity-VAE on the MNIST dataset. We recommend to start there for the first time you run Affinity-VAE.

Affinity-VAE configuration parameters

Affinity-VAE has a running script (run.py) that allows you to configure and run the code. You can look at the available configuration options by running:

python run.py --help

which will give you:

Usage: run.py [OPTIONS]
Options:
--config_file PATH
-d, --datapath TEXT Path to training data.
-dtype, --datatype TEXT Type of the data: mrc, npy
-dbg, --debug Run in debug mode.
-res, --restart Is the calculation restarting from a
checkpoint.
-st, --state TEXT The saved model state to be loaded for
evaluation/resume training.
-mt, --meta TEXT The saved meta file to be loaded for
regenerating dynamic plots.
-lm, --limit INTEGER Limit the number of samples loaded (default
None).
-sp, --split INTEGER Train/val split in %.
-newo, --new_out Create new output directory where to save
the results.
-nd, --no_val_drop Do not drop last validate batch if if it is
smaller than batch_size.
-af, --affinity TEXT Path to affinity matrix for training.
-cl, --classes TEXT Path to a CSV file containing a list of
classes for training.
-clf, --classifier TEXT Method to classify the latent space. Options
are: KNN (nearest neighbour), NN (neural
network), LR (Logistic Regression).
-ep, --epochs INTEGER Number of epochs (default 100).
-ba, --batch INTEGER Batch size (default 128).
-de, --depth INTEGER Depth of the convolutional layers (default
3).
-ch, --channels INTEGER First layer channels (default 64).
-fl, --filters TEXT Comma-separated list of filters for the
network. Either provide filters, or capacity
and depth.
-ld, --latent_dims INTEGER Latent space dimension (default 10).
-pd, --pose_dims INTEGER If pose on, number of pose dimensions. If 0
and gamma=0 it becomesa standard beta-VAE.
-bn_enc, --bnorm_encoder Batch normalisation in encoder is on if
True.
-bn_dec, --bnorm_decoder Batch normalisation in encoder is on if
True.
-gsdcl, --gsd_conv_layers INTEGER
The number of output channels for the
convolution layers at the end of the GSD
decoder
-spl, --n_splats INTEGER Number of Gaussian splats.
-kr, --klreduction TEXT Mean or sum reduction on KLD term.
-be, --beta FLOAT Beta maximum in the case of cyclical
annealing schedule
-bl, --beta_load The path to the saved beta array file to be
loaded if this file is provided, all other
beta related variables would be ignored
-g, --gamma FLOAT Scale factor for the loss component
corresponding to shape similarity. If 0 and
pd=0 it becomes a standardbeta-VAE.
-gl, --gamma_load The path to the saved gamma array file to be
loadedif this file is provided, all other
gamma related variables would be ignored
-lr, --learning FLOAT Learning rate.
-lf, --loss_fn TEXT Loss type: 'MSE' or 'BCE' (default 'MSE').
-bs, --beta_min FLOAT Beta minimum in the case of cyclical
annealing schedule
-bc, --beta_cycle INTEGER Number of cycles for beta during training in
the case of cyclical annealing schedule
-br, --beta_ratio FLOAT The ratio for steps in beta
-cycmb, --cyc_method_beta TEXT The schedule for : for constant beta : flat,
other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-gs, --gamma_min FLOAT gamma minimum in the case of cyclical
annealing schedule
-gc, --gamma_cycle INTEGER Number of cycles for gamma during training
in the case of cyclical annealing schedule
-gr, --gamma_ratio FLOAT The ratio for steps in gamma
-cycmg, --cyc_method_gamma TEXT
The schedule for gamma: for constant gamma :
flat, other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-g, --gpu Use GPU for training.
-ev, --eval Evaluate test data.
-dn, --dynamic Enable collecting meta and dynamic latent
space plots.
-m, --model TEXT Choose model to run. The choice of models
are a, b, u and gsd
-vl, --vis_los Visualise loss (every epoch starting at
epoch 2).
-vac, --vis_acc Visualise confusion matrix and F1 scores
(frequency controlled).
-vr, --vis_rec Visualise reconstructions (frequency
controlled).
-ve, --vis_emb Visualise latent space embedding (frequency
controlled).
-vi, --vis_int Visualise interpolations (frequency
controlled).
-vt, --vis_dis Visualise latent disentanglement (frequency
controlled).
-vps, --vis_pos Visualise pose disentanglement (frequency
controlled).
-vpsc, --vis_pose_class TEXT Example: A,B,C. your deliminator should be
commas and no spaces. Classes to be used for
pose interpolation (a seperate pose
interpolation figure would be created for
each class).
-vzni, --vis_z_n_int TEXT Number of Latent interpolation classes to to
be printed, number of interpolation steps in
each plot. Example: 1,10. 1 plot with 10
interpolation steps between two classes.
your deliminator should be commas and no
spaces.
-vc, --vis_cyc Visualise cyclical parameters (once per
run).
-va, --vis_aff Visualise affinity matrix (once per run).
-his, --vis_his Visualise train-val class distribution (once
per run).
-similarity, --vis_sim Visualise train-val model similarity matrix.
-va, --vis_all Visualise all above.
-vf, --vis_format TEXT The format of saved images. Options: png ,
pdf
-fev, --freq_eval INTEGER Frequency at which to evaluate test set.
-fs, --freq_sta INTEGER Frequency at which to save state
-fac, --freq_acc INTEGER Frequency at which to visualise confusion
matrix.
-fr, --freq_rec INTEGER Frequency at which to visualise
reconstructions
-fe, --freq_emb INTEGER Frequency at which to visualise the latent
space embedding.
-fi, --freq_int INTEGER Frequency at which to visualise latent
spaceinterpolations (default every 10
epochs).
-ft, --freq_dis INTEGER Frequency at which to visualise single
transversals.
-fp, --freq_pos INTEGER Frequency at which to visualise pose.
-fsim, --freq_sim INTEGER Frequency at which to visualise similarity
matrix.
-fa, --freq_all INTEGER Frequency at which to visualise all plots
except loss.
-opt, --opt_method TEXT The method of optimisation. It can be
adam/sgd/asgd
-gb, --gaussian_blur Applying gaussian bluring to the image data
which should help removing noise. The
minimum and maximum for this is hardcoded.
-nrm, --normalise Normalise data
-sftm, --shift_min Shift the minimum of the data to one zero
and the maximum to one
-res, --rescale INTEGER Rescale images to given value (tuple, one
value per dim).
-tb, --tensorboard Log metrics and figures to tensorboard
during training
-st, --strategy TEXT Define the strategy for distributed
training. Options are: 'ddp', 'deepspeed' or
'fsdp
--help Show this message and exit.

Note that setting -g/--gamma to 0 and -pd/--pose_dims to 0 will run a vanilla beta-VAE.

Configuring from the command line

You can run on example data with the following command:

python affinity-vae/run.py -d data/subtomo_files --split 20 --epochs 10 -ba 128 -lr 0.001 -de 4 -ch 64 -ld 8 -pd 3 --beta 1 --gamma 2 --limit 1000 --freq_all 5 --vis_all --dynamic

where the subtomo_files is a directory with a number of .mcr proteine image files named with the protein keyword such as (1BXN_m0_156_Th0.mrc,5MRC_m8_1347_Th0.mrc, etc). The subtomo_files directory should also have be a classes.csv file with a list of the protein names and keywords to be considered (1BXN, 5MRC, etc.) and a affinity_scores.csv matrix with the initial values for the proteins named in the classes.csv.

Using a config submission file

You can also run the code using a submission config file (you can find an example with default values on configs/avae-test-config.yml). For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml

You can also use a mix of config file and command line arguments. For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml --epochs 10 --affinity /path/to/different_affinity.csv

this will rewrite the values for the epochs and affinity path in the config file.

At the end of the run, the code will save the final config file used for the run in the working directory. This will account for any changes made to the config file from the command line. Running the code again with that config file will reproduce the results.

In the tools folder you can find notebooks which will assist you in creating the input files for Affinity-VAE or analyse teh output of the model.

Considerations

Test folder : If test folder is present, the program will read the test files regardless of the eval flag
Evaluation: To run evaluation on a trained model you can turn the eval flag to True. This will load the last model present on the states directory (within the working directory path where you run the code) and run the evaluation on data set by the datapath flag. The evaluation will be saved in the plots and latents directory with the eval suffix on the names.
The name of the state file consist of avae_date_time_Epoch_latent_pose.pt

Inspecting the results from Affinity-VAE

You can interact with the latent space and access reconstruction from the train model using Napari. You can find more information on how to use the Napari plugin in the README.md file in the scripts folder.

About

Self-supervised method for disentanglement, clustering and classification of objects in multidimensional image data

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

BlackTestspre-commit

Note: This a development version of the code. The code in the main branch is a more stable version of the code.

Affinity-VAE

Affinity-VAE for disentanglement, clustering and classification of objects in multidimensional image data
Mirecka J, Famili M, Kotanska A, Juraschko N, Costa-Gomes B, Palmer CM, Thiyagalingam J, Burnley T, Basham M & Lowe AR
doi:10.48550/arXiv.2209.04517

Installation

Installing with pip + virtual environments

Note: This has been tested in the develop branch.

You can install the libraries needed for this package on a fresh virtual environment with the following:

python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ."[all]"

If you are developing code, you should be able to run pre-commits and tests, therefore the best installation option after setting up the virtual environment is:

python -m pip install -e ."[test]"

run tests locally from this same working directory as installation (root of this repository):

python -m pytest -s -W ignore

Note: This is the preferred option for running on macOS laptops.

Warning: M1 macOS can not do pytorch paralelisation. A temporary solution for this is to modify the code on the DataLoaders in data.py to num_workers=0 in order to run the code. Otherwise, you will get the error: AttributeError: Can't pickle local object 'ProteinDataset.__init__.<locals>.<lambda>'.

Installing with pyenv in Baskerville

The following is the recommended way of installing all libraries in Baskervile.


module purge
module load baskerville
module load bask-apps/live
module load PyTorch/2.0.1-foss-2022a-CUDA-11.7.0
module load torchvision/0.15.2-foss-2022a-CUDA-11.7.0
python -m venv pyenv_affinity
source pyenv_affinity/bin/activate
git clone https://github.com/alan-turing-institute/affinity-vae.git
cd affinity-vae/
python -m pip install -e ."[baskerville]"

you can send a SLURM job to the cluster using the script in tools, with the following command:

sbatch slurm_run.sh

Running Affinity-VAE: A quick start

We have a tutorial on how to run Affinity-VAE on the MNIST dataset. We recommend to start there for the first time you run Affinity-VAE.

Affinity-VAE configuration parameters

Affinity-VAE has a running script (run.py) that allows you to configure and run the code. You can look at the available configuration options by running:

python run.py --help

which will give you:

Usage: run.py [OPTIONS]
Options:
--config_file PATH
-d, --datapath TEXT Path to training data.
-dtype, --datatype TEXT Type of the data: mrc, npy
-dbg, --debug Run in debug mode.
-res, --restart Is the calculation restarting from a
checkpoint.
-st, --state TEXT The saved model state to be loaded for
evaluation/resume training.
-mt, --meta TEXT The saved meta file to be loaded for
regenerating dynamic plots.
-lm, --limit INTEGER Limit the number of samples loaded (default
None).
-sp, --split INTEGER Train/val split in %.
-newo, --new_out Create new output directory where to save
the results.
-nd, --no_val_drop Do not drop last validate batch if if it is
smaller than batch_size.
-af, --affinity TEXT Path to affinity matrix for training.
-cl, --classes TEXT Path to a CSV file containing a list of
classes for training.
-clf, --classifier TEXT Method to classify the latent space. Options
are: KNN (nearest neighbour), NN (neural
network), LR (Logistic Regression).
-ep, --epochs INTEGER Number of epochs (default 100).
-ba, --batch INTEGER Batch size (default 128).
-de, --depth INTEGER Depth of the convolutional layers (default
3).
-ch, --channels INTEGER First layer channels (default 64).
-fl, --filters TEXT Comma-separated list of filters for the
network. Either provide filters, or capacity
and depth.
-ld, --latent_dims INTEGER Latent space dimension (default 10).
-pd, --pose_dims INTEGER If pose on, number of pose dimensions. If 0
and gamma=0 it becomesa standard beta-VAE.
-bn_enc, --bnorm_encoder Batch normalisation in encoder is on if
True.
-bn_dec, --bnorm_decoder Batch normalisation in encoder is on if
True.
-gsdcl, --gsd_conv_layers INTEGER
The number of output channels for the
convolution layers at the end of the GSD
decoder
-spl, --n_splats INTEGER Number of Gaussian splats.
-kr, --klreduction TEXT Mean or sum reduction on KLD term.
-be, --beta FLOAT Beta maximum in the case of cyclical
annealing schedule
-bl, --beta_load The path to the saved beta array file to be
loaded if this file is provided, all other
beta related variables would be ignored
-g, --gamma FLOAT Scale factor for the loss component
corresponding to shape similarity. If 0 and
pd=0 it becomes a standardbeta-VAE.
-gl, --gamma_load The path to the saved gamma array file to be
loadedif this file is provided, all other
gamma related variables would be ignored
-lr, --learning FLOAT Learning rate.
-lf, --loss_fn TEXT Loss type: 'MSE' or 'BCE' (default 'MSE').
-bs, --beta_min FLOAT Beta minimum in the case of cyclical
annealing schedule
-bc, --beta_cycle INTEGER Number of cycles for beta during training in
the case of cyclical annealing schedule
-br, --beta_ratio FLOAT The ratio for steps in beta
-cycmb, --cyc_method_beta TEXT The schedule for : for constant beta : flat,
other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-gs, --gamma_min FLOAT gamma minimum in the case of cyclical
annealing schedule
-gc, --gamma_cycle INTEGER Number of cycles for gamma during training
in the case of cyclical annealing schedule
-gr, --gamma_ratio FLOAT The ratio for steps in gamma
-cycmg, --cyc_method_gamma TEXT
The schedule for gamma: for constant gamma :
flat, other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-g, --gpu Use GPU for training.
-ev, --eval Evaluate test data.
-dn, --dynamic Enable collecting meta and dynamic latent
space plots.
-m, --model TEXT Choose model to run. The choice of models
are a, b, u and gsd
-vl, --vis_los Visualise loss (every epoch starting at
epoch 2).
-vac, --vis_acc Visualise confusion matrix and F1 scores
(frequency controlled).
-vr, --vis_rec Visualise reconstructions (frequency
controlled).
-ve, --vis_emb Visualise latent space embedding (frequency
controlled).
-vi, --vis_int Visualise interpolations (frequency
controlled).
-vt, --vis_dis Visualise latent disentanglement (frequency
controlled).
-vps, --vis_pos Visualise pose disentanglement (frequency
controlled).
-vpsc, --vis_pose_class TEXT Example: A,B,C. your deliminator should be
commas and no spaces. Classes to be used for
pose interpolation (a seperate pose
interpolation figure would be created for
each class).
-vzni, --vis_z_n_int TEXT Number of Latent interpolation classes to to
be printed, number of interpolation steps in
each plot. Example: 1,10. 1 plot with 10
interpolation steps between two classes.
your deliminator should be commas and no
spaces.
-vc, --vis_cyc Visualise cyclical parameters (once per
run).
-va, --vis_aff Visualise affinity matrix (once per run).
-his, --vis_his Visualise train-val class distribution (once
per run).
-similarity, --vis_sim Visualise train-val model similarity matrix.
-va, --vis_all Visualise all above.
-vf, --vis_format TEXT The format of saved images. Options: png ,
pdf
-fev, --freq_eval INTEGER Frequency at which to evaluate test set.
-fs, --freq_sta INTEGER Frequency at which to save state
-fac, --freq_acc INTEGER Frequency at which to visualise confusion
matrix.
-fr, --freq_rec INTEGER Frequency at which to visualise
reconstructions
-fe, --freq_emb INTEGER Frequency at which to visualise the latent
space embedding.
-fi, --freq_int INTEGER Frequency at which to visualise latent
spaceinterpolations (default every 10
epochs).
-ft, --freq_dis INTEGER Frequency at which to visualise single
transversals.
-fp, --freq_pos INTEGER Frequency at which to visualise pose.
-fsim, --freq_sim INTEGER Frequency at which to visualise similarity
matrix.
-fa, --freq_all INTEGER Frequency at which to visualise all plots
except loss.
-opt, --opt_method TEXT The method of optimisation. It can be
adam/sgd/asgd
-gb, --gaussian_blur Applying gaussian bluring to the image data
which should help removing noise. The
minimum and maximum for this is hardcoded.
-nrm, --normalise Normalise data
-sftm, --shift_min Shift the minimum of the data to one zero
and the maximum to one
-res, --rescale INTEGER Rescale images to given value (tuple, one
value per dim).
-tb, --tensorboard Log metrics and figures to tensorboard
during training
-st, --strategy TEXT Define the strategy for distributed
training. Options are: 'ddp', 'deepspeed' or
'fsdp
--help Show this message and exit.

Note that setting -g/--gamma to 0 and -pd/--pose_dims to 0 will run a vanilla beta-VAE.

Configuring from the command line

You can run on example data with the following command:

python affinity-vae/run.py -d data/subtomo_files --split 20 --epochs 10 -ba 128 -lr 0.001 -de 4 -ch 64 -ld 8 -pd 3 --beta 1 --gamma 2 --limit 1000 --freq_all 5 --vis_all --dynamic

where the subtomo_files is a directory with a number of .mcr proteine image files named with the protein keyword such as (1BXN_m0_156_Th0.mrc,5MRC_m8_1347_Th0.mrc, etc). The subtomo_files directory should also have be a classes.csv file with a list of the protein names and keywords to be considered (1BXN, 5MRC, etc.) and a affinity_scores.csv matrix with the initial values for the proteins named in the classes.csv.

Using a config submission file

You can also run the code using a submission config file (you can find an example with default values on configs/avae-test-config.yml). For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml

You can also use a mix of config file and command line arguments. For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml --epochs 10 --affinity /path/to/different_affinity.csv

this will rewrite the values for the epochs and affinity path in the config file.

At the end of the run, the code will save the final config file used for the run in the working directory. This will account for any changes made to the config file from the command line. Running the code again with that config file will reproduce the results.

In the tools folder you can find notebooks which will assist you in creating the input files for Affinity-VAE or analyse teh output of the model.

Considerations

Test folder : If test folder is present, the program will read the test files regardless of the eval flag
Evaluation: To run evaluation on a trained model you can turn the eval flag to True. This will load the last model present on the states directory (within the working directory path where you run the code) and run the evaluation on data set by the datapath flag. The evaluation will be saved in the plots and latents directory with the eval suffix on the names.
The name of the state file consist of avae_date_time_Epoch_latent_pose.pt

Inspecting the results from Affinity-VAE

You can interact with the latent space and access reconstruction from the train model using Napari. You can find more information on how to use the Napari plugin in the README.md file in the scripts folder.

About

Self-supervised method for disentanglement, clustering and classification of objects in multidimensional image data

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

BlackTestspre-commit

Note: This a development version of the code. The code in the main branch is a more stable version of the code.

Affinity-VAE

Affinity-VAE for disentanglement, clustering and classification of objects in multidimensional image data
Mirecka J, Famili M, Kotanska A, Juraschko N, Costa-Gomes B, Palmer CM, Thiyagalingam J, Burnley T, Basham M & Lowe AR
doi:10.48550/arXiv.2209.04517

Installation

Installing with pip + virtual environments

Note: This has been tested in the develop branch.

You can install the libraries needed for this package on a fresh virtual environment with the following:

python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ."[all]"

If you are developing code, you should be able to run pre-commits and tests, therefore the best installation option after setting up the virtual environment is:

python -m pip install -e ."[test]"

run tests locally from this same working directory as installation (root of this repository):

python -m pytest -s -W ignore

Note: This is the preferred option for running on macOS laptops.

Warning: M1 macOS can not do pytorch paralelisation. A temporary solution for this is to modify the code on the DataLoaders in data.py to num_workers=0 in order to run the code. Otherwise, you will get the error: AttributeError: Can't pickle local object 'ProteinDataset.__init__.<locals>.<lambda>'.

Installing with pyenv in Baskerville

The following is the recommended way of installing all libraries in Baskervile.


module purge
module load baskerville
module load bask-apps/live
module load PyTorch/2.0.1-foss-2022a-CUDA-11.7.0
module load torchvision/0.15.2-foss-2022a-CUDA-11.7.0
python -m venv pyenv_affinity
source pyenv_affinity/bin/activate
git clone https://github.com/alan-turing-institute/affinity-vae.git
cd affinity-vae/
python -m pip install -e ."[baskerville]"

you can send a SLURM job to the cluster using the script in tools, with the following command:

sbatch slurm_run.sh

Running Affinity-VAE: A quick start

We have a tutorial on how to run Affinity-VAE on the MNIST dataset. We recommend to start there for the first time you run Affinity-VAE.

Affinity-VAE configuration parameters

Affinity-VAE has a running script (run.py) that allows you to configure and run the code. You can look at the available configuration options by running:

python run.py --help

which will give you:

Usage: run.py [OPTIONS]
Options:
--config_file PATH
-d, --datapath TEXT Path to training data.
-dtype, --datatype TEXT Type of the data: mrc, npy
-dbg, --debug Run in debug mode.
-res, --restart Is the calculation restarting from a
checkpoint.
-st, --state TEXT The saved model state to be loaded for
evaluation/resume training.
-mt, --meta TEXT The saved meta file to be loaded for
regenerating dynamic plots.
-lm, --limit INTEGER Limit the number of samples loaded (default
None).
-sp, --split INTEGER Train/val split in %.
-newo, --new_out Create new output directory where to save
the results.
-nd, --no_val_drop Do not drop last validate batch if if it is
smaller than batch_size.
-af, --affinity TEXT Path to affinity matrix for training.
-cl, --classes TEXT Path to a CSV file containing a list of
classes for training.
-clf, --classifier TEXT Method to classify the latent space. Options
are: KNN (nearest neighbour), NN (neural
network), LR (Logistic Regression).
-ep, --epochs INTEGER Number of epochs (default 100).
-ba, --batch INTEGER Batch size (default 128).
-de, --depth INTEGER Depth of the convolutional layers (default
3).
-ch, --channels INTEGER First layer channels (default 64).
-fl, --filters TEXT Comma-separated list of filters for the
network. Either provide filters, or capacity
and depth.
-ld, --latent_dims INTEGER Latent space dimension (default 10).
-pd, --pose_dims INTEGER If pose on, number of pose dimensions. If 0
and gamma=0 it becomesa standard beta-VAE.
-bn_enc, --bnorm_encoder Batch normalisation in encoder is on if
True.
-bn_dec, --bnorm_decoder Batch normalisation in encoder is on if
True.
-gsdcl, --gsd_conv_layers INTEGER
The number of output channels for the
convolution layers at the end of the GSD
decoder
-spl, --n_splats INTEGER Number of Gaussian splats.
-kr, --klreduction TEXT Mean or sum reduction on KLD term.
-be, --beta FLOAT Beta maximum in the case of cyclical
annealing schedule
-bl, --beta_load The path to the saved beta array file to be
loaded if this file is provided, all other
beta related variables would be ignored
-g, --gamma FLOAT Scale factor for the loss component
corresponding to shape similarity. If 0 and
pd=0 it becomes a standardbeta-VAE.
-gl, --gamma_load The path to the saved gamma array file to be
loadedif this file is provided, all other
gamma related variables would be ignored
-lr, --learning FLOAT Learning rate.
-lf, --loss_fn TEXT Loss type: 'MSE' or 'BCE' (default 'MSE').
-bs, --beta_min FLOAT Beta minimum in the case of cyclical
annealing schedule
-bc, --beta_cycle INTEGER Number of cycles for beta during training in
the case of cyclical annealing schedule
-br, --beta_ratio FLOAT The ratio for steps in beta
-cycmb, --cyc_method_beta TEXT The schedule for : for constant beta : flat,
other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-gs, --gamma_min FLOAT gamma minimum in the case of cyclical
annealing schedule
-gc, --gamma_cycle INTEGER Number of cycles for gamma during training
in the case of cyclical annealing schedule
-gr, --gamma_ratio FLOAT The ratio for steps in gamma
-cycmg, --cyc_method_gamma TEXT
The schedule for gamma: for constant gamma :
flat, other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-g, --gpu Use GPU for training.
-ev, --eval Evaluate test data.
-dn, --dynamic Enable collecting meta and dynamic latent
space plots.
-m, --model TEXT Choose model to run. The choice of models
are a, b, u and gsd
-vl, --vis_los Visualise loss (every epoch starting at
epoch 2).
-vac, --vis_acc Visualise confusion matrix and F1 scores
(frequency controlled).
-vr, --vis_rec Visualise reconstructions (frequency
controlled).
-ve, --vis_emb Visualise latent space embedding (frequency
controlled).
-vi, --vis_int Visualise interpolations (frequency
controlled).
-vt, --vis_dis Visualise latent disentanglement (frequency
controlled).
-vps, --vis_pos Visualise pose disentanglement (frequency
controlled).
-vpsc, --vis_pose_class TEXT Example: A,B,C. your deliminator should be
commas and no spaces. Classes to be used for
pose interpolation (a seperate pose
interpolation figure would be created for
each class).
-vzni, --vis_z_n_int TEXT Number of Latent interpolation classes to to
be printed, number of interpolation steps in
each plot. Example: 1,10. 1 plot with 10
interpolation steps between two classes.
your deliminator should be commas and no
spaces.
-vc, --vis_cyc Visualise cyclical parameters (once per
run).
-va, --vis_aff Visualise affinity matrix (once per run).
-his, --vis_his Visualise train-val class distribution (once
per run).
-similarity, --vis_sim Visualise train-val model similarity matrix.
-va, --vis_all Visualise all above.
-vf, --vis_format TEXT The format of saved images. Options: png ,
pdf
-fev, --freq_eval INTEGER Frequency at which to evaluate test set.
-fs, --freq_sta INTEGER Frequency at which to save state
-fac, --freq_acc INTEGER Frequency at which to visualise confusion
matrix.
-fr, --freq_rec INTEGER Frequency at which to visualise
reconstructions
-fe, --freq_emb INTEGER Frequency at which to visualise the latent
space embedding.
-fi, --freq_int INTEGER Frequency at which to visualise latent
spaceinterpolations (default every 10
epochs).
-ft, --freq_dis INTEGER Frequency at which to visualise single
transversals.
-fp, --freq_pos INTEGER Frequency at which to visualise pose.
-fsim, --freq_sim INTEGER Frequency at which to visualise similarity
matrix.
-fa, --freq_all INTEGER Frequency at which to visualise all plots
except loss.
-opt, --opt_method TEXT The method of optimisation. It can be
adam/sgd/asgd
-gb, --gaussian_blur Applying gaussian bluring to the image data
which should help removing noise. The
minimum and maximum for this is hardcoded.
-nrm, --normalise Normalise data
-sftm, --shift_min Shift the minimum of the data to one zero
and the maximum to one
-res, --rescale INTEGER Rescale images to given value (tuple, one
value per dim).
-tb, --tensorboard Log metrics and figures to tensorboard
during training
-st, --strategy TEXT Define the strategy for distributed
training. Options are: 'ddp', 'deepspeed' or
'fsdp
--help Show this message and exit.

Note that setting -g/--gamma to 0 and -pd/--pose_dims to 0 will run a vanilla beta-VAE.

Configuring from the command line

You can run on example data with the following command:

python affinity-vae/run.py -d data/subtomo_files --split 20 --epochs 10 -ba 128 -lr 0.001 -de 4 -ch 64 -ld 8 -pd 3 --beta 1 --gamma 2 --limit 1000 --freq_all 5 --vis_all --dynamic

where the subtomo_files is a directory with a number of .mcr proteine image files named with the protein keyword such as (1BXN_m0_156_Th0.mrc,5MRC_m8_1347_Th0.mrc, etc). The subtomo_files directory should also have be a classes.csv file with a list of the protein names and keywords to be considered (1BXN, 5MRC, etc.) and a affinity_scores.csv matrix with the initial values for the proteins named in the classes.csv.

Using a config submission file

You can also run the code using a submission config file (you can find an example with default values on configs/avae-test-config.yml). For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml

You can also use a mix of config file and command line arguments. For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml --epochs 10 --affinity /path/to/different_affinity.csv

this will rewrite the values for the epochs and affinity path in the config file.

At the end of the run, the code will save the final config file used for the run in the working directory. This will account for any changes made to the config file from the command line. Running the code again with that config file will reproduce the results.

In the tools folder you can find notebooks which will assist you in creating the input files for Affinity-VAE or analyse teh output of the model.

Considerations

Test folder : If test folder is present, the program will read the test files regardless of the eval flag
Evaluation: To run evaluation on a trained model you can turn the eval flag to True. This will load the last model present on the states directory (within the working directory path where you run the code) and run the evaluation on data set by the datapath flag. The evaluation will be saved in the plots and latents directory with the eval suffix on the names.
The name of the state file consist of avae_date_time_Epoch_latent_pose.pt

Inspecting the results from Affinity-VAE

You can interact with the latent space and access reconstruction from the train model using Napari. You can find more information on how to use the Napari plugin in the README.md file in the scripts folder.

About

Self-supervised method for disentanglement, clustering and classification of objects in multidimensional image data

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

BlackTestspre-commit

Note: This a development version of the code. The code in the main branch is a more stable version of the code.

Affinity-VAE

Affinity-VAE for disentanglement, clustering and classification of objects in multidimensional image data
Mirecka J, Famili M, Kotanska A, Juraschko N, Costa-Gomes B, Palmer CM, Thiyagalingam J, Burnley T, Basham M & Lowe AR
doi:10.48550/arXiv.2209.04517

Installation

Installing with pip + virtual environments

Note: This has been tested in the develop branch.

You can install the libraries needed for this package on a fresh virtual environment with the following:

python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ."[all]"

If you are developing code, you should be able to run pre-commits and tests, therefore the best installation option after setting up the virtual environment is:

python -m pip install -e ."[test]"

run tests locally from this same working directory as installation (root of this repository):

python -m pytest -s -W ignore

Note: This is the preferred option for running on macOS laptops.

Warning: M1 macOS can not do pytorch paralelisation. A temporary solution for this is to modify the code on the DataLoaders in data.py to num_workers=0 in order to run the code. Otherwise, you will get the error: AttributeError: Can't pickle local object 'ProteinDataset.__init__.<locals>.<lambda>'.

Installing with pyenv in Baskerville

The following is the recommended way of installing all libraries in Baskervile.


module purge
module load baskerville
module load bask-apps/live
module load PyTorch/2.0.1-foss-2022a-CUDA-11.7.0
module load torchvision/0.15.2-foss-2022a-CUDA-11.7.0
python -m venv pyenv_affinity
source pyenv_affinity/bin/activate
git clone https://github.com/alan-turing-institute/affinity-vae.git
cd affinity-vae/
python -m pip install -e ."[baskerville]"

you can send a SLURM job to the cluster using the script in tools, with the following command:

sbatch slurm_run.sh

Running Affinity-VAE: A quick start

We have a tutorial on how to run Affinity-VAE on the MNIST dataset. We recommend to start there for the first time you run Affinity-VAE.

Affinity-VAE configuration parameters

Affinity-VAE has a running script (run.py) that allows you to configure and run the code. You can look at the available configuration options by running:

python run.py --help

which will give you:

Usage: run.py [OPTIONS]
Options:
--config_file PATH
-d, --datapath TEXT Path to training data.
-dtype, --datatype TEXT Type of the data: mrc, npy
-dbg, --debug Run in debug mode.
-res, --restart Is the calculation restarting from a
checkpoint.
-st, --state TEXT The saved model state to be loaded for
evaluation/resume training.
-mt, --meta TEXT The saved meta file to be loaded for
regenerating dynamic plots.
-lm, --limit INTEGER Limit the number of samples loaded (default
None).
-sp, --split INTEGER Train/val split in %.
-newo, --new_out Create new output directory where to save
the results.
-nd, --no_val_drop Do not drop last validate batch if if it is
smaller than batch_size.
-af, --affinity TEXT Path to affinity matrix for training.
-cl, --classes TEXT Path to a CSV file containing a list of
classes for training.
-clf, --classifier TEXT Method to classify the latent space. Options
are: KNN (nearest neighbour), NN (neural
network), LR (Logistic Regression).
-ep, --epochs INTEGER Number of epochs (default 100).
-ba, --batch INTEGER Batch size (default 128).
-de, --depth INTEGER Depth of the convolutional layers (default
3).
-ch, --channels INTEGER First layer channels (default 64).
-fl, --filters TEXT Comma-separated list of filters for the
network. Either provide filters, or capacity
and depth.
-ld, --latent_dims INTEGER Latent space dimension (default 10).
-pd, --pose_dims INTEGER If pose on, number of pose dimensions. If 0
and gamma=0 it becomesa standard beta-VAE.
-bn_enc, --bnorm_encoder Batch normalisation in encoder is on if
True.
-bn_dec, --bnorm_decoder Batch normalisation in encoder is on if
True.
-gsdcl, --gsd_conv_layers INTEGER
The number of output channels for the
convolution layers at the end of the GSD
decoder
-spl, --n_splats INTEGER Number of Gaussian splats.
-kr, --klreduction TEXT Mean or sum reduction on KLD term.
-be, --beta FLOAT Beta maximum in the case of cyclical
annealing schedule
-bl, --beta_load The path to the saved beta array file to be
loaded if this file is provided, all other
beta related variables would be ignored
-g, --gamma FLOAT Scale factor for the loss component
corresponding to shape similarity. If 0 and
pd=0 it becomes a standardbeta-VAE.
-gl, --gamma_load The path to the saved gamma array file to be
loadedif this file is provided, all other
gamma related variables would be ignored
-lr, --learning FLOAT Learning rate.
-lf, --loss_fn TEXT Loss type: 'MSE' or 'BCE' (default 'MSE').
-bs, --beta_min FLOAT Beta minimum in the case of cyclical
annealing schedule
-bc, --beta_cycle INTEGER Number of cycles for beta during training in
the case of cyclical annealing schedule
-br, --beta_ratio FLOAT The ratio for steps in beta
-cycmb, --cyc_method_beta TEXT The schedule for : for constant beta : flat,
other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-gs, --gamma_min FLOAT gamma minimum in the case of cyclical
annealing schedule
-gc, --gamma_cycle INTEGER Number of cycles for gamma during training
in the case of cyclical annealing schedule
-gr, --gamma_ratio FLOAT The ratio for steps in gamma
-cycmg, --cyc_method_gamma TEXT
The schedule for gamma: for constant gamma :
flat, other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-g, --gpu Use GPU for training.
-ev, --eval Evaluate test data.
-dn, --dynamic Enable collecting meta and dynamic latent
space plots.
-m, --model TEXT Choose model to run. The choice of models
are a, b, u and gsd
-vl, --vis_los Visualise loss (every epoch starting at
epoch 2).
-vac, --vis_acc Visualise confusion matrix and F1 scores
(frequency controlled).
-vr, --vis_rec Visualise reconstructions (frequency
controlled).
-ve, --vis_emb Visualise latent space embedding (frequency
controlled).
-vi, --vis_int Visualise interpolations (frequency
controlled).
-vt, --vis_dis Visualise latent disentanglement (frequency
controlled).
-vps, --vis_pos Visualise pose disentanglement (frequency
controlled).
-vpsc, --vis_pose_class TEXT Example: A,B,C. your deliminator should be
commas and no spaces. Classes to be used for
pose interpolation (a seperate pose
interpolation figure would be created for
each class).
-vzni, --vis_z_n_int TEXT Number of Latent interpolation classes to to
be printed, number of interpolation steps in
each plot. Example: 1,10. 1 plot with 10
interpolation steps between two classes.
your deliminator should be commas and no
spaces.
-vc, --vis_cyc Visualise cyclical parameters (once per
run).
-va, --vis_aff Visualise affinity matrix (once per run).
-his, --vis_his Visualise train-val class distribution (once
per run).
-similarity, --vis_sim Visualise train-val model similarity matrix.
-va, --vis_all Visualise all above.
-vf, --vis_format TEXT The format of saved images. Options: png ,
pdf
-fev, --freq_eval INTEGER Frequency at which to evaluate test set.
-fs, --freq_sta INTEGER Frequency at which to save state
-fac, --freq_acc INTEGER Frequency at which to visualise confusion
matrix.
-fr, --freq_rec INTEGER Frequency at which to visualise
reconstructions
-fe, --freq_emb INTEGER Frequency at which to visualise the latent
space embedding.
-fi, --freq_int INTEGER Frequency at which to visualise latent
spaceinterpolations (default every 10
epochs).
-ft, --freq_dis INTEGER Frequency at which to visualise single
transversals.
-fp, --freq_pos INTEGER Frequency at which to visualise pose.
-fsim, --freq_sim INTEGER Frequency at which to visualise similarity
matrix.
-fa, --freq_all INTEGER Frequency at which to visualise all plots
except loss.
-opt, --opt_method TEXT The method of optimisation. It can be
adam/sgd/asgd
-gb, --gaussian_blur Applying gaussian bluring to the image data
which should help removing noise. The
minimum and maximum for this is hardcoded.
-nrm, --normalise Normalise data
-sftm, --shift_min Shift the minimum of the data to one zero
and the maximum to one
-res, --rescale INTEGER Rescale images to given value (tuple, one
value per dim).
-tb, --tensorboard Log metrics and figures to tensorboard
during training
-st, --strategy TEXT Define the strategy for distributed
training. Options are: 'ddp', 'deepspeed' or
'fsdp
--help Show this message and exit.

Note that setting -g/--gamma to 0 and -pd/--pose_dims to 0 will run a vanilla beta-VAE.

Configuring from the command line

You can run on example data with the following command:

python affinity-vae/run.py -d data/subtomo_files --split 20 --epochs 10 -ba 128 -lr 0.001 -de 4 -ch 64 -ld 8 -pd 3 --beta 1 --gamma 2 --limit 1000 --freq_all 5 --vis_all --dynamic

where the subtomo_files is a directory with a number of .mcr proteine image files named with the protein keyword such as (1BXN_m0_156_Th0.mrc,5MRC_m8_1347_Th0.mrc, etc). The subtomo_files directory should also have be a classes.csv file with a list of the protein names and keywords to be considered (1BXN, 5MRC, etc.) and a affinity_scores.csv matrix with the initial values for the proteins named in the classes.csv.

Using a config submission file

You can also run the code using a submission config file (you can find an example with default values on configs/avae-test-config.yml). For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml

You can also use a mix of config file and command line arguments. For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml --epochs 10 --affinity /path/to/different_affinity.csv

this will rewrite the values for the epochs and affinity path in the config file.

At the end of the run, the code will save the final config file used for the run in the working directory. This will account for any changes made to the config file from the command line. Running the code again with that config file will reproduce the results.

In the tools folder you can find notebooks which will assist you in creating the input files for Affinity-VAE or analyse teh output of the model.

Considerations

Test folder : If test folder is present, the program will read the test files regardless of the eval flag
Evaluation: To run evaluation on a trained model you can turn the eval flag to True. This will load the last model present on the states directory (within the working directory path where you run the code) and run the evaluation on data set by the datapath flag. The evaluation will be saved in the plots and latents directory with the eval suffix on the names.
The name of the state file consist of avae_date_time_Epoch_latent_pose.pt

Inspecting the results from Affinity-VAE

You can interact with the latent space and access reconstruction from the train model using Napari. You can find more information on how to use the Napari plugin in the README.md file in the scripts folder.

About

Self-supervised method for disentanglement, clustering and classification of objects in multidimensional image data

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

BlackTestspre-commit

Note: This a development version of the code. The code in the main branch is a more stable version of the code.

Affinity-VAE

Affinity-VAE for disentanglement, clustering and classification of objects in multidimensional image data
Mirecka J, Famili M, Kotanska A, Juraschko N, Costa-Gomes B, Palmer CM, Thiyagalingam J, Burnley T, Basham M & Lowe AR
doi:10.48550/arXiv.2209.04517

Installation

Installing with pip + virtual environments

Note: This has been tested in the develop branch.

You can install the libraries needed for this package on a fresh virtual environment with the following:

python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ."[all]"

If you are developing code, you should be able to run pre-commits and tests, therefore the best installation option after setting up the virtual environment is:

python -m pip install -e ."[test]"

run tests locally from this same working directory as installation (root of this repository):

python -m pytest -s -W ignore

Note: This is the preferred option for running on macOS laptops.

Warning: M1 macOS can not do pytorch paralelisation. A temporary solution for this is to modify the code on the DataLoaders in data.py to num_workers=0 in order to run the code. Otherwise, you will get the error: AttributeError: Can't pickle local object 'ProteinDataset.__init__.<locals>.<lambda>'.

Installing with pyenv in Baskerville

The following is the recommended way of installing all libraries in Baskervile.


module purge
module load baskerville
module load bask-apps/live
module load PyTorch/2.0.1-foss-2022a-CUDA-11.7.0
module load torchvision/0.15.2-foss-2022a-CUDA-11.7.0
python -m venv pyenv_affinity
source pyenv_affinity/bin/activate
git clone https://github.com/alan-turing-institute/affinity-vae.git
cd affinity-vae/
python -m pip install -e ."[baskerville]"

you can send a SLURM job to the cluster using the script in tools, with the following command:

sbatch slurm_run.sh

Running Affinity-VAE: A quick start

We have a tutorial on how to run Affinity-VAE on the MNIST dataset. We recommend to start there for the first time you run Affinity-VAE.

Affinity-VAE configuration parameters

Affinity-VAE has a running script (run.py) that allows you to configure and run the code. You can look at the available configuration options by running:

python run.py --help

which will give you:

Usage: run.py [OPTIONS]
Options:
--config_file PATH
-d, --datapath TEXT Path to training data.
-dtype, --datatype TEXT Type of the data: mrc, npy
-dbg, --debug Run in debug mode.
-res, --restart Is the calculation restarting from a
checkpoint.
-st, --state TEXT The saved model state to be loaded for
evaluation/resume training.
-mt, --meta TEXT The saved meta file to be loaded for
regenerating dynamic plots.
-lm, --limit INTEGER Limit the number of samples loaded (default
None).
-sp, --split INTEGER Train/val split in %.
-newo, --new_out Create new output directory where to save
the results.
-nd, --no_val_drop Do not drop last validate batch if if it is
smaller than batch_size.
-af, --affinity TEXT Path to affinity matrix for training.
-cl, --classes TEXT Path to a CSV file containing a list of
classes for training.
-clf, --classifier TEXT Method to classify the latent space. Options
are: KNN (nearest neighbour), NN (neural
network), LR (Logistic Regression).
-ep, --epochs INTEGER Number of epochs (default 100).
-ba, --batch INTEGER Batch size (default 128).
-de, --depth INTEGER Depth of the convolutional layers (default
3).
-ch, --channels INTEGER First layer channels (default 64).
-fl, --filters TEXT Comma-separated list of filters for the
network. Either provide filters, or capacity
and depth.
-ld, --latent_dims INTEGER Latent space dimension (default 10).
-pd, --pose_dims INTEGER If pose on, number of pose dimensions. If 0
and gamma=0 it becomesa standard beta-VAE.
-bn_enc, --bnorm_encoder Batch normalisation in encoder is on if
True.
-bn_dec, --bnorm_decoder Batch normalisation in encoder is on if
True.
-gsdcl, --gsd_conv_layers INTEGER
The number of output channels for the
convolution layers at the end of the GSD
decoder
-spl, --n_splats INTEGER Number of Gaussian splats.
-kr, --klreduction TEXT Mean or sum reduction on KLD term.
-be, --beta FLOAT Beta maximum in the case of cyclical
annealing schedule
-bl, --beta_load The path to the saved beta array file to be
loaded if this file is provided, all other
beta related variables would be ignored
-g, --gamma FLOAT Scale factor for the loss component
corresponding to shape similarity. If 0 and
pd=0 it becomes a standardbeta-VAE.
-gl, --gamma_load The path to the saved gamma array file to be
loadedif this file is provided, all other
gamma related variables would be ignored
-lr, --learning FLOAT Learning rate.
-lf, --loss_fn TEXT Loss type: 'MSE' or 'BCE' (default 'MSE').
-bs, --beta_min FLOAT Beta minimum in the case of cyclical
annealing schedule
-bc, --beta_cycle INTEGER Number of cycles for beta during training in
the case of cyclical annealing schedule
-br, --beta_ratio FLOAT The ratio for steps in beta
-cycmb, --cyc_method_beta TEXT The schedule for : for constant beta : flat,
other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-gs, --gamma_min FLOAT gamma minimum in the case of cyclical
annealing schedule
-gc, --gamma_cycle INTEGER Number of cycles for gamma during training
in the case of cyclical annealing schedule
-gr, --gamma_ratio FLOAT The ratio for steps in gamma
-cycmg, --cyc_method_gamma TEXT
The schedule for gamma: for constant gamma :
flat, other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-g, --gpu Use GPU for training.
-ev, --eval Evaluate test data.
-dn, --dynamic Enable collecting meta and dynamic latent
space plots.
-m, --model TEXT Choose model to run. The choice of models
are a, b, u and gsd
-vl, --vis_los Visualise loss (every epoch starting at
epoch 2).
-vac, --vis_acc Visualise confusion matrix and F1 scores
(frequency controlled).
-vr, --vis_rec Visualise reconstructions (frequency
controlled).
-ve, --vis_emb Visualise latent space embedding (frequency
controlled).
-vi, --vis_int Visualise interpolations (frequency
controlled).
-vt, --vis_dis Visualise latent disentanglement (frequency
controlled).
-vps, --vis_pos Visualise pose disentanglement (frequency
controlled).
-vpsc, --vis_pose_class TEXT Example: A,B,C. your deliminator should be
commas and no spaces. Classes to be used for
pose interpolation (a seperate pose
interpolation figure would be created for
each class).
-vzni, --vis_z_n_int TEXT Number of Latent interpolation classes to to
be printed, number of interpolation steps in
each plot. Example: 1,10. 1 plot with 10
interpolation steps between two classes.
your deliminator should be commas and no
spaces.
-vc, --vis_cyc Visualise cyclical parameters (once per
run).
-va, --vis_aff Visualise affinity matrix (once per run).
-his, --vis_his Visualise train-val class distribution (once
per run).
-similarity, --vis_sim Visualise train-val model similarity matrix.
-va, --vis_all Visualise all above.
-vf, --vis_format TEXT The format of saved images. Options: png ,
pdf
-fev, --freq_eval INTEGER Frequency at which to evaluate test set.
-fs, --freq_sta INTEGER Frequency at which to save state
-fac, --freq_acc INTEGER Frequency at which to visualise confusion
matrix.
-fr, --freq_rec INTEGER Frequency at which to visualise
reconstructions
-fe, --freq_emb INTEGER Frequency at which to visualise the latent
space embedding.
-fi, --freq_int INTEGER Frequency at which to visualise latent
spaceinterpolations (default every 10
epochs).
-ft, --freq_dis INTEGER Frequency at which to visualise single
transversals.
-fp, --freq_pos INTEGER Frequency at which to visualise pose.
-fsim, --freq_sim INTEGER Frequency at which to visualise similarity
matrix.
-fa, --freq_all INTEGER Frequency at which to visualise all plots
except loss.
-opt, --opt_method TEXT The method of optimisation. It can be
adam/sgd/asgd
-gb, --gaussian_blur Applying gaussian bluring to the image data
which should help removing noise. The
minimum and maximum for this is hardcoded.
-nrm, --normalise Normalise data
-sftm, --shift_min Shift the minimum of the data to one zero
and the maximum to one
-res, --rescale INTEGER Rescale images to given value (tuple, one
value per dim).
-tb, --tensorboard Log metrics and figures to tensorboard
during training
-st, --strategy TEXT Define the strategy for distributed
training. Options are: 'ddp', 'deepspeed' or
'fsdp
--help Show this message and exit.

Note that setting -g/--gamma to 0 and -pd/--pose_dims to 0 will run a vanilla beta-VAE.

Configuring from the command line

You can run on example data with the following command:

python affinity-vae/run.py -d data/subtomo_files --split 20 --epochs 10 -ba 128 -lr 0.001 -de 4 -ch 64 -ld 8 -pd 3 --beta 1 --gamma 2 --limit 1000 --freq_all 5 --vis_all --dynamic

where the subtomo_files is a directory with a number of .mcr proteine image files named with the protein keyword such as (1BXN_m0_156_Th0.mrc,5MRC_m8_1347_Th0.mrc, etc). The subtomo_files directory should also have be a classes.csv file with a list of the protein names and keywords to be considered (1BXN, 5MRC, etc.) and a affinity_scores.csv matrix with the initial values for the proteins named in the classes.csv.

Using a config submission file

You can also run the code using a submission config file (you can find an example with default values on configs/avae-test-config.yml). For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml

You can also use a mix of config file and command line arguments. For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml --epochs 10 --affinity /path/to/different_affinity.csv

this will rewrite the values for the epochs and affinity path in the config file.

At the end of the run, the code will save the final config file used for the run in the working directory. This will account for any changes made to the config file from the command line. Running the code again with that config file will reproduce the results.

In the tools folder you can find notebooks which will assist you in creating the input files for Affinity-VAE or analyse teh output of the model.

Considerations

Test folder : If test folder is present, the program will read the test files regardless of the eval flag
Evaluation: To run evaluation on a trained model you can turn the eval flag to True. This will load the last model present on the states directory (within the working directory path where you run the code) and run the evaluation on data set by the datapath flag. The evaluation will be saved in the plots and latents directory with the eval suffix on the names.
The name of the state file consist of avae_date_time_Epoch_latent_pose.pt

Inspecting the results from Affinity-VAE

You can interact with the latent space and access reconstruction from the train model using Napari. You can find more information on how to use the Napari plugin in the README.md file in the scripts folder.

About

Self-supervised method for disentanglement, clustering and classification of objects in multidimensional image data

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

BlackTestspre-commit

Note: This a development version of the code. The code in the main branch is a more stable version of the code.

Affinity-VAE

Affinity-VAE for disentanglement, clustering and classification of objects in multidimensional image data
Mirecka J, Famili M, Kotanska A, Juraschko N, Costa-Gomes B, Palmer CM, Thiyagalingam J, Burnley T, Basham M & Lowe AR
doi:10.48550/arXiv.2209.04517

Installation

Installing with pip + virtual environments

Note: This has been tested in the develop branch.

You can install the libraries needed for this package on a fresh virtual environment with the following:

python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ."[all]"

If you are developing code, you should be able to run pre-commits and tests, therefore the best installation option after setting up the virtual environment is:

python -m pip install -e ."[test]"

run tests locally from this same working directory as installation (root of this repository):

python -m pytest -s -W ignore

Note: This is the preferred option for running on macOS laptops.

Warning: M1 macOS can not do pytorch paralelisation. A temporary solution for this is to modify the code on the DataLoaders in data.py to num_workers=0 in order to run the code. Otherwise, you will get the error: AttributeError: Can't pickle local object 'ProteinDataset.__init__.<locals>.<lambda>'.

Installing with pyenv in Baskerville

The following is the recommended way of installing all libraries in Baskervile.


module purge
module load baskerville
module load bask-apps/live
module load PyTorch/2.0.1-foss-2022a-CUDA-11.7.0
module load torchvision/0.15.2-foss-2022a-CUDA-11.7.0
python -m venv pyenv_affinity
source pyenv_affinity/bin/activate
git clone https://github.com/alan-turing-institute/affinity-vae.git
cd affinity-vae/
python -m pip install -e ."[baskerville]"

you can send a SLURM job to the cluster using the script in tools, with the following command:

sbatch slurm_run.sh

Running Affinity-VAE: A quick start

We have a tutorial on how to run Affinity-VAE on the MNIST dataset. We recommend to start there for the first time you run Affinity-VAE.

Affinity-VAE configuration parameters

Affinity-VAE has a running script (run.py) that allows you to configure and run the code. You can look at the available configuration options by running:

python run.py --help

which will give you:

Usage: run.py [OPTIONS]
Options:
--config_file PATH
-d, --datapath TEXT Path to training data.
-dtype, --datatype TEXT Type of the data: mrc, npy
-dbg, --debug Run in debug mode.
-res, --restart Is the calculation restarting from a
checkpoint.
-st, --state TEXT The saved model state to be loaded for
evaluation/resume training.
-mt, --meta TEXT The saved meta file to be loaded for
regenerating dynamic plots.
-lm, --limit INTEGER Limit the number of samples loaded (default
None).
-sp, --split INTEGER Train/val split in %.
-newo, --new_out Create new output directory where to save
the results.
-nd, --no_val_drop Do not drop last validate batch if if it is
smaller than batch_size.
-af, --affinity TEXT Path to affinity matrix for training.
-cl, --classes TEXT Path to a CSV file containing a list of
classes for training.
-clf, --classifier TEXT Method to classify the latent space. Options
are: KNN (nearest neighbour), NN (neural
network), LR (Logistic Regression).
-ep, --epochs INTEGER Number of epochs (default 100).
-ba, --batch INTEGER Batch size (default 128).
-de, --depth INTEGER Depth of the convolutional layers (default
3).
-ch, --channels INTEGER First layer channels (default 64).
-fl, --filters TEXT Comma-separated list of filters for the
network. Either provide filters, or capacity
and depth.
-ld, --latent_dims INTEGER Latent space dimension (default 10).
-pd, --pose_dims INTEGER If pose on, number of pose dimensions. If 0
and gamma=0 it becomesa standard beta-VAE.
-bn_enc, --bnorm_encoder Batch normalisation in encoder is on if
True.
-bn_dec, --bnorm_decoder Batch normalisation in encoder is on if
True.
-gsdcl, --gsd_conv_layers INTEGER
The number of output channels for the
convolution layers at the end of the GSD
decoder
-spl, --n_splats INTEGER Number of Gaussian splats.
-kr, --klreduction TEXT Mean or sum reduction on KLD term.
-be, --beta FLOAT Beta maximum in the case of cyclical
annealing schedule
-bl, --beta_load The path to the saved beta array file to be
loaded if this file is provided, all other
beta related variables would be ignored
-g, --gamma FLOAT Scale factor for the loss component
corresponding to shape similarity. If 0 and
pd=0 it becomes a standardbeta-VAE.
-gl, --gamma_load The path to the saved gamma array file to be
loadedif this file is provided, all other
gamma related variables would be ignored
-lr, --learning FLOAT Learning rate.
-lf, --loss_fn TEXT Loss type: 'MSE' or 'BCE' (default 'MSE').
-bs, --beta_min FLOAT Beta minimum in the case of cyclical
annealing schedule
-bc, --beta_cycle INTEGER Number of cycles for beta during training in
the case of cyclical annealing schedule
-br, --beta_ratio FLOAT The ratio for steps in beta
-cycmb, --cyc_method_beta TEXT The schedule for : for constant beta : flat,
other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-gs, --gamma_min FLOAT gamma minimum in the case of cyclical
annealing schedule
-gc, --gamma_cycle INTEGER Number of cycles for gamma during training
in the case of cyclical annealing schedule
-gr, --gamma_ratio FLOAT The ratio for steps in gamma
-cycmg, --cyc_method_gamma TEXT
The schedule for gamma: for constant gamma :
flat, other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-g, --gpu Use GPU for training.
-ev, --eval Evaluate test data.
-dn, --dynamic Enable collecting meta and dynamic latent
space plots.
-m, --model TEXT Choose model to run. The choice of models
are a, b, u and gsd
-vl, --vis_los Visualise loss (every epoch starting at
epoch 2).
-vac, --vis_acc Visualise confusion matrix and F1 scores
(frequency controlled).
-vr, --vis_rec Visualise reconstructions (frequency
controlled).
-ve, --vis_emb Visualise latent space embedding (frequency
controlled).
-vi, --vis_int Visualise interpolations (frequency
controlled).
-vt, --vis_dis Visualise latent disentanglement (frequency
controlled).
-vps, --vis_pos Visualise pose disentanglement (frequency
controlled).
-vpsc, --vis_pose_class TEXT Example: A,B,C. your deliminator should be
commas and no spaces. Classes to be used for
pose interpolation (a seperate pose
interpolation figure would be created for
each class).
-vzni, --vis_z_n_int TEXT Number of Latent interpolation classes to to
be printed, number of interpolation steps in
each plot. Example: 1,10. 1 plot with 10
interpolation steps between two classes.
your deliminator should be commas and no
spaces.
-vc, --vis_cyc Visualise cyclical parameters (once per
run).
-va, --vis_aff Visualise affinity matrix (once per run).
-his, --vis_his Visualise train-val class distribution (once
per run).
-similarity, --vis_sim Visualise train-val model similarity matrix.
-va, --vis_all Visualise all above.
-vf, --vis_format TEXT The format of saved images. Options: png ,
pdf
-fev, --freq_eval INTEGER Frequency at which to evaluate test set.
-fs, --freq_sta INTEGER Frequency at which to save state
-fac, --freq_acc INTEGER Frequency at which to visualise confusion
matrix.
-fr, --freq_rec INTEGER Frequency at which to visualise
reconstructions
-fe, --freq_emb INTEGER Frequency at which to visualise the latent
space embedding.
-fi, --freq_int INTEGER Frequency at which to visualise latent
spaceinterpolations (default every 10
epochs).
-ft, --freq_dis INTEGER Frequency at which to visualise single
transversals.
-fp, --freq_pos INTEGER Frequency at which to visualise pose.
-fsim, --freq_sim INTEGER Frequency at which to visualise similarity
matrix.
-fa, --freq_all INTEGER Frequency at which to visualise all plots
except loss.
-opt, --opt_method TEXT The method of optimisation. It can be
adam/sgd/asgd
-gb, --gaussian_blur Applying gaussian bluring to the image data
which should help removing noise. The
minimum and maximum for this is hardcoded.
-nrm, --normalise Normalise data
-sftm, --shift_min Shift the minimum of the data to one zero
and the maximum to one
-res, --rescale INTEGER Rescale images to given value (tuple, one
value per dim).
-tb, --tensorboard Log metrics and figures to tensorboard
during training
-st, --strategy TEXT Define the strategy for distributed
training. Options are: 'ddp', 'deepspeed' or
'fsdp
--help Show this message and exit.

Note that setting -g/--gamma to 0 and -pd/--pose_dims to 0 will run a vanilla beta-VAE.

Configuring from the command line

You can run on example data with the following command:

python affinity-vae/run.py -d data/subtomo_files --split 20 --epochs 10 -ba 128 -lr 0.001 -de 4 -ch 64 -ld 8 -pd 3 --beta 1 --gamma 2 --limit 1000 --freq_all 5 --vis_all --dynamic

where the subtomo_files is a directory with a number of .mcr proteine image files named with the protein keyword such as (1BXN_m0_156_Th0.mrc,5MRC_m8_1347_Th0.mrc, etc). The subtomo_files directory should also have be a classes.csv file with a list of the protein names and keywords to be considered (1BXN, 5MRC, etc.) and a affinity_scores.csv matrix with the initial values for the proteins named in the classes.csv.

Using a config submission file

You can also run the code using a submission config file (you can find an example with default values on configs/avae-test-config.yml). For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml

You can also use a mix of config file and command line arguments. For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml --epochs 10 --affinity /path/to/different_affinity.csv

this will rewrite the values for the epochs and affinity path in the config file.

At the end of the run, the code will save the final config file used for the run in the working directory. This will account for any changes made to the config file from the command line. Running the code again with that config file will reproduce the results.

In the tools folder you can find notebooks which will assist you in creating the input files for Affinity-VAE or analyse teh output of the model.

Considerations

Test folder : If test folder is present, the program will read the test files regardless of the eval flag
Evaluation: To run evaluation on a trained model you can turn the eval flag to True. This will load the last model present on the states directory (within the working directory path where you run the code) and run the evaluation on data set by the datapath flag. The evaluation will be saved in the plots and latents directory with the eval suffix on the names.
The name of the state file consist of avae_date_time_Epoch_latent_pose.pt

Inspecting the results from Affinity-VAE

You can interact with the latent space and access reconstruction from the train model using Napari. You can find more information on how to use the Napari plugin in the README.md file in the scripts folder.

About

Self-supervised method for disentanglement, clustering and classification of objects in multidimensional image data

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

BlackTestspre-commit

Note: This a development version of the code. The code in the main branch is a more stable version of the code.

Affinity-VAE

Affinity-VAE for disentanglement, clustering and classification of objects in multidimensional image data
Mirecka J, Famili M, Kotanska A, Juraschko N, Costa-Gomes B, Palmer CM, Thiyagalingam J, Burnley T, Basham M & Lowe AR
doi:10.48550/arXiv.2209.04517

Installation

Installing with pip + virtual environments

Note: This has been tested in the develop branch.

You can install the libraries needed for this package on a fresh virtual environment with the following:

python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ."[all]"

If you are developing code, you should be able to run pre-commits and tests, therefore the best installation option after setting up the virtual environment is:

python -m pip install -e ."[test]"

run tests locally from this same working directory as installation (root of this repository):

python -m pytest -s -W ignore

Note: This is the preferred option for running on macOS laptops.

Warning: M1 macOS can not do pytorch paralelisation. A temporary solution for this is to modify the code on the DataLoaders in data.py to num_workers=0 in order to run the code. Otherwise, you will get the error: AttributeError: Can't pickle local object 'ProteinDataset.__init__.<locals>.<lambda>'.

Installing with pyenv in Baskerville

The following is the recommended way of installing all libraries in Baskervile.


module purge
module load baskerville
module load bask-apps/live
module load PyTorch/2.0.1-foss-2022a-CUDA-11.7.0
module load torchvision/0.15.2-foss-2022a-CUDA-11.7.0
python -m venv pyenv_affinity
source pyenv_affinity/bin/activate
git clone https://github.com/alan-turing-institute/affinity-vae.git
cd affinity-vae/
python -m pip install -e ."[baskerville]"

you can send a SLURM job to the cluster using the script in tools, with the following command:

sbatch slurm_run.sh

Running Affinity-VAE: A quick start

We have a tutorial on how to run Affinity-VAE on the MNIST dataset. We recommend to start there for the first time you run Affinity-VAE.

Affinity-VAE configuration parameters

Affinity-VAE has a running script (run.py) that allows you to configure and run the code. You can look at the available configuration options by running:

python run.py --help

which will give you:

Usage: run.py [OPTIONS]
Options:
--config_file PATH
-d, --datapath TEXT Path to training data.
-dtype, --datatype TEXT Type of the data: mrc, npy
-dbg, --debug Run in debug mode.
-res, --restart Is the calculation restarting from a
checkpoint.
-st, --state TEXT The saved model state to be loaded for
evaluation/resume training.
-mt, --meta TEXT The saved meta file to be loaded for
regenerating dynamic plots.
-lm, --limit INTEGER Limit the number of samples loaded (default
None).
-sp, --split INTEGER Train/val split in %.
-newo, --new_out Create new output directory where to save
the results.
-nd, --no_val_drop Do not drop last validate batch if if it is
smaller than batch_size.
-af, --affinity TEXT Path to affinity matrix for training.
-cl, --classes TEXT Path to a CSV file containing a list of
classes for training.
-clf, --classifier TEXT Method to classify the latent space. Options
are: KNN (nearest neighbour), NN (neural
network), LR (Logistic Regression).
-ep, --epochs INTEGER Number of epochs (default 100).
-ba, --batch INTEGER Batch size (default 128).
-de, --depth INTEGER Depth of the convolutional layers (default
3).
-ch, --channels INTEGER First layer channels (default 64).
-fl, --filters TEXT Comma-separated list of filters for the
network. Either provide filters, or capacity
and depth.
-ld, --latent_dims INTEGER Latent space dimension (default 10).
-pd, --pose_dims INTEGER If pose on, number of pose dimensions. If 0
and gamma=0 it becomesa standard beta-VAE.
-bn_enc, --bnorm_encoder Batch normalisation in encoder is on if
True.
-bn_dec, --bnorm_decoder Batch normalisation in encoder is on if
True.
-gsdcl, --gsd_conv_layers INTEGER
The number of output channels for the
convolution layers at the end of the GSD
decoder
-spl, --n_splats INTEGER Number of Gaussian splats.
-kr, --klreduction TEXT Mean or sum reduction on KLD term.
-be, --beta FLOAT Beta maximum in the case of cyclical
annealing schedule
-bl, --beta_load The path to the saved beta array file to be
loaded if this file is provided, all other
beta related variables would be ignored
-g, --gamma FLOAT Scale factor for the loss component
corresponding to shape similarity. If 0 and
pd=0 it becomes a standardbeta-VAE.
-gl, --gamma_load The path to the saved gamma array file to be
loadedif this file is provided, all other
gamma related variables would be ignored
-lr, --learning FLOAT Learning rate.
-lf, --loss_fn TEXT Loss type: 'MSE' or 'BCE' (default 'MSE').
-bs, --beta_min FLOAT Beta minimum in the case of cyclical
annealing schedule
-bc, --beta_cycle INTEGER Number of cycles for beta during training in
the case of cyclical annealing schedule
-br, --beta_ratio FLOAT The ratio for steps in beta
-cycmb, --cyc_method_beta TEXT The schedule for : for constant beta : flat,
other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-gs, --gamma_min FLOAT gamma minimum in the case of cyclical
annealing schedule
-gc, --gamma_cycle INTEGER Number of cycles for gamma during training
in the case of cyclical annealing schedule
-gr, --gamma_ratio FLOAT The ratio for steps in gamma
-cycmg, --cyc_method_gamma TEXT
The schedule for gamma: for constant gamma :
flat, other options include , cycle_linear,
cycle_sigmoid, cycle_cosine, ramp
-g, --gpu Use GPU for training.
-ev, --eval Evaluate test data.
-dn, --dynamic Enable collecting meta and dynamic latent
space plots.
-m, --model TEXT Choose model to run. The choice of models
are a, b, u and gsd
-vl, --vis_los Visualise loss (every epoch starting at
epoch 2).
-vac, --vis_acc Visualise confusion matrix and F1 scores
(frequency controlled).
-vr, --vis_rec Visualise reconstructions (frequency
controlled).
-ve, --vis_emb Visualise latent space embedding (frequency
controlled).
-vi, --vis_int Visualise interpolations (frequency
controlled).
-vt, --vis_dis Visualise latent disentanglement (frequency
controlled).
-vps, --vis_pos Visualise pose disentanglement (frequency
controlled).
-vpsc, --vis_pose_class TEXT Example: A,B,C. your deliminator should be
commas and no spaces. Classes to be used for
pose interpolation (a seperate pose
interpolation figure would be created for
each class).
-vzni, --vis_z_n_int TEXT Number of Latent interpolation classes to to
be printed, number of interpolation steps in
each plot. Example: 1,10. 1 plot with 10
interpolation steps between two classes.
your deliminator should be commas and no
spaces.
-vc, --vis_cyc Visualise cyclical parameters (once per
run).
-va, --vis_aff Visualise affinity matrix (once per run).
-his, --vis_his Visualise train-val class distribution (once
per run).
-similarity, --vis_sim Visualise train-val model similarity matrix.
-va, --vis_all Visualise all above.
-vf, --vis_format TEXT The format of saved images. Options: png ,
pdf
-fev, --freq_eval INTEGER Frequency at which to evaluate test set.
-fs, --freq_sta INTEGER Frequency at which to save state
-fac, --freq_acc INTEGER Frequency at which to visualise confusion
matrix.
-fr, --freq_rec INTEGER Frequency at which to visualise
reconstructions
-fe, --freq_emb INTEGER Frequency at which to visualise the latent
space embedding.
-fi, --freq_int INTEGER Frequency at which to visualise latent
spaceinterpolations (default every 10
epochs).
-ft, --freq_dis INTEGER Frequency at which to visualise single
transversals.
-fp, --freq_pos INTEGER Frequency at which to visualise pose.
-fsim, --freq_sim INTEGER Frequency at which to visualise similarity
matrix.
-fa, --freq_all INTEGER Frequency at which to visualise all plots
except loss.
-opt, --opt_method TEXT The method of optimisation. It can be
adam/sgd/asgd
-gb, --gaussian_blur Applying gaussian bluring to the image data
which should help removing noise. The
minimum and maximum for this is hardcoded.
-nrm, --normalise Normalise data
-sftm, --shift_min Shift the minimum of the data to one zero
and the maximum to one
-res, --rescale INTEGER Rescale images to given value (tuple, one
value per dim).
-tb, --tensorboard Log metrics and figures to tensorboard
during training
-st, --strategy TEXT Define the strategy for distributed
training. Options are: 'ddp', 'deepspeed' or
'fsdp
--help Show this message and exit.

Note that setting -g/--gamma to 0 and -pd/--pose_dims to 0 will run a vanilla beta-VAE.

Configuring from the command line

You can run on example data with the following command:

python affinity-vae/run.py -d data/subtomo_files --split 20 --epochs 10 -ba 128 -lr 0.001 -de 4 -ch 64 -ld 8 -pd 3 --beta 1 --gamma 2 --limit 1000 --freq_all 5 --vis_all --dynamic

where the subtomo_files is a directory with a number of .mcr proteine image files named with the protein keyword such as (1BXN_m0_156_Th0.mrc,5MRC_m8_1347_Th0.mrc, etc). The subtomo_files directory should also have be a classes.csv file with a list of the protein names and keywords to be considered (1BXN, 5MRC, etc.) and a affinity_scores.csv matrix with the initial values for the proteins named in the classes.csv.

Using a config submission file

You can also run the code using a submission config file (you can find an example with default values on configs/avae-test-config.yml). For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml

You can also use a mix of config file and command line arguments. For example, you can run the following command:

python affinity-vae/run.py --config_file affinity-vae/configs/avae-test-config.yml --epochs 10 --affinity /path/to/different_affinity.csv

this will rewrite the values for the epochs and affinity path in the config file.

At the end of the run, the code will save the final config file used for the run in the working directory. This will account for any changes made to the config file from the command line. Running the code again with that config file will reproduce the results.

In the tools folder you can find notebooks which will assist you in creating the input files for Affinity-VAE or analyse teh output of the model.

Considerations

Test folder : If test folder is present, the program will read the test files regardless of the eval flag
Evaluation: To run evaluation on a trained model you can turn the eval flag to True. This will load the last model present on the states directory (within the working directory path where you run the code) and run the evaluation on data set by the datapath flag. The evaluation will be saved in the plots and latents directory with the eval suffix on the names.
The name of the state file consist of avae_date_time_Epoch_latent_pose.pt

Inspecting the results from Affinity-VAE

You can interact with the latent space and access reconstruction from the train model using Napari. You can find more information on how to use the Napari plugin in the README.md file in the scripts folder.

About

Self-supervised method for disentanglement, clustering and classification of objects in multidimensional image data

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages