A library for crowdflow prediction!
Project description
st_dif
A Python library for crowd flow prediction and spatiotemporal modeling. Built on PyTorch, PyTorch Geometric, and PyTorch Geometric Temporal.
This is the Python library developed for Chapter 3 and 4 of the thesis:
V. W. H. Wong, Spatio-temporal Representation Learning: Applications to Manufacturing Planning and Pedestrian Crowd Analysis, Ph.D. Thesis, Department of Civil and Environmental Engineering, Stanford University, Stanford, CA, June 2024.
Installation Guide
Follow these steps carefully to set up your environment.
Option 1: Install from PYPI
1. Create a New Virtual Environment
Using conda:
conda create -n st_dif_env python=3.10
conda activate st_dif_env
Or using venv:
python -m venv st_dif_env
st_dif_env\Scripts\activate # Windows
source st_dif_env/bin/activate # macOS/Linux
2. Install PyTorch
Install PyTorch matching your hardware (example for CUDA 12.6):
pip install torch torchvision torchaudio
(Refer to the PyTorch Get Started guide if you need specific instructions.)
3. Install PyTorch Geometric Libraries
Because st_dif depends on CUDA-based libraries, it is necessary to install them manually:
pip install torch-scatter torch-sparse torch-geometric -f https://data.pyg.org/whl/torch-2.5.1+cu121.html
pip install torch-geometric-temporal
Important: Make sure you install from the special https://data.pyg.org wheels to ensure CUDA compatibility.
4. Install st_dif
Install the st_dif library:
pip install st_dif
Summary:
- Follow the installation steps carefully to match CUDA and PyTorch versions.
- Manually install
torch-scatter,torch-sparse, andtorch-geometricfrom the correct source. - Then install
st_dif.
Example Full Setup Commands
conda create -n st_dif_env python=3.10
conda activate st_dif_env
pip install torch torchvision torchaudio
pip install torch-scatter torch-sparse torch-geometric -f https://data.pyg.org/whl/torch-2.5.1+cu121.html
pip install torch-geometric-temporal
pip install st_dif
At this point, you are ready to use st_dif.
Notes
- If you encounter
[WinError 127] The specified procedure could not be found, it usually indicates that torch-scatter or torch-sparse were installed incorrectly. Reinstall them following the instructions above. - Ensure that your PyTorch version matches your CUDA version.
- If using a CPU-only version of PyTorch, install CPU-compatible versions of the dependencies.
Option 2: Install from Source (developer)
git clone https://github.com/vivian-wong/crowd-framework/
cd crowd-framework
pip install -e .[dev]
Run Installation Test
Assuming pytest has been installed:
python -m pytest
Example Usage
from st_dif.data_utils import get_pyg_temporal_dataset, get_loaders
from st_dif.models.sten import STEN
Check the examples/ directory for simplified demo notebooks.
Reproducing paper experiments
To run all experiments as detailed in the thesis, run
bash reproduce_paper_experiments.sh
and generate plots with the jupyter notebook experiments/plot_results.ipynb
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss proposed changes.
License
MIT License
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 st_dif-0.1.2.tar.gz.
File metadata
- Download URL: st_dif-0.1.2.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32bed49bd920921522508e1fb3e52ac6c121640f8c5622b8d79bff66ff68e0df
|
|
| MD5 |
3d71764ae129d987ea126ce247c1b7fc
|
|
| BLAKE2b-256 |
2455c4aff5027a4fce1596d9b8bf78d9e46ad151f1d90e76eec726e8fb4bd32f
|
Provenance
The following attestation bundles were made for st_dif-0.1.2.tar.gz:
Publisher:
publish.yml on vivian-wong/crowd-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
st_dif-0.1.2.tar.gz -
Subject digest:
32bed49bd920921522508e1fb3e52ac6c121640f8c5622b8d79bff66ff68e0df - Sigstore transparency entry: 313208741
- Sigstore integration time:
-
Permalink:
vivian-wong/crowd-framework@1379a0d7e4c6272524d7f4257413e845b375e853 -
Branch / Tag:
refs/tags/v0.1.2-beta - Owner: https://github.com/vivian-wong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1379a0d7e4c6272524d7f4257413e845b375e853 -
Trigger Event:
release
-
Statement type:
File details
Details for the file st_dif-0.1.2-py3-none-any.whl.
File metadata
- Download URL: st_dif-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.7 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 |
1aa14110e9d8dab1a034245443b0a1b94f8f382a57d2851786aeb64dfbbbc944
|
|
| MD5 |
0a1fb738c6a364d998011f0f748b6e39
|
|
| BLAKE2b-256 |
aafc2b29f1a989514113e2a094fc5df9720fff6201dddf0c4bcce27946abdd1d
|
Provenance
The following attestation bundles were made for st_dif-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on vivian-wong/crowd-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
st_dif-0.1.2-py3-none-any.whl -
Subject digest:
1aa14110e9d8dab1a034245443b0a1b94f8f382a57d2851786aeb64dfbbbc944 - Sigstore transparency entry: 313208755
- Sigstore integration time:
-
Permalink:
vivian-wong/crowd-framework@1379a0d7e4c6272524d7f4257413e845b375e853 -
Branch / Tag:
refs/tags/v0.1.2-beta - Owner: https://github.com/vivian-wong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1379a0d7e4c6272524d7f4257413e845b375e853 -
Trigger Event:
release
-
Statement type: