Skip to content

Commit c7e61da

Browse files
Merge pull request #18 from coleygroup/remote-weights
Removed model weights from repository and added automatic download from Hugging Face
2 parents c0f0c1d + 2464ea4 commit c7e61da

13 files changed

Lines changed: 616 additions & 71 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# checkpoints
2+
*.ckpt
3+
*.bak
4+
15
# macOS
26
*.DS_Store
37

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# September 3, 2025 (v0.2.4)
2+
### Model loading and repository optimization
3+
- Added automatic model downloading from HuggingFace Hub with `load_model()`, `get_model_info()`, and `clear_model_cache()` functions
4+
- Removed model weights from git history to reduce repository size - **users should re-clone the repository**
5+
- Added ability for interrupting inference with improved UI to Streamlit app
6+
17
# August 29, 2025 (v0.2.3)
28
### Add Streamlit app for demonstrations
39
- Added an easy-to-use app for demonstration purposes

README.md

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,36 @@ Note that *ShEPhERD* has a sister repository, [shepherd-score](https://github.co
55

66
The preprint can be found on arXiv: [ShEPhERD: Diffusing shape, electrostatics, and pharmacophores for bioisosteric drug design](https://arxiv.org/abs/2411.04130)
77

8-
### **Important** notice for current repository
9-
This repository has undergone a major refactor to accommodate inference with PyTorch 2.5, primarily for ease-of-use. To maintain reproducibility for training and inference, the original code can be found under commit `c3d5ec0` or the Release titled "Publication code v0.1.0". The model checkpoints used for publication can be found in those binaries or at the following Dropbox [link](https://www.dropbox.com/scl/fo/rgn33g9kwthnjt27bsc3m/ADGt-CplyEXSU7u5MKc0aTo?rlkey=fhi74vkktpoj1irl84ehnw95h&e=1&st=wn46d6o2&dl=0) where training data can also be found. The checkpoints were converted with `python -m pytorch_lightning.utilities.upgrade_checkpoint <chkpt_path>`
10-
Slight changes have also been made to the training code to adhere to Pytorch Lightning >2.0 and new versions of PyTorch Geometric.
11-
12-
We would like to acknowledge Matthew Cox for his contributions in updating this codebase.
13-
148
<p align="center">
159
<img width="400" src="./docs/images/shepherd_logo.svg">
1610
</p>
1711

1812
<sub><sup>1</sup> **ShEPhERD**: **S**hape, **E**lectrostatics, and **Ph**armacophores **E**xplicit **R**epresentation **D**iffusion</sub>
1913

14+
### **Important** notice for current repository status
15+
16+
#### UPDATE: June 6, 2025
17+
This repository has undergone a major refactor to accommodate inference with PyTorch 2.5, primarily for ease-of-use. To maintain reproducibility for training and inference, the original code can be found under commit `ec510b2` or the Release titled "Publication code v0.1.0". The model checkpoints used for publication can be found in those binaries or at the following Dropbox [link](https://www.dropbox.com/scl/fo/rgn33g9kwthnjt27bsc3m/ADGt-CplyEXSU7u5MKc0aTo?rlkey=fhi74vkktpoj1irl84ehnw95h&e=1&st=wn46d6o2&dl=0) where training data can also be found. The checkpoints were converted with `python -m pytorch_lightning.utilities.upgrade_checkpoint <chkpt_path>`.
18+
Slight changes have also been made to the training code to adhere to Pytorch Lightning >2.0 and new versions of PyTorch Geometric.
19+
20+
We would like to acknowledge Matthew Cox for his contributions in updating this codebase.
21+
22+
#### UPDATE: Sept. 3, 2025
23+
To reduce the size of the repository, git-filter-repo was used to remove model weights from git history. You can use the new [loading functions](##model-loading) (recommended) to automatically download model weights from our [HuggingFace repo](https://huggingface.co/kabeywar/shepherd) for *ShEPhERD* **>0.2.4**. For older versions, please manually download and place the relevant weights in the `./data/shepherd_chkpts` folder from our [Dropbox](https://www.dropbox.com/scl/fo/rgn33g9kwthnjt27bsc3m/ADGt-CplyEXSU7u5MKc0aTo?rlkey=fhi74vkktpoj1irl84ehnw95h&e=1&st=wn46d6o2&dl=0) or the same HuggingFace repo. More details can be found at `./data/shepherd_chkpts/README.md`.
24+
25+
If you have cloned this repo before, please **re-clone** this repo:
26+
```
27+
git clone https://github.com/coleygroup/shepherd.git
28+
```
29+
2030
## Table of Contents
2131
1. [File Structure](##file-structure)
2232
2. [Environment](##environment)
23-
3. [Training and inference data](##training-and-inference-data)
24-
4. [Training](##training)
25-
5. [Inference](##inference)
26-
6. [Evaluations](##evaluations)
33+
3. [Model Loading](##model-loading)
34+
4. [Training and inference data](##training-and-inference-data)
35+
5. [Training](##training)
36+
6. [Inference](##inference)
37+
7. [Evaluations](##evaluations)
2738

2839
## File Structure
2940

@@ -33,9 +44,9 @@ We would like to acknowledge Matthew Cox for his contributions in updating this
3344
│ └── shepherd/
3445
│ ├── lightning_module.py # pytorch-lightning modules
3546
│ ├── datasets.py # torch_geometric dataset class (for training)
36-
│ ├── inference.py # inference functions
3747
│ ├── extract.py # for extracting field properties
3848
│ ├── shepherd_score_utils/ # dependencies from shepherd-score Github repository
49+
│ ├── inference/ # inference functions
3950
│ └── model/
4051
│ ├── equiformer_operations.py # select E3NN operations from (original) Equiformer
4152
│ ├── equiformer_v2_encoder.py # slightly customized Equiformer-V2 module
@@ -89,7 +100,7 @@ pandas==2.2.3
89100
**We** followed these steps to create a suitable conda environment, which worked on our Linux system. Please note that this exact installation procedure may depend on your system, particularly your cuda version.
90101

91102
```
92-
conda create -n shepherd python=3.9
103+
conda create -n shepherd python=3.11
93104
conda activate shepherd
94105
pip install uv
95106
@@ -110,6 +121,47 @@ conda install xtb
110121
pip install -e .
111122
```
112123

124+
## Model Loading
125+
126+
*ShEPhERD* provides pre-trained model checkpoints that are automatically downloaded from HuggingFace and cached locally. The model weights are compatible with PyTorch Lightning >2.0 and have been converted from the original model weights using `python -m pytorch_lightning.utilities.upgrade_checkpoint <chkpt_path>`. The original model weights can be found at the [Dropbox link](https://www.dropbox.com/scl/fo/rgn33g9kwthnjt27bsc3m/ADGt-CplyEXSU7u5MKc0aTo?rlkey=fhi74vkktpoj1irl84ehnw95h&e=1&st=wn46d6o2&dl=0).
127+
128+
### Available Models
129+
130+
| Model Type | Description | Training Dataset |
131+
|------------|-------------|------------------|
132+
| `mosesaq` | Shape, electrostatics, and pharmacophores | MOSES-aq |
133+
| `gdb_x2` | Shape conditioning only | GDB17 |
134+
| `gdb_x3` | Shape and electrostatics | GDB17 |
135+
| `gdb_x4` | Pharmacophores only | GDB17 |
136+
137+
### Basic Usage
138+
139+
```python
140+
from shepherd import load_shepherd_model
141+
142+
# Load the default MOSES-aq model (downloads automatically if needed)
143+
model = load_shepherd_model()
144+
145+
# Load a specific model type
146+
model = load_shepherd_model('gdb_x3')
147+
```
148+
149+
### Advanced Usage
150+
```python
151+
from shepherd import load_model, clear_model_cache
152+
153+
# Use custom cache directory
154+
model = load_model(cache_dir='./data/shepherd_chkpts')
155+
156+
# Check for local checkpoints first
157+
model = load_model(local_data_dir='./data/shepherd_chkpts')
158+
159+
# Clear cached models
160+
clear_model_cache('mosesaq') # Clear specific model
161+
clear_model_cache() # Clear all models
162+
```
163+
164+
**Note:** Model weights are downloaded from HuggingFace to the cache directory unless you specify a local directory path (`data/shepherd_chkpts`). The models are automatically cached to avoid repeated downloads.
113165

114166
## Training and inference data
115167
`data/conformers/` contains the 3D structures of the natural products, PDB ligands, and fragments that we used in our experiments in the preprint. It also includes the 100 test-set structures from GDB-17 that we used in our conditional generation evaluations.
@@ -145,6 +197,9 @@ The inference script now supports conditional generation of molecules that conta
145197
This repository does *not* contain the code to evaluate samples from *ShEPhERD* (e.g., evaluate their validity, RMSD upon relaxation, 3D similarity to a target structure, etc). All such evaluations can be found in the sister repository: https://github.com/coleygroup/shepherd-score. These repositories were made separate so that the functions within [shepherd-score](https://github.com/coleygroup/shepherd-score) can be used for more general-purpose applications in ligand-based drug design. We also encourage others to use [shepherd-score](https://github.com/coleygroup/shepherd-score) to evaluate other 3D generative models besides *ShEPhERD*.
146198

147199

200+
## App
201+
There is an easy-to-use app found in `app/`. Please follow the instructions there for local deployment.
202+
148203
## License
149204

150205
This project is licensed under the MIT License -- see [LICENSE](./LICENSE) file for details.

app/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Interactive web interface for **ShEPhERD** (Shape, Electrostatics, and Pharmacop
1212

1313
### Installation
1414
```
15-
pip install streamlit stmol "shepherd-score>=1.1.1" py3Dmol
15+
uv pip install streamlit stmol "shepherd-score>=1.1.3" py3Dmol seaborn ipython_genutils
1616
```
17-
NOTE: requires shepherd-score >= 1.1.1 for visualizations
17+
NOTE: requires shepherd-score >= 1.1.3 for visualizations
1818

1919
### How to use
2020
```

0 commit comments

Comments
 (0)