- Python 94.4%
- Jupyter Notebook 3.7%
- Shell 1.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| docs | ||
| scripts | ||
| src/pdiff | ||
| tests | ||
| .gitignore | ||
| LICENSE | ||
| pDIFF_flow.pdf | ||
| pDIFF_flow.png | ||
| pyproject.toml | ||
| README.md | ||
| requirements.txt | ||
| tox.ini | ||
pDIFF - Profile-guided Latent Diffusion for Generative High-Content Imaging
Contact
Steven Cook steven-1.cook@novartis.com
William Godinez william_jose.godinez_navarro@novartis.com
Introduction
pDIFF is a framework for training Latent Diffusion models to predict high-content images from bioactivity profiles. It contains classes to wrap paired profile-image data as a dataset, train a model, and run inference to create a new set of generated images.
Documentation available in /docs/build/html directory
Paper
Cook et al. "A diffusion model conditioned on compound bioactivity profiles for predicting high-content images" [URL TBD]
License
Copyright (c) 2026 Novartis Biomedical Research Inc. Licensed under the MIT License. See LICENSE file in the project root.
Contents
src: Python source code for pDIFFdata: sample images and latent diffusion model componentstests: tests and sample images and latent diffusion model componentsdocs: HTML documentation for pDIFF and sphinx configurationmodels: when training, this folder will be created and populated with log files, checkpoints, and saved full pDIFF model pipeline components
System requirements
Hardware
GPUs
We have tested pDIFF on machines with the following GPUs:
- NVIDIA A100 40GB
Software
Operating systems
We have tested pDIFF on machines with the following systems:
- Red Hat Enterprise Linux release 8.8 (Ootpa)
Software Dependencies
- See full list in
pyproject.toml
Installation
-
Clone this repository
-
Create a new virtual environment. pDIFF has been tested with python3.8 but newer versions should work. example:
conda create -n pdiff python=3.8 -
Install via pip using pyproject.toml: from root directory, run:
pip install -e . -
Copy in stable diffusion VAE model weights file https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/blob/refs%2Fpr%2F1/vae/diffusion_pytorch_model.safetensors to /tests/test_data/sample_pdiff_model/vae and text encoder model weights file https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/blob/main/text_encoder/model.safetensors file to tests/test_data/sample_pdiff_model/text_encoder/
-
Confirm tests are passing: from root directory, run:
pytest tests/Some warnings are expected.
Run Sample Training
In this example we replace bioactivity profiles with chemical fingerprints to demonstrate training. The example data includes fingerprints and images for 16 compounds.
-
Optional - create a copy of /scripts/accelerate_1gpu_fp32.yaml and adjust multi-GPU configuration as necessary. Update scripts/sample_train_script.sh to call this new configuration file. https://huggingface.co/docs/accelerate/en/index
-
Update sample_train_script.sh: in the "conda activate" line, replace with the name of your environment, or remove altogether if you're planning to run the script directly.
-
Run training script directly or through a QSUB job submission system on HPC: Direct execution option: In a CUDA-capable environment with a GPU available, in the scripts directory, run
./sample_train_script.sh
QSUB execution option: adjust the QSUB argument comments at the top of sample_train_script.sh and submit to your scheduler.
- Observe training progress. Currently Tensorboard is supported:
tensorboard --log_dir /models/logs(--bind_all and --port=XXXX if needed)
Custom Data Training
-
Create a dataframe like the one stored in
/data/morgan_mininvps.pklto contain paths to your data and insert the corresponding profiles. Let's call it/data/your_data.pkl. Ensure you can load the new pkl file in a pDiffMetadata instance and access it correctly before proceeding. -
Create a copy of the sample training script in
scripts/sample_train_script.shto point to your new pickled dataframe. Adjust other hyperparameters as necessary. -
invoke training script
Inference
- Once model is trained, run through
/scripts/sample_inference.ipynbto generate new images.
