Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shineiarakawa/diffusion-model-cpp
A C++ implementation of a diffusion model using libtorch.
https://github.com/shineiarakawa/diffusion-model-cpp
cpp diffusion-models libtorch
Last synced: 6 days ago
JSON representation
A C++ implementation of a diffusion model using libtorch.
- Host: GitHub
- URL: https://github.com/shineiarakawa/diffusion-model-cpp
- Owner: ShineiArakawa
- License: mit
- Created: 2024-06-11T09:34:41.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-14T11:52:02.000Z (8 months ago)
- Last Synced: 2024-06-15T09:09:56.743Z (8 months ago)
- Topics: cpp, diffusion-models, libtorch
- Language: C++
- Homepage:
- Size: 482 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# diffusion-model-cpp
A C++ implementation of a diffusion model using libtorch![Teaser image](./assets/sampled_images.png)
## Features
- Diffusion model implemented using libtorch
- Support for training and ~~inference~~
- Customizable parameters for training and model configuration
- Pure C++ implementation## Tested environments
- C++17
- GCC 11.4.0
- CMake 3.30
- libtorch 2.1.0
- OpenCV 4.7.0 (for image processing)
- CUDAToolkit 12.3## Getting Started
### Build
1. Clone the repository:
```sh
git clone --recursive https://github.com/your_username/diffusion-model-cpp.git
cd diffusion-model-cpp
```2. Install dependencies:
```sh
sudo apt-get update
sudo apt-get install libopencv-dev
```3. Download and extract libtorch:
```sh
wget https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-shared-with-deps-2.3.1%2Bcu121.zip
unzip libtorch-cxx11-abi-shared-with-deps-2.3.1+cu121.zip
```4. Build the project using CMake:
```sh
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..
make
```### Training
1. Prepare your dataset and update the dataset path and log dir path in the configuration file `configs/sample.json`.2. Run the training program:
```sh
./build/src/train configs/sample.json
```3. The model and training logs will be saved in the log directory.
## Acknowledgements
- This project uses [libtorch](https://pytorch.org/cppdocs/) for implementing the diffusion model.
- OpenCV is used for image processing tasks.
- Inspiration and algorithms are based on recent research in the field of [diffusion models](https://github.com/crowsonkb/k-diffusion).