Skip to content
Direct Graphical Models (DGM) C++ library, a cross-platform Conditional Random Fields library, which is optimized for parallel computing and includes modules for feature extraction, classification and visualization.
C++ CMake Batchfile Shell GLSL
Branch: master
Clone or download

Direct Graphical Models C++ library

License Version CodeFactor Build status

DGM is a cross-platform C++ library implementing various tasks in probabilistic graphical models with pairwise and complete (dense) dependencies. The library aims to be used for the Markov and Conditional Random Fields (MRF / CRF), Markov Chains, Bayesian Networks, etc. Specifically, it includes a variety of methods for the following tasks:

  • Learning: Training of unary and pairwise potentials
  • Inference / Decoding: Computing the conditional probabilities and the most likely configuration
  • Parameter Estimation: Computing maximum likelihood (or MAP) estimates of the parameters
  • Evaluation / Visualization: Evaluation and visualization of the classification results
  • Data Analysis: Extraction, analysis and visualization of valuable knowlage from training data
  • Feature Engineering: Extraction of various descriptors from images, which are useful for classification

These tasks are optimized for speed, i.e. high-efficient calculations. The code is written in optimized C++17, compiled with Microsoft Visual Studio, Xcode or GCC and can take advantage of multi-core processing as well as GPU computing. DGM is released under a BSD license and hence it is free for both academic and commercial use.

Check out the project site for all the details like

Please join the DGM-user Q&A forum to ask questions and talk about methods and models. Framework development discussions and thorough bug reports are collected on Issues.


  • DGM - the main library
  • FEX - feature extraction module
  • VIS - visualization module

License and Citation

DGM is released under the BSD 3-Clause license. The Project-X reference models are released for unrestricted use.

If the DGM library helps you in your research, please cite it in your publications:

	author = {Kosov, Sergey},
	title = {Direct Graphical Models {C++} library},
	year = {2013},

and / or the PhD thesis, wich describes all the theory lying behind the DGM library:

	author = {Kosov, Sergey},
	title = {Multi-Layer Conditional Random Fields for Revealing Unobserved Entities},
	school = {Siegen University},
	year = {2018},
	doi = {10.13140/RG.2.2.12409.31844},
	urn = {urn:nbn:de:hbz:467-13434},
	url = {}
You can’t perform that action at this time.