Metadata-Version: 2.1
Name: cyto-dl
Version: 0.1.4
Summary: Collection of representation learning models, techniques, callbacks, utils, used to create latent variable models of cell shape, morphology and intracellular organization.
Author-email: Benji Morris <benjamin.morris@alleninstitute.org>,Guilherme Pires <guilherme.pires@alleninstitute.org>,Ritvik Vasan <ritvik.vasan@alleninstitute.org>
Requires-Python: >=3.8,<3.11
Requires-Dist: PyYAML~=6.0
Requires-Dist: aicsimageio~=4.11.0
Requires-Dist: anndata~=0.8
Requires-Dist: astropy~=5.2
Requires-Dist: bfio==2.3.0
Requires-Dist: edt>=2.3.1
Requires-Dist: einops>=0.6.1
Requires-Dist: fire~=0.5
Requires-Dist: hydra-colorlog~=1.2
Requires-Dist: hydra-core~=1.3
Requires-Dist: hydra-optuna-sweeper~=1.2
Requires-Dist: joblib~=1.2
Requires-Dist: lightning<2.1,>=2.0
Requires-Dist: matplotlib~=3.7
Requires-Dist: mlflow~=2.1
Requires-Dist: monai-weekly>=1.2.dev2308
Requires-Dist: numpy~=1.23
Requires-Dist: ome-zarr~=0.6
Requires-Dist: omegaconf~=2.3
Requires-Dist: ostat>=0.2
Requires-Dist: pandas~=1.5
Requires-Dist: protobuf<=3.20.1
Requires-Dist: pyarrow~=10.0
Requires-Dist: pyrootutils~=1.0
Requires-Dist: scikit-learn~=1.2
Requires-Dist: tifffile~=2023.2
Requires-Dist: timm>=0.9.7
Requires-Dist: torch<2.1,>=2.0
Requires-Dist: tqdm~=4.64
Requires-Dist: universal-pathlib~=0.0
Provides-Extra: all
Requires-Dist: cyto-dl[equiv,pcloud,s3,spharm,torchserve]; extra == "all"
Provides-Extra: docs
Requires-Dist: cyto-dl[all]; extra == "docs"
Requires-Dist: furo<=2023.3.23; extra == "docs"
Requires-Dist: m2r2<=0.3.3.post2; extra == "docs"
Requires-Dist: sphinx<=6.1.3; extra == "docs"
Provides-Extra: equiv
Requires-Dist: lie_learn==0.0.1.post1; extra == "equiv"
Requires-Dist: escnn~=1.0.7; extra == "equiv"
Requires-Dist: py3nj==0.1.2; extra == "equiv"
Requires-Dist: e3nn~=0.5.1; extra == "equiv"
Provides-Extra: pcloud
Requires-Dist: pyntcloud>=0.3.1; extra == "pcloud"
Requires-Dist: aicsshparam>=0.1.7; extra == "pcloud"
Requires-Dist: torch-geometric>=2.3.1; extra == "pcloud"
Requires-Dist: point-cloud-utils>=0.29.6; extra == "pcloud"
Requires-Dist: geomloss>=0.2.6; extra == "pcloud"
Requires-Dist: Ninja>=1.11.1; extra == "pcloud"
Requires-Dist: torchio>=0.19.1; extra == "pcloud"
Provides-Extra: s3
Requires-Dist: boto3<1.24.5,>=1.23.5; extra == "s3"
Requires-Dist: s3fs~=2023.1; extra == "s3"
Provides-Extra: spharm
Requires-Dist: vtk~=9.2; extra == "spharm"
Requires-Dist: aicscytoparam~=0.1; extra == "spharm"
Requires-Dist: pyshtools==4.10.3; extra == "spharm"
Provides-Extra: test
Requires-Dist: cyto-dl[all]; extra == "test"
Requires-Dist: pytest~=7.2; extra == "test"
Requires-Dist: pytest-cov[toml]~=4.0; extra == "test"
Provides-Extra: torchserve
Requires-Dist: torchserve>=0.8.0; extra == "torchserve"
Requires-Dist: gorilla>=0.4.0; extra == "torchserve"
Project-URL: Homepage, https://github.com/AllenCellModeling/cyto-dl
Description-Content-Type: text/markdown

<div align="center">

<!-- <picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://github.com/AllenCellModeling/cyto-dl/blob/b73e6f357727e3b42adea8540c86f2475ea60379/docs/CytoDL-logo-1C-onDark.png">
  <source media="(prefers-color-scheme: light)" srcset="https://github.com/AllenCellModeling/cyto-dl/blob/b73e6f357727e3b42adea8540c86f2475ea60379/docs/CytoDL-logo-1C-onLight.png">
  <img src="https://github.com/AllenCellModeling/cyto-dl/blob/b73e6f357727e3b42adea8540c86f2475ea60379/docs/CytoDL-logo-1C-onLight.png">
</picture> -->

<h1>CytoDL</h1>

<a href="https://pytorch.org/get-started/locally/"><img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-ee4c2c?logo=pytorch&logoColor=white"></a>
<a href="https://pytorchlightning.ai/"><img alt="Lightning" src="https://img.shields.io/badge/-Lightning-792ee5?logo=pytorchlightning&logoColor=white"></a>
<a href="https://hydra.cc/"><img alt="Config: Hydra" src="https://img.shields.io/badge/Config-Hydra-89b8cd"></a>
<a href="https://github.com/ashleve/lightning-hydra-template"><img alt="Template" src="https://img.shields.io/badge/-Lightning--Hydra--Template-017F2F?style=flat&logo=github&labelColor=gray"></a><br>

</div>

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://github.com/AllenCellModeling/cyto-dl/blob/acf7dad69f492c417b0e486f8f08c19f25575927/docs/CytoDL-overview_dark_1.png">
    <source media="(prefers-color-scheme: light)" srcset="https://github.com/AllenCellModeling/cyto-dl/blob/acf7dad69f492c417b0e486f8f08c19f25575927/docs/CytoDL-overview_light_1.png">
    <img src="https://github.com/AllenCellModeling/cyto-dl/blob/acf7dad69f492c417b0e486f8f08c19f25575927/docs/CytoDL-overview_light_1.png">
  </picture>
</p>

## Description

As part of the [Allen Institute for Cell Science's](allencell.org) mission to understand the principles by which human induced pluripotent stem cells establish and maintain robust dynamic localization of cellular structure, `CytoDL` aims to unify deep learning approaches for understanding 2D and 3D biological data as images, point clouds, and tabular data.

The bulk of `CytoDL`'s underlying structure bases the [lightning-hydra-template](https://github.com/ashleve/lightning-hydra-template) organization - we highly recommend that you familiarize yourself with their (short) docs for detailed instructions on running training, overrides, etc.

Our currently available code is roughly split into two domains: image-to-image transformations and representation learning. The image-to-image code (denoted im2im) contains configuration files detailing how to train and predict using models for resolution enhancement using conditional GANs (e.g. predicting 100x images from 20x images), semantic and instance segmentation, and label-free prediction. We also provide configs for Masked Autoencoder (MAE) pretraining using a Vision Transformer (ViT) backbone and for training segmentation decoders from these pretrained features. Representation learning code includes a wide variety of Variational Auto Encoder (VAE) architectures. Due to dependency issues, equivariant autoencoders are not currently supported on Windows.

As we rely on recent versions of pytorch, users wishing to train and run models on GPU hardware will need up-to-date NVIDIA drivers. Users with older GPUs should not expect code to work out of the box. Similarly, we do not currently support training/predicting on Mac GPUs. In most cases, cpu-based training should work when GPU training fails.

For im2im models, we provide a handful of example 3D images for training the basic image-to-image tranformation-type models and default model configuration files for users to become comfortable with the framework and prepare them for training and applying these models on their own data. Note that these default models are very small and train on heavily downsampled data in order to make tests run efficiently - for best performance, the model size should be increased and downsampling removed from the data configuration.

## How to run

Install dependencies. Dependencies are platform specific, please replace `PLATFORM` with your platform - either `linux`, `windows`, or `mac`

```bash
# clone project
git clone https://github.com/AllenCellModeling/cyto-dl
cd cyto-dl

# [OPTIONAL] create conda environment
conda create -n myenv python=3.9
conda activate myenv

pip install -r requirements/PLATFORM/requirements.txt

# [OPTIONAL] install extra dependencies - equivariance related
pip install -r requirements/PLATFORM/equiv-requirements.txt

pip install -e .


#[OPTIONAL] if you want to use default experiments on example data
python scripts/download_test_data.py
```

### API

```python
from cyto_dl.api import CytoDLModel

model = CytoDLModel()
model.download_example_data()
model.load_default_experiment("segmentation", output_dir="./output", overrides=["trainer=cpu"])
model.print_config()
model.train()

# [OPTIONAL] async training
await model.train(run_async=True)
```

Train model with chosen experiment configuration from [configs/experiment/](configs/experiment/)

```bash
#gpu
python cyto_dl/train.py experiment=im2im/experiment_name.yaml trainer=gpu

#cpu
python cyto_dl/train.py experiment=im2im/experiment_name.yaml trainer=cpu

```

You can override any parameter from command line like this

```bash
python cyto_dl/train.py trainer.max_epochs=20 datamodule.batch_size=64
```

