You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
mht 175a60e7f6 Update README files: document automated C++/Python model alignment, debug export, and trustworthy comparison pipeline (no fallbacks, all real outputs) 2 weeks ago
.idea a stable stage 2 months ago
backbone_pure_tensors Fix model weight paths, unify tensor loading (plain/JIT), and enable robust C++/Python comparison for all model components 3 weeks ago
bin Feat: Achieved perfect Conv1, good BN1/ReLU1/MaxPool similarity. README updated. 2 months ago
build Align C++ and Python ResNet debug output pipeline: identical preprocessing, shape, and output comparison; fix PyTorch 2.6+ torch.load issue; automate debug export and comparison for all stages 2 weeks ago
cimp Align C++ and Python ResNet debug output pipeline: identical preprocessing, shape, and output comparison; fix PyTorch 2.6+ torch.load issue; automate debug export and comparison for all stages 2 weeks ago
cmake-build-debug Feat: Achieved perfect Conv1, good BN1/ReLU1/MaxPool similarity. README updated. 2 months ago
exported_weights Fix model weight paths, unify tensor loading (plain/JIT), and enable robust C++/Python comparison for all model components 3 weeks ago
ltr Align C++ and Python ResNet debug output pipeline: identical preprocessing, shape, and output comparison; fix PyTorch 2.6+ torch.load issue; automate debug export and comparison for all stages 2 weeks ago
pytracking WIP: Save and compare BB regressor and ResNet debug tensors, modularize comparison scripts, fix path issues, and improve reporting. [auto-commit] 3 weeks ago
test Update README files: document automated C++/Python model alignment, debug export, and trustworthy comparison pipeline (no fallbacks, all real outputs) 2 weeks ago
vcpkg@8f54ef5453 Intial commit 2 months ago
.gitignore Fix: CUDA setup, demo script errors, weight paths & .gitignore 2 months ago
CMakeLists.txt WIP: Save and compare BB regressor and ResNet debug tensors, modularize comparison scripts, fix path issues, and improve reporting. [auto-commit] 3 weeks ago
README.md Update README files: document automated C++/Python model alignment, debug export, and trustworthy comparison pipeline (no fallbacks, all real outputs) 2 weeks ago
bb_regressor_stats.txt a stable stage 2 months ago
build.sh Feat: Achieved perfect Conv1, good BN1/ReLU1/MaxPool similarity. README updated. 2 months ago
classifier_stats.txt a stable stage 2 months ago
compare_bbreg_debug_tensors.py WIP: Save and compare BB regressor and ResNet debug tensors, modularize comparison scripts, fix path issues, and improve reporting. [auto-commit] 3 weeks ago
compare_bbreg_weights.py WIP: Save and compare BB regressor and ResNet debug tensors, modularize comparison scripts, fix path issues, and improve reporting. [auto-commit] 3 weeks ago
compare_preprocessed_inputs_debug.py Align C++ and Python ResNet debug output pipeline: identical preprocessing, shape, and output comparison; fix PyTorch 2.6+ torch.load issue; automate debug export and comparison for all stages 2 weeks ago
compare_resnet_features_debug.py WIP: Save and compare BB regressor and ResNet debug tensors, modularize comparison scripts, fix path issues, and improve reporting. [auto-commit] 3 weeks ago
compare_resnet_outputs_debug.py Align C++ and Python ResNet debug output pipeline: identical preprocessing, shape, and output comparison; fix PyTorch 2.6+ torch.load issue; automate debug export and comparison for all stages 2 weeks ago
compare_resnet_weights.py Align C++ and Python ResNet debug output pipeline: identical preprocessing, shape, and output comparison; fix PyTorch 2.6+ torch.load issue; automate debug export and comparison for all stages 2 weeks ago
demo.py Intial commit 2 months ago
export_and_verify_backbone_tensors.py Fix model weight paths, unify tensor loading (plain/JIT), and enable robust C++/Python comparison for all model components 3 weeks ago
export_backbone_from_python_tracker.py Fix model weight paths, unify tensor loading (plain/JIT), and enable robust C++/Python comparison for all model components 3 weeks ago
export_resnet_individual_tensors.py Feat: Achieved perfect Conv1, good BN1/ReLU1/MaxPool similarity. README updated. 2 months ago
export_resnet_raw.py Feat: Achieved perfect Conv1, good BN1/ReLU1/MaxPool similarity. README updated. 2 months ago
run_demo.sh Feat: Achieved perfect Conv1, good BN1/ReLU1/MaxPool similarity. README updated. 2 months ago
test_tensor.pt Fix model weight paths, unify tensor loading (plain/JIT), and enable robust C++/Python comparison for all model components 3 weeks ago
vcpkg-toolchain.cmake Intial commit 2 months ago
vcpkg.json Feat: Achieved perfect Conv1, good BN1/ReLU1/MaxPool similarity. README updated. 2 months ago
wget-log Feat: Achieved perfect Conv1, good BN1/ReLU1/MaxPool similarity. README updated. 2 months ago

README.md

C++ Tracker Implementation

This project implements a C++ version of the DiMP tracker, focusing on the bounding box regressor and classifier components.

Overview

The project consists of two main components:

  1. BBRegressor: Implements the IoU (Intersection over Union) network for bounding box regression
  2. Classifier: Implements the feature extraction for target classification

Requirements

  • CMake (3.18 or higher)
  • C++17 compatible compiler
  • LibTorch (PyTorch C++ API) - Currently targeting 1.8.0+cu111.
  • CUDA (required) - This implementation requires CUDA. The build.sh script targets CUDA 11.1 for compatibility with LibTorch 1.8.0+cu111. If CUDA 11.1 is not found at /usr/local/cuda-11.1, the script will warn and use a fallback (e.g., /usr/local/cuda-11.8 or an existing CUDA_HOME), which might lead to compilation or runtime issues if there's a significant mismatch.

Building the Project

Automatic Build

The easiest way to build the project is to use the provided build script:

chmod +x build.sh
./build.sh

This will:

  1. Check for CUDA availability (and exit if not found)
  2. Download LibTorch with CUDA support if not already installed
  3. Configure the project with CMake
  4. Build the project
  5. Install the executable to the bin/ directory

Manual Build

If you prefer to build manually:

mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release

Running the Demo

To run the demo application:

# Make sure CUDA is properly set up in your environment
./run_demo.sh

The script will check for CUDA availability and set up the necessary environment variables before running the demo.

Project Structure

  • cimp/: Main C++ implementation
    • bb_regressor/: Bounding box regressor implementation
    • classifier/: Feature extractor implementation
    • demo.cpp: Demo application
  • exported_weights/: Directory containing exported PyTorch weights
    • backbone/: Backbone network weights
    • bb_regressor/: Bounding box regressor weights
    • classifier/: Classifier weights
  • ltr/: Reference Python implementation
  • bin/: Built executables

Implementation Notes

  • The PrRoIPooling implementation requires CUDA and has no CPU fallback
  • All tensor operations are performed on CUDA devices
  • The tracker is optimized for GPU execution only

Comparing Python and C++ Implementations

To compare the outputs between Python and C++ implementations:

  1. Run the Python implementation to generate reference outputs:
python demo.py
  1. Run the C++ implementation:
./run_demo.sh
  1. Compare the output statistics in the generated files:
    • bb_regressor_stats.txt
    • classifier_stats.txt

Automated C++/Python Model Alignment and Comparison (2024)

This project now features a fully automated pipeline to ensure the C++ and Python implementations of ResNet, Classifier, and BBRegressor are numerically aligned:

  • Identical Preprocessing: The exact same preprocessed input tensor is exported from Python and loaded in C++ for all tests, ensuring both models receive identical data.
  • No Fallbacks or Defaults: All models are loaded with real, user-supplied weights. If any weights or outputs are missing, the test aborts or marks the result as missing—no dummy or default values are used.
  • Intermediate Debug Export: Both C++ and Python save all intermediate outputs (after each ResNet stage, etc.) in matching shapes and formats for direct comparison.
  • Automated Comparison: The test/compare_models.py script compares all outputs, reporting cosine similarity, allclose status, max error, and more. An HTML report is generated in test/comparison/report.html.
  • Trustworthy Results: If any file is missing or invalid, the report marks it as such. All agreement metrics are real and reflect true model alignment.

To run the full comparison:

# Build and run the C++ test pipeline
test/run_full_comparison.sh 1
# Or run steps manually (see test/README.md)

See test/README.md for details on the test pipeline and how to add new models for comparison.

License

This project is licensed under the MIT License - see the LICENSE file for details.

C++ Implementation Details

The C++ version in the cimp/ directory aims to replicate the core components of the Python tracker.

Key C++ modules:

  • BBRegressor: Bounding Box Regressor (based on AtomIoUNet).
  • Classifier: Target Classifier (based on DiMP DIMPNet classifier part).
  • ResNet: ResNet-50 backbone for feature extraction.
  • Demo Application: A simple executable in bin/tracking_demo to test components.
  • Test Models: An executable in bin/test_models for running comparisons and tests.