diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..aa5741d5 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,43 @@ +# GitHub Actions Workflows + +This directory contains GitHub Actions workflows for automated checks and builds. + +## Available Workflows + +### Build (`build.yaml`) +Builds and tests the package on multiple platforms (Ubuntu and Windows) with Python 3.10 and PyTorch 2.4.0. + +**Triggers:** Push and Pull Requests to `main` branch + +### Codespell (`codespell.yml`) +Checks for spelling errors in the codebase using codespell. + +**Triggers:** Push and Pull Requests to `main` branch + +### Check File Headers (`check-headers.yml`) +Ensures all Python files have the proper FMPose3D header with Apache 2.0 license information. + +**Triggers:** Push and Pull Requests to `main` branch + +**How it works:** +- Runs `scripts/update_headers.py --check` to verify headers +- Fails if any Python files are missing proper headers +- To fix locally, run: `python scripts/update_headers.py` and commit the changes + +## Running Header Checks Locally + +Before submitting a pull request, you can check and fix headers locally: + +```bash +# Check if all files have proper headers +python scripts/update_headers.py --check + +# Add/update headers to files that need them +python scripts/update_headers.py +``` + +The script will: +- Add the standard FMPose3D header to Python files that don't have one +- Replace old header formats with the current standard +- Preserve shebangs (#!) and `from __future__` imports at the top of files +- Skip `__init__.py` files that are very short diff --git a/.github/workflows/check-headers.yml b/.github/workflows/check-headers.yml new file mode 100644 index 00000000..191ada6b --- /dev/null +++ b/.github/workflows/check-headers.yml @@ -0,0 +1,36 @@ +--- +name: Check File Headers + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + check-headers: + name: Check Python file headers + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Check headers + run: | + python scripts/update_headers.py --check + continue-on-error: false + + - name: Provide fix instructions + if: failure() + run: | + echo "::error::Some files are missing proper headers." + echo "To fix this, run: python scripts/update_headers.py" + echo "Then commit the changes." diff --git a/animals/demo/vis_animals.py b/animals/demo/vis_animals.py index 0aad779b..204c049d 100644 --- a/animals/demo/vis_animals.py +++ b/animals/demo/vis_animals.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + # SuperAnimal Demo: https://github.com/DeepLabCut/DeepLabCut/blob/main/examples/COLAB/COLAB_YOURDATA_SuperAnimal.ipynb import sys import os diff --git a/animals/models/model_animals.py b/animals/models/model_animals.py index e2fa4836..a1f95d2f 100644 --- a/animals/models/model_animals.py +++ b/animals/models/model_animals.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import math from functools import partial diff --git a/animals/scripts/main_animal3d.py b/animals/scripts/main_animal3d.py index fb40166f..157b5d52 100644 --- a/animals/scripts/main_animal3d.py +++ b/animals/scripts/main_animal3d.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import os import torch import random diff --git a/demo/vis_in_the_wild.py b/demo/vis_in_the_wild.py index d53da8a1..02e572c0 100755 --- a/demo/vis_in_the_wild.py +++ b/demo/vis_in_the_wild.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import sys import cv2 import os diff --git a/fmpose/aggregation_methods.py b/fmpose/aggregation_methods.py index 03daca4e..ee2b62d5 100644 --- a/fmpose/aggregation_methods.py +++ b/fmpose/aggregation_methods.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import torch from fmpose.common.utils import project_to_2d diff --git a/fmpose/animals/__init__.py b/fmpose/animals/__init__.py index 951bd296..fd963384 100644 --- a/fmpose/animals/__init__.py +++ b/fmpose/animals/__init__.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + """ Animal-specific components for FMPose. """ diff --git a/fmpose/animals/common/__init__.py b/fmpose/animals/common/__init__.py index cc11449b..deeb083c 100644 --- a/fmpose/animals/common/__init__.py +++ b/fmpose/animals/common/__init__.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + """ Shared utilities for animal datasets and models. """ diff --git a/fmpose/animals/common/animal3d_dataset.py b/fmpose/animals/common/animal3d_dataset.py index 875bebdf..15c98918 100644 --- a/fmpose/animals/common/animal3d_dataset.py +++ b/fmpose/animals/common/animal3d_dataset.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import json import numpy as np diff --git a/fmpose/animals/common/animal_visualization.py b/fmpose/animals/common/animal_visualization.py index 1d387750..c45d6f66 100644 --- a/fmpose/animals/common/animal_visualization.py +++ b/fmpose/animals/common/animal_visualization.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import os import cv2 diff --git a/fmpose/animals/common/arber_dataset.py b/fmpose/animals/common/arber_dataset.py index 7835d07d..c70bb838 100644 --- a/fmpose/animals/common/arber_dataset.py +++ b/fmpose/animals/common/arber_dataset.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import copy import gc import glob diff --git a/fmpose/animals/common/arguments.py b/fmpose/animals/common/arguments.py index 3a00e133..690c5400 100755 --- a/fmpose/animals/common/arguments.py +++ b/fmpose/animals/common/arguments.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import argparse import math diff --git a/fmpose/animals/common/camera.py b/fmpose/animals/common/camera.py index f901dc71..59c2b320 100755 --- a/fmpose/animals/common/camera.py +++ b/fmpose/animals/common/camera.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import sys import numpy as np diff --git a/fmpose/animals/common/graph_utils.py b/fmpose/animals/common/graph_utils.py index 0f1b380d..aad42f8a 100755 --- a/fmpose/animals/common/graph_utils.py +++ b/fmpose/animals/common/graph_utils.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + from __future__ import absolute_import import numpy as np diff --git a/fmpose/animals/common/lifter3d.py b/fmpose/animals/common/lifter3d.py index b609165c..4911a5a5 100644 --- a/fmpose/animals/common/lifter3d.py +++ b/fmpose/animals/common/lifter3d.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import glob import cv2 diff --git a/fmpose/animals/common/mocap_dataset.py b/fmpose/animals/common/mocap_dataset.py index a8d4f4f2..75d837cd 100755 --- a/fmpose/animals/common/mocap_dataset.py +++ b/fmpose/animals/common/mocap_dataset.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + class MocapDataset: def __init__(self, fps, skeleton): self._skeleton = skeleton diff --git a/fmpose/animals/common/skeleton.py b/fmpose/animals/common/skeleton.py index 0c236d92..bea6871f 100755 --- a/fmpose/animals/common/skeleton.py +++ b/fmpose/animals/common/skeleton.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import numpy as np diff --git a/fmpose/animals/common/utils.py b/fmpose/animals/common/utils.py index 22d5293a..d4496625 100755 --- a/fmpose/animals/common/utils.py +++ b/fmpose/animals/common/utils.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import glob import hashlib import json diff --git a/fmpose/animals/models/__init__.py b/fmpose/animals/models/__init__.py index 89379d73..a4d79fdb 100644 --- a/fmpose/animals/models/__init__.py +++ b/fmpose/animals/models/__init__.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + """ FMPose models. """ diff --git a/fmpose/animals/models/graph_frames.py b/fmpose/animals/models/graph_frames.py index ebc7df8a..7d07645d 100755 --- a/fmpose/animals/models/graph_frames.py +++ b/fmpose/animals/models/graph_frames.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import numpy as np class Graph(): diff --git a/fmpose/animals/models/model_animal3d.py b/fmpose/animals/models/model_animal3d.py index 5ee38706..2fbc1750 100644 --- a/fmpose/animals/models/model_animal3d.py +++ b/fmpose/animals/models/model_animal3d.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import math from functools import partial diff --git a/fmpose/common/__init__.py b/fmpose/common/__init__.py index b2a3e3f6..44082829 100644 --- a/fmpose/common/__init__.py +++ b/fmpose/common/__init__.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + """ Common utilities for FMPose. """ diff --git a/fmpose/common/arguments.py b/fmpose/common/arguments.py index 16bdc0d4..3777a1fd 100755 --- a/fmpose/common/arguments.py +++ b/fmpose/common/arguments.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import argparse import math diff --git a/fmpose/common/camera.py b/fmpose/common/camera.py index f901dc71..59c2b320 100755 --- a/fmpose/common/camera.py +++ b/fmpose/common/camera.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import sys import numpy as np diff --git a/fmpose/common/generator.py b/fmpose/common/generator.py index 1c65ab2b..4361c5a8 100755 --- a/fmpose/common/generator.py +++ b/fmpose/common/generator.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import numpy as np diff --git a/fmpose/common/graph_utils.py b/fmpose/common/graph_utils.py index b435ec66..ef75f5bb 100755 --- a/fmpose/common/graph_utils.py +++ b/fmpose/common/graph_utils.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + from __future__ import absolute_import import numpy as np diff --git a/fmpose/common/h36m_dataset.py b/fmpose/common/h36m_dataset.py index 7285acb5..11e07395 100755 --- a/fmpose/common/h36m_dataset.py +++ b/fmpose/common/h36m_dataset.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import copy import numpy as np diff --git a/fmpose/common/load_data_hm36.py b/fmpose/common/load_data_hm36.py index 03a2a9ba..be38b595 100755 --- a/fmpose/common/load_data_hm36.py +++ b/fmpose/common/load_data_hm36.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import numpy as np import torch.utils.data as data diff --git a/fmpose/common/mocap_dataset.py b/fmpose/common/mocap_dataset.py index a8d4f4f2..75d837cd 100755 --- a/fmpose/common/mocap_dataset.py +++ b/fmpose/common/mocap_dataset.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + class MocapDataset: def __init__(self, fps, skeleton): self._skeleton = skeleton diff --git a/fmpose/common/skeleton.py b/fmpose/common/skeleton.py index 0c236d92..bea6871f 100755 --- a/fmpose/common/skeleton.py +++ b/fmpose/common/skeleton.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import numpy as np diff --git a/fmpose/common/utils.py b/fmpose/common/utils.py index f65a7a09..11cf3747 100755 --- a/fmpose/common/utils.py +++ b/fmpose/common/utils.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import glob import hashlib import json diff --git a/fmpose/lib/checkpoint/download_checkpoints.py b/fmpose/lib/checkpoint/download_checkpoints.py index 01e01015..b00fb1a2 100644 --- a/fmpose/lib/checkpoint/download_checkpoints.py +++ b/fmpose/lib/checkpoint/download_checkpoints.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + """ Auto-download checkpoint files from Google Drive if they don't exist. Downloads to user cache directory for better compatibility. diff --git a/fmpose/lib/hrnet/gen_kpts.py b/fmpose/lib/hrnet/gen_kpts.py index e1b83a3a..1ae3f79c 100755 --- a/fmpose/lib/hrnet/gen_kpts.py +++ b/fmpose/lib/hrnet/gen_kpts.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/fmpose/lib/hrnet/lib/config/__init__.py b/fmpose/lib/hrnet/lib/config/__init__.py index a44e926b..74dfc5a4 100755 --- a/fmpose/lib/hrnet/lib/config/__init__.py +++ b/fmpose/lib/hrnet/lib/config/__init__.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + # ------------------------------------------------------------------------------ # Copyright (c) Microsoft # Licensed under the MIT License. diff --git a/fmpose/lib/hrnet/lib/config/default.py b/fmpose/lib/hrnet/lib/config/default.py index 030f468f..ad70f83c 100755 --- a/fmpose/lib/hrnet/lib/config/default.py +++ b/fmpose/lib/hrnet/lib/config/default.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + # ------------------------------------------------------------------------------ # Copyright (c) Microsoft diff --git a/fmpose/lib/hrnet/lib/config/models.py b/fmpose/lib/hrnet/lib/config/models.py index 8e04c4f7..58f318b4 100755 --- a/fmpose/lib/hrnet/lib/config/models.py +++ b/fmpose/lib/hrnet/lib/config/models.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + # ------------------------------------------------------------------------------ # Copyright (c) Microsoft # Licensed under the MIT License. diff --git a/fmpose/lib/hrnet/lib/models/pose_hrnet.py b/fmpose/lib/hrnet/lib/models/pose_hrnet.py index 09ff346a..d62d787c 100755 --- a/fmpose/lib/hrnet/lib/models/pose_hrnet.py +++ b/fmpose/lib/hrnet/lib/models/pose_hrnet.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + # ------------------------------------------------------------------------------ # Copyright (c) Microsoft # Licensed under the MIT License. diff --git a/fmpose/lib/hrnet/lib/utils/coco_h36m.py b/fmpose/lib/hrnet/lib/utils/coco_h36m.py index 44fe35fa..577ef0bb 100755 --- a/fmpose/lib/hrnet/lib/utils/coco_h36m.py +++ b/fmpose/lib/hrnet/lib/utils/coco_h36m.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import numpy as np diff --git a/fmpose/lib/hrnet/lib/utils/inference.py b/fmpose/lib/hrnet/lib/utils/inference.py index 77942ad2..09afe3fd 100755 --- a/fmpose/lib/hrnet/lib/utils/inference.py +++ b/fmpose/lib/hrnet/lib/utils/inference.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + # ------------------------------------------------------------------------------ # Copyright (c) Microsoft # Licensed under the MIT License. diff --git a/fmpose/lib/hrnet/lib/utils/transforms.py b/fmpose/lib/hrnet/lib/utils/transforms.py index 2a14b620..e3d0d39d 100755 --- a/fmpose/lib/hrnet/lib/utils/transforms.py +++ b/fmpose/lib/hrnet/lib/utils/transforms.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + # ------------------------------------------------------------------------------ # Copyright (c) Microsoft # Licensed under the MIT License. diff --git a/fmpose/lib/hrnet/lib/utils/utilitys.py b/fmpose/lib/hrnet/lib/utils/utilitys.py index 8e756f2b..5f4271f9 100755 --- a/fmpose/lib/hrnet/lib/utils/utilitys.py +++ b/fmpose/lib/hrnet/lib/utils/utilitys.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import cv2 import sys import torch diff --git a/fmpose/lib/preprocess.py b/fmpose/lib/preprocess.py index bfe38370..4d324b96 100755 --- a/fmpose/lib/preprocess.py +++ b/fmpose/lib/preprocess.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import json import numpy as np import os diff --git a/fmpose/lib/sort/sort.py b/fmpose/lib/sort/sort.py index ab17bdee..129cf6d3 100755 --- a/fmpose/lib/sort/sort.py +++ b/fmpose/lib/sort/sort.py @@ -1,5 +1,13 @@ """ - https://arxiv.org/abs/1602.00763 +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 + +SORT Tracker: + Based on https://arxiv.org/abs/1602.00763 """ from __future__ import print_function diff --git a/fmpose/lib/yolov3/bbox.py b/fmpose/lib/yolov3/bbox.py index 96818bc4..60373d5f 100755 --- a/fmpose/lib/yolov3/bbox.py +++ b/fmpose/lib/yolov3/bbox.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + from __future__ import division import torch diff --git a/fmpose/lib/yolov3/darknet.py b/fmpose/lib/yolov3/darknet.py index 36e73d83..941316be 100755 --- a/fmpose/lib/yolov3/darknet.py +++ b/fmpose/lib/yolov3/darknet.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + from __future__ import division import torch diff --git a/fmpose/lib/yolov3/human_detector.py b/fmpose/lib/yolov3/human_detector.py index 911b22ed..c3eecce0 100755 --- a/fmpose/lib/yolov3/human_detector.py +++ b/fmpose/lib/yolov3/human_detector.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + from __future__ import division import time import torch diff --git a/fmpose/lib/yolov3/preprocess.py b/fmpose/lib/yolov3/preprocess.py index 77041f1c..015374e9 100755 --- a/fmpose/lib/yolov3/preprocess.py +++ b/fmpose/lib/yolov3/preprocess.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + from __future__ import division import torch diff --git a/fmpose/lib/yolov3/util.py b/fmpose/lib/yolov3/util.py index fd990ca7..79808ba9 100755 --- a/fmpose/lib/yolov3/util.py +++ b/fmpose/lib/yolov3/util.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + from __future__ import division import torch diff --git a/fmpose/models/__init__.py b/fmpose/models/__init__.py index bc460081..bd33b79a 100644 --- a/fmpose/models/__init__.py +++ b/fmpose/models/__init__.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + """ FMPose models. """ diff --git a/fmpose/models/graph_frames.py b/fmpose/models/graph_frames.py index 3439d2af..7aa2c391 100755 --- a/fmpose/models/graph_frames.py +++ b/fmpose/models/graph_frames.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import numpy as np class Graph(): diff --git a/fmpose/models/model_GAMLP.py b/fmpose/models/model_GAMLP.py index 5aefe0af..9a016d4a 100644 --- a/fmpose/models/model_GAMLP.py +++ b/fmpose/models/model_GAMLP.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import sys sys.path.append("..") import torch diff --git a/scripts/FMPose_main.py b/scripts/FMPose_main.py index 9ce3a6e5..b0df3376 100644 --- a/scripts/FMPose_main.py +++ b/scripts/FMPose_main.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import datetime import logging import os diff --git a/scripts/update_headers.py b/scripts/update_headers.py index 7c0ba358..7a73989d 100755 --- a/scripts/update_headers.py +++ b/scripts/update_headers.py @@ -1,107 +1,286 @@ #!/usr/bin/env python3 """ -Script to update file headers in the FMPose3D repository. +FMPose3D: monocular 3D Pose Estimation via Flow Matching -This script replaces the old header format with the new header format -across all Python files in the repository. +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 """ import os import sys from pathlib import Path -# Define the old and new headers -OLD_HEADER = '''""" -FMPose: 3D Pose Estimation via Flow Matching +# Define the standard header for the project +STANDARD_HEADER = '''""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching Official implementation of the paper: -"FMPose: 3D Pose Estimation via Flow Matching" +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis -Accepted by IEEE Transactions on Multimedia (TMM), 2025. +Licensed under Apache 2.0 """''' -NEW_HEADER = '''""" -FMPose3D: monocular 3D Pose Estimation via Flow Matching +# Old headers that should be replaced +OLD_HEADERS = [ + '''""" +FMPose: 3D Pose Estimation via Flow Matching Official implementation of the paper: -"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +"FMPose: 3D Pose Estimation via Flow Matching" by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis -Licensed under Apache 2.0 +Accepted by IEEE Transactions on Multimedia (TMM), 2025. """''' +] -def update_file_header(file_path): +def should_skip_file(file_path): """ - Update the header in a single file. + Determine if a file should be skipped for header addition. + + Args: + file_path: Path to check + + Returns: + True if the file should be skipped, False otherwise + """ + skip_dirs = {'.git', '__pycache__', '.pytest_cache', 'venv', 'env', '.tox', 'build', 'dist', '.eggs'} + + # Skip if in excluded directory + for part in file_path.parts: + if part in skip_dirs: + return True + + # Skip __init__.py files that are typically minimal + if file_path.name == '__init__.py': + try: + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + # Skip if __init__.py is very short (likely just imports) + if len(content.strip()) < 50: + return True + except Exception: + pass + + return False + + +def has_header(content): + """ + Check if content already has the standard header or a valid variant. + + Args: + content: File content to check + + Returns: + True if the file has the standard header or acceptable variant, False otherwise + """ + # Check for exact match + if STANDARD_HEADER.strip() in content: + return True + + # Check for header with additional content (like in sort.py) + # Header should contain the key elements + lines = content.split('\n') + if len(lines) < 3: + return False + + # Check if it starts with a docstring + if not lines[0].strip().startswith('"""'): + return False + + # Check for key header components in the first 15 lines + header_section = '\n'.join(lines[:15]) + required_elements = [ + 'FMPose3D: monocular 3D Pose Estimation via Flow Matching', + 'Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis', + 'Licensed under Apache 2.0' + ] + + return all(elem in header_section for elem in required_elements) + + +def needs_header_update(content): + """ + Check if content has an old header that needs updating. + + Args: + content: File content to check + + Returns: + Old header if found, None otherwise + """ + for old_header in OLD_HEADERS: + if old_header.strip() in content: + return old_header + return None + + +def add_or_update_header(file_path, check_only=False): + """ + Add or update the header in a single file. Args: file_path: Path to the file to update + check_only: If True, only check without modifying Returns: - True if the file was updated, False otherwise + Tuple of (status, message) where status is 'ok', 'updated', 'added', or 'error' """ try: with open(file_path, 'r', encoding='utf-8') as f: content = f.read() - if OLD_HEADER in content: - new_content = content.replace(OLD_HEADER, NEW_HEADER) - with open(file_path, 'w', encoding='utf-8') as f: - f.write(new_content) - return True - return False + # Check if file already has the correct header + if has_header(content): + return ('ok', 'Already has correct header') + + # Check if file has an old header that needs replacing + old_header = needs_header_update(content) + if old_header: + if not check_only: + new_content = content.replace(old_header, STANDARD_HEADER) + with open(file_path, 'w', encoding='utf-8') as f: + f.write(new_content) + return ('updated', 'Replaced old header with standard header') + + # File has no header, add one + # Skip adding header to files that start with shebang or are very short + lines = content.split('\n') + if content.strip() and len(content.strip()) > 10: + if not check_only: + # Handle special cases for header placement + new_lines = [] + insert_index = 0 + + # If file starts with shebang, keep it at the top + if lines[0].startswith('#!'): + new_lines.append(lines[0]) + insert_index = 1 + + # Check for 'from __future__' imports which must be very early + # Find the first non-comment, non-shebang, non-empty line + future_import_index = None + for i in range(insert_index, min(len(lines), 10)): + line = lines[i].strip() + if line.startswith('from __future__'): + future_import_index = i + break + elif line and not line.startswith('#'): + # Found a non-comment line that isn't a future import + break + + if future_import_index is not None: + # If there's a from __future__ import, add header AFTER it + new_lines.extend(lines[insert_index:future_import_index+1]) + new_lines.append(STANDARD_HEADER) + new_lines.append('') + new_lines.extend(lines[future_import_index+1:]) + else: + # Otherwise, add header at the beginning (after shebang if present) + new_lines.append(STANDARD_HEADER) + new_lines.append('') + new_lines.extend(lines[insert_index:]) + + new_content = '\n'.join(new_lines) + + with open(file_path, 'w', encoding='utf-8') as f: + f.write(new_content) + return ('added', 'Added standard header') + + return ('ok', 'Skipped (file too short or empty)') + except Exception as e: - print(f"Error processing {file_path}: {e}") - return False + return ('error', f"Error processing file: {e}") -def find_and_update_headers(root_dir): +def find_and_process_headers(root_dir, check_only=False): """ - Find and update all Python files with the old header. + Find and process all Python files. Args: root_dir: Root directory to search from + check_only: If True, only check without modifying files Returns: - List of files that were updated + Dictionary with statistics about processed files """ root_path = Path(root_dir) - updated_files = [] + stats = { + 'ok': [], + 'updated': [], + 'added': [], + 'error': [] + } # Find all Python files for py_file in root_path.rglob('*.py'): - # Skip files in .git directory - if '.git' in py_file.parts: + # Skip files that should not be processed + if should_skip_file(py_file): continue - if update_file_header(py_file): - updated_files.append(py_file) - print(f"✓ Updated: {py_file.relative_to(root_path)}") + status, message = add_or_update_header(py_file, check_only) + stats[status].append((py_file, message)) + + if status in ['updated', 'added']: + rel_path = py_file.relative_to(root_path) + print(f"{'[CHECK]' if check_only else '✓'} {rel_path}: {message}") + elif status == 'error': + rel_path = py_file.relative_to(root_path) + print(f"✗ {rel_path}: {message}") - return updated_files + return stats def main(): """Main function to run the header update script.""" - if len(sys.argv) > 1: - root_dir = sys.argv[1] + check_only = '--check' in sys.argv + + if len(sys.argv) > 1 and not sys.argv[1].startswith('--'): + root_dir = Path(sys.argv[1]) else: - root_dir = os.getcwd() + root_dir = Path(os.getcwd()) - print(f"Searching for files with old headers in: {root_dir}") + mode = "Checking" if check_only else "Processing" + print(f"{mode} files for headers in: {root_dir}") print("-" * 60) - updated_files = find_and_update_headers(root_dir) + stats = find_and_process_headers(root_dir, check_only) print("-" * 60) - if updated_files: - print(f"\n✓ Successfully updated {len(updated_files)} file(s):") - for file_path in updated_files: - print(f" - {file_path}") - else: - print("\nNo files found with the old header.") - return 0 if updated_files else 1 + # Print summary + total_changes = len(stats['updated']) + len(stats['added']) + + if check_only: + if total_changes > 0: + print(f"\n⚠ Found {total_changes} file(s) needing header updates:") + for file_path, msg in stats['updated']: + print(f" - {file_path.relative_to(root_dir)}: {msg}") + for file_path, msg in stats['added']: + print(f" - {file_path.relative_to(root_dir)}: {msg}") + return 1 + else: + print("\n✓ All Python files have correct headers!") + return 0 + else: + if total_changes > 0: + print(f"\n✓ Successfully processed {total_changes} file(s):") + if stats['updated']: + print(f" - Updated: {len(stats['updated'])} file(s)") + if stats['added']: + print(f" - Added headers: {len(stats['added'])} file(s)") + else: + print("\n✓ No files needed header updates.") + + if stats['error']: + print(f"\n✗ Errors: {len(stats['error'])} file(s)") + for file_path, msg in stats['error']: + print(f" - {file_path.relative_to(root_dir)}: {msg}") + return 1 + + return 0 if __name__ == '__main__': diff --git a/tests/test_demo_human.py b/tests/test_demo_human.py index 9fbf893e..c0728189 100644 --- a/tests/test_demo_human.py +++ b/tests/test_demo_human.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import pytest import os import sys diff --git a/tests/test_model.py b/tests/test_model.py index 0ccec900..7e8edbb5 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import pytest import torch from fmpose.models import Model diff --git a/tests/test_training_pipeline.py b/tests/test_training_pipeline.py index 3e843b22..d0a79289 100644 --- a/tests/test_training_pipeline.py +++ b/tests/test_training_pipeline.py @@ -1,3 +1,12 @@ +""" +FMPose3D: monocular 3D Pose Estimation via Flow Matching + +Official implementation of the paper: +"FMPose3D: monocular 3D Pose Estimation via Flow Matching" +by Ti Wang, Xiaohang Yu, and Mackenzie Weygandt Mathis +Licensed under Apache 2.0 +""" + import pytest import torch import torch.optim as optim