A PyTorch implementation of the SPAGHETTI model for phase-contrast microscopy image transformation
Project description
SPAGHETTI - SSIM-restrained Phase Contrast Microscopy GAN for H&E Translation of Images
Implementation of the SPAGHETTI method for phase-contrast microscopy images pre-processing so that you can use your favourite H&E model on them.
Read the documentation at documentations.md
Installing SPAGHETTI
Installing using PyPI
SPAGHETTI is available on the Python Package Index (PyPI) to be installed with pip directly. To install, run:
pip install pcm-spaghetti
Installing Locally
Alternatively, you may also install SPAGHETTI from the GitHub repository directly. To do that, first create a virtual Python environment and install SPAHETTI locally.
virtualenv --no-download spaghetti
source spaghetti/bin/activate
git clone https://github.com/schwartzlab-methods/spaghetti
cd spaghetti
python setup.py sdist bdist_wheel
pip install .
Inferences using SPAGHETTI
An example workflow of how to use SPAGHETTI to convert your phase-contrast microscopy images into H&E-like images can be found at ./tutorials/inference_example.py. Before running the example code, please ensure that you have cloned the default SPAGHETTI checkpoint file properly located at ./spaghetti_checkpoint.ckpt. If not, please go to the repository and directly download this checkpoint file.
Inferences with the CLI tool
Alternatively, you can also run inferences using the CLI interface to perform quick inferences. To do this, after you have installed SPAGHETTI, run:
python spaghetti --input path_to_directory_with_your_images \
--output path_to_directory_to_save_the_images --checkpoint path_to_the_checkpoint_file
The checkpoint file can either be the default checkpoint file (to be downloaded from ./spaghetti_checkpoint.ckpt), or can be the checkpoint files from your own training (see below for more details on how to train your own SPAGHETTI model).
Inferences with Docker Image
The CLI inference tool of SPAGHETTI is available as a Docker image so that you do not need to worry about setting up the environment. To use it, ensure you have Docker installed, then run:
docker pull yinnikun/spaghetti:latest
Before running the following command, please ensure that all your files (the input image/directory and the model checkpoint) is stored in one directory as we will need to mount this directory in the VM for Docker to run.
Suppose all your input files are stored at /usr/data/spaghetti_inferences/inputs/ and your model checkpoint is loacted at /usr/data/spaghetti_inferences/model.ckpt, and you want to save your results at /usr/data/spaghetti_inferences/outputs/, run the following command to performan the inference using Docker:
docker run --rm -v /usr/data/spaghetti_inferences/:/usr/data/ spaghetti \
--input /usr/data/inputs/ --output /usr/data/outputs/ --checkpoint /usr/data/model.ckpt
Training your own model
You can also train your own model to perform the inferences. See an example code at ./tutorials/train_example.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pcm_spaghetti-1.0.1.tar.gz.
File metadata
- Download URL: pcm_spaghetti-1.0.1.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eee6ad4cd03633388831cb3d2609a0054e214d36d6331956f6e3a459b40b86dd
|
|
| MD5 |
24cf94c4e542500e1126bc9787d32cd2
|
|
| BLAKE2b-256 |
ca27f44cf1860edc266ff7d8925fe83e7c824a71077e6ae4eed6911ccc40d6ac
|
Provenance
The following attestation bundles were made for pcm_spaghetti-1.0.1.tar.gz:
Publisher:
python-publish.yml on schwartzlab-methods/spaghetti
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pcm_spaghetti-1.0.1.tar.gz -
Subject digest:
eee6ad4cd03633388831cb3d2609a0054e214d36d6331956f6e3a459b40b86dd - Sigstore transparency entry: 237623770
- Sigstore integration time:
-
Permalink:
schwartzlab-methods/spaghetti@673c9750086f72382ab558d6f6efef4713f7ab73 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/schwartzlab-methods
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@673c9750086f72382ab558d6f6efef4713f7ab73 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pcm_spaghetti-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pcm_spaghetti-1.0.1-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
574d0bb62ca4bf3bcc92c38497e9a79c1b2b3a7ea44a990c23c401e8436af522
|
|
| MD5 |
ef563fd7c9ec9dbf7d54ef5f8372ff4c
|
|
| BLAKE2b-256 |
e925ea92053b660d7244aacea74adfc92884fe13978b64603f56eb7adc1c93b2
|
Provenance
The following attestation bundles were made for pcm_spaghetti-1.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on schwartzlab-methods/spaghetti
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pcm_spaghetti-1.0.1-py3-none-any.whl -
Subject digest:
574d0bb62ca4bf3bcc92c38497e9a79c1b2b3a7ea44a990c23c401e8436af522 - Sigstore transparency entry: 237623772
- Sigstore integration time:
-
Permalink:
schwartzlab-methods/spaghetti@673c9750086f72382ab558d6f6efef4713f7ab73 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/schwartzlab-methods
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@673c9750086f72382ab558d6f6efef4713f7ab73 -
Trigger Event:
release
-
Statement type: