An inference-only C++ implementation of FairMOT.
- CMake 3.18.4
- Python headers 3.8.10
- CUDA 11.4
- cuDNN 8.1.1
- LibTorch 1.12.1
- Torchvision 0.13.1
- OpenCV 4.7.0
- Eigen 3.4.0
Other than Eigen, older versions for the dependencies may also work.
-
Clone the repo and its submodules
git clone https://github.com/liyier90/FairMOT-cpp.git && cd FairMOT-cpp git submodule update --init --recursive
-
Download fairmot_dla34.pth to the
weights/
folder. -
Convert the PyTorch model to a JIT model.
cd python pip install -r requirements.txt python convert_to_jit.py
Older versions of the required Python packages may work as well.
-
Set up third-party C++ dependencies.
cd ../third_party
-
Download and install Eigen.
wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz tar -xvf eigen-3.4.0.tar.gz && cd eigen-3.4.0 mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=</path/to/third_party/eigen> .. make install cd ../..
-
Download and install OpenCV
wget https://github.com/opencv/opencv/archive/refs/tags/4.7.0.tar.gz tar -xvf 4.7.0.tar.gz && cd opencv-4.7.0 mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=</path/to/third_party/opencv4> .. cmake --build . make install cd ../..
This OpenCV may use Eigen instead of LAPACK as the linear alegbra package.
-
Download LibTorch.
wget https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.12.1%2Bcu113.zip unzip libtorch-cxx11-abi-shared-with-deps-1.12.1+cu113.zip
-
Clone and install Torchvision
git clone https://github.com/pytorch/vision.git && cd vision git checkout tags/v0.13.1 mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=</path/to/third_party/torchvision> \ -DCMAKE_PREFIX_PATH=</path/to/third_party/libtorch/share/cmake> \ -DWITH_CUDA=ON \ -DUSE_PYTHON=OFF .. cmake --build . make install cd ../..
-
-
Compile the source code
mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build .
-
Run FairMOT
./FairMOT </path/to/video/file>
Results on MOT challenge train set.
Dataset | MOTA | IDF1 | IDS | MT | ML | FPS |
---|---|---|---|---|---|---|
MOT-16 | 81.8 | 80.6 | 519 | 303 | 27 | 30.1 |
Evaluation was run on NVIDIA GeForce RTX 3070 8GB.