This repo generates custom 2D human keypoint annotations from images by:
- Defining mesh-surface markers on an SMPL body.
- Fitting people in images with the vendored CameraHMR inference stack.
- Projecting those markers into each image.
- Exporting the result as COCO-style keypoint annotations.
The source tree is standalone. You do not need a separate CameraHMR checkout. Runtime assets and a few Python dependencies are still external.
python gui_define.pyCreate or edit a YAML keypoint-definition file with an Open3D GUI.python process.py --image-folder ... --keypoint-config ... --output-dir ...Run batch fitting and exportoutput/annotations/dataset.json.python gui_verify.py --coco-json ... --image-folder ...Review generated annotations with an Open3D image browser.
- CameraHMR source is vendored under
vendor/camerahmr/. - Asset paths are resolved inside the repo by
src/runtime_paths.py. - The
smplxPython package is still installed from pip. - Official SMPL / SMPL-H / SMPL-X body-model files and pretrained checkpoints
are still supplied locally under
data/or redirected throughconfig/paths.yaml/HKA_*environment variables.
- Python 3.10 (recommended)
- NVIDIA GPU with CUDA support (recommended for usable inference speed)
- Git (for Detectron2 installation)
conda create -n autolabel python=3.10
conda activate autolabelOr using venv:
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activateInstall PyTorch with CUDA support (adjust CUDA version for your system):
pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118For CPU-only installation:
pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1cd human_keypoint_autolabelling
pip install -r requirements.txtThis installs:
- Core dependencies:
numpy,opencv-python,trimesh,open3d,pyyaml - SMPL utilities:
smplx,chumpy - CameraHMR dependencies:
pytorch-lightning,einops,timm, etc. - Detectron2 (from GitHub)
Download and place the required model files under data/:
data/
├── pretrained-models/
│ ├── cam_model_cleaned.ckpt
│ ├── camerahmr_checkpoint_cleaned.ckpt
│ └── model_final_f05665.pkl
├── smpl_mean_params.npz
└── models/
└── SMPL/
└── SMPL_NEUTRAL.pkl
Where to get these files:
- SMPL models: Register at SMPL website
- CameraHMR checkpoints: See CameraHMR repository
- Detectron2 checkpoint: Available from Detectron2 Model Zoo
python tests/run_tests.pyExpected output: ALL TESTS PASSED
pip install pre-commit
pre-commit install- Define custom keypoints →
gui_define.py - Process images →
process.py - Verify annotations →
gui_verify.py
Launch the keypoint definition GUI:
python gui_define.pyOptional arguments:
--model-type {smpl,smplh,smplx}- Choose body model type (default: smpl)--output config/my_keypoints.yaml- Specify output file path
GUI workflow:
- Select Joint A and Joint B from dropdowns
- Adjust
Length %(distance along bone) andAzimuth(rotation angle) - Preview the marker position on the 3D body mesh
- Click "Add Keypoint" to save it to the configuration
- Export the configuration to a YAML file
Run batch processing to fit SMPL models and generate annotations:
python process.py --image-folder data/my_images --keypoint-config config/my_keypoints.yaml --output-dir outputRequired arguments:
--image-folder PATH- Directory containing images to process--keypoint-config PATH- YAML file with keypoint definitions--output-dir PATH- Output directory for annotations and logs
Optional arguments:
--save-viz- Save visualization overlays tooutput/visualizations/--verbose- Enable INFO-level logging--device {cuda,cpu}- Force specific device (default: auto-detect)--detection-threshold FLOAT- Detectron2 person detection threshold (default: 0.9)
Example with all options:
python process.py \
--image-folder data/my_images \
--keypoint-config config/custom_markers.yaml \
--output-dir output \
--save-viz \
--verbose \
--detection-threshold 0.85Outputs:
output/annotations/dataset.json- COCO-format keypoint annotationsoutput/visualizations/*_viz.jpg- Overlay images (if--save-vizused)output/logs/- Processing logs
Supported image formats: .jpg, .jpeg, .png, .bmp, .tiff, .webp
Review generated annotations with the verification GUI:
python gui_verify.py --coco-json output/annotations/dataset.json --image-folder data/my_imagesRequired arguments:
--coco-json PATH- Path to generated COCO JSON file--image-folder PATH- Directory containing source images
GUI features:
- Navigate between images using arrow keys or buttons
- Jump to specific image index
- Toggle keypoint labels on/off
- Save current visualization
- View dataset-wide visibility statistics
Keypoint visibility colors:
- 🟢 Green: Visible (COCO v=2)
- 🟡 Yellow: Occluded (COCO v=1)
- 🔴 Red: Unlabeled (COCO v=0)
Override default asset paths using HKA_* environment variables:
export HKA_CAMERAHMR_CHECKPOINT=/path/to/camerahmr_checkpoint_cleaned.ckpt
export HKA_CAM_MODEL_CHECKPOINT=/path/to/cam_model_cleaned.ckpt
export HKA_DETECTRON_CHECKPOINT=/path/to/model_final_f05665.pkl
export HKA_SMPL_MODEL_PATH=/path/to/SMPL_NEUTRAL.pklAlternatively, edit config/paths.yaml to set custom paths.
Asset resolution order:
- Explicit function arguments
HKA_*environment variablesconfig/paths.yaml- Default paths under
data/
# Define keypoints
python gui_define.py --model-type smpl --output config/keypoints.yaml
# Process images with visualizations
python process.py --image-folder data/images --keypoint-config config/keypoints.yaml --output-dir output --save-viz
# Verify results
python gui_verify.py --coco-json output/annotations/dataset.json --image-folder data/images
# Run tests
python tests/run_tests.py# 1. Activate environment
conda activate autolabel
# 2. Define 5 custom keypoints
python gui_define.py
# 3. Process a folder of images
python process.py \
--image-folder data/my_dataset \
--keypoint-config config/custom_keypoints.yaml \
--output-dir output \
--save-viz \
--verbose
# 4. Review the annotations
python gui_verify.py \
--coco-json output/annotations/dataset.json \
--image-folder data/my_datasetIssue: ModuleNotFoundError: No module named 'detectron2'
- Solution: Reinstall Detectron2:
pip install 'git+https://github.com/facebookresearch/detectron2.git'
Issue: CUDA out of memory
- Solution: Process fewer images at once or use
--device cpu
Issue: Missing checkpoint files
- Solution: Ensure all required files are in
data/or setHKA_*environment variables
Issue: No persons detected
- Solution: Lower detection threshold:
--detection-threshold 0.5
- Getting Started Guide - Detailed setup instructions
- Architecture Overview - System design and components
- API Reference - Python API documentation
- YAML Format - Keypoint configuration format
- COCO Output Format - Annotation schema details
- The keypoint schema is currently built around the SMPL 24-joint skeleton
gui_define.pyexposessmpl,smplh, andsmplx, but non-SMPL modes are only partially documented. The stored keypoint definitions still use the SMPL 24-joint names and IDs- The lightweight test runner covers pure modules only. It does not exercise the full Detectron2 + CameraHMR + Open3D runtime path
- Image discovery is not recursive; only the specified folder is scanned
This repository uses pre-commit hooks for code quality:
pip install pre-commit
pre-commit install
pre-commit run --all-files # Run all hooks manuallyHooks include:
- YAML validation
- End-of-file fixing
- Trailing whitespace removal
- Secret detection (gitleaks)