-
Notifications
You must be signed in to change notification settings - Fork 54
[WIP] Integration with DeepLabCut 3.0 - PyTorch Engine #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This script will be used for both benchmarking and integration testing, therefore it needs to crash if inference isnt successful
- removing until a new one can be added properly
* Update benchmark.py - changed benchmarking link; needs testing * fix #112 - don't subset cpuinfo (#114) * Introduce CI/CD for TensorFLow version (#122) * Update .gitignore * CI/CD update python version * CI/CD update actions versions * CI/CD update trigger events * CI/CD update MacOS version * dlclibrary set version to >=0.0.6 * Poetry lock * Poetry lock * Pyproject.toml update tensorflow installation * Poetry lock * Install specific tensorflow-io-gcs-filesystem for windows * Poetry lock * Update deprecated section name * Poetry lock * CI/CD test on python 3.11, 3.12, 3.13 as well * Update testing.yml - rename to main - add tables installation --------- Co-authored-by: Mackenzie Mathis <[email protected]> * master --> main * Update testing.yml * Update benchmark.py * Update README & benchmarking script (#126) * Update README.md fix test instructions * Update check_install.py * Update check_install.py * Update check_install.py * Update pyproject.toml (#125) * Update pyproject.toml - adding support for python 3.11, 3.12, 3.13 * Update testing.yml * Update testing.yml * Update pyproject.toml * Update testing.yml * Update pyproject.toml * Update poetry.lock * Update poetry.lock * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update testing.yml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update testing.yml * Update pyproject.toml * Update pyproject.toml * Update poetry.lock * Update testing.yml * Update testing.yml * Update testing.yml - remove poetry (for now) * Update testing.yml * Update testing.yml * Update testing.yml * Update testing.yml * Update testing.yml * updated poetry.lock * updated * Update testing.yml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update testing.yml testing 3.11 * Update testing.yml * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Update testing.yml * updated test for win32 * Update testing.yml * Update testing.yml * Update testing.yml * Update testing.yml * Fix download_benchmarking_data() * Ignore __MACOSX directories * Run tests on all PRs * tensorflow-io-gcs-filesystem - python=3.9 * Pin python to 3.10 version * WIP refactor benchmarking: __init__.py * WIP refactor benchmarking: remove dupplicates * WIP refactor benchmarking: warning * WIP refactor benchmarking: close live * WIP refactor benchmarking: resize and pixels * WIP refactor benchmarking: get_sys_info * Update benchmark.py (#123) * WIP refactor benchmarking: Delete dupplicate scripts * WIP refactor benchmarking: Introduce Engine * WIP refactor benchmarking: benchmark() method * WIP refactor benchmarking: benchmark_videos() * CI/CD: add torch installation * WIP refactor benchmarking: extract Engine * Refactor benchmarking: model_type in benchmark_videos() * Delete poetry lock * Fix frame_batch initialization in runner.py when low detection confidence (#138) --------- Co-authored-by: Mackenzie Mathis <[email protected]> Co-authored-by: Jonny Saunders <[email protected]> Co-authored-by: Artur <[email protected]>
|
@copilot resolve conflicts |
|
@MMathisLab I've opened a new pull request, #146, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request updates DeepLabCut-Live to version 3.0.0a0, adding PyTorch engine support for models exported with DeepLabCut 3.0 while maintaining backward compatibility with TensorFlow models. The code is structured to require only the engine-specific dependencies (PyTorch or TensorFlow) based on the model being used.
Changes:
- Updated to version 3.0.0a0 with Python 3.10+ support
- Added PyTorch runner and model infrastructure for DLC 3.0 models
- Maintained TensorFlow runner for legacy model support
- Updated installation documentation for both desktop and Jetson platforms
- Added new test and utility scripts for benchmarking and model export
Reviewed changes
Copilot reviewed 79 out of 84 changed files in this pull request and generated 31 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Updated version to 3.0.0a0, Python to 3.10-3.11, made TensorFlow/PyTorch optional dependencies |
| poetry.lock | Regenerated lock file (removed old dependencies) |
| dlclive/version.py | Updated version string to 3.0.0a0 |
| dlclive/utils.py | Added type hints, improved exception handling, cleaned up formatting |
| dlclive/processor/*.py | Modernized class definitions, cleaned up formatting |
| dlclive/predictor/*.py | New predictor modules for pose estimation |
| dlclive/pose_estimation_tensorflow/*.py | Refactored TensorFlow inference code into separate module |
| dlclive/pose_estimation_pytorch/*.py | New PyTorch runner and model infrastructure |
| tests/test_benchmark_script.py | New functional test for benchmarking |
| scripts/*.py | New utility scripts for export and import fixing |
| docs/*.md | Updated installation instructions for PyTorch and new Python versions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| benchmark_videos( | ||
| args.model_path, | ||
| args.video_path, | ||
| output=args.output, | ||
| resize=args.resize, | ||
| pixels=args.pixels, | ||
| cropping=args.cropping, | ||
| dynamic=args.dynamic, | ||
| n_frames=args.n_frames, | ||
| print_rate=args.print_rate, | ||
| video_path=args.video_path, | ||
| model_path=args.model_path, | ||
| model_type=args.model_type, | ||
| device=args.device, | ||
| precision=args.precision, | ||
| display=args.display, | ||
| pcutoff=args.pcutoff, | ||
| display_radius=args.display_radius, | ||
| cmap=args.cmap, | ||
| resize=tuple(args.resize) if args.resize else None, | ||
| cropping=args.cropping, | ||
| dynamic=tuple(args.dynamic), | ||
| save_poses=args.save_poses, | ||
| save_dir=args.save_dir, | ||
| draw_keypoint_names=args.draw_keypoint_names, | ||
| cmap=args.cmap, | ||
| get_sys_info=args.get_sys_info, | ||
| save_video=args.save_video, | ||
| ) |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keyword argument 'precision' is not a supported parameter name of function benchmark_videos.
Keyword argument 'save_dir' is not a supported parameter name of function benchmark_videos.
Keyword argument 'device' is not a supported parameter name of function benchmark_videos.
Keyword argument 'draw_keypoint_names' is not a supported parameter name of function benchmark_videos.
Keyword argument 'get_sys_info' is not a supported parameter name of function benchmark_videos.
| # Assuming you have 'heatmap' tensor | ||
| max_pooled_heatmap = predictor.max_pool(heatmap) | ||
| """ | ||
| pool1 = torch.nn.MaxPool2d(3, 1, 1) |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable pool1 is not used.
| """ | ||
| pool1 = torch.nn.MaxPool2d(3, 1, 1) | ||
| pool2 = torch.nn.MaxPool2d(5, 1, 2) | ||
| pool3 = torch.nn.MaxPool2d(7, 1, 3) |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable pool3 is not used.
| pool1 = torch.nn.MaxPool2d(3, 1, 1) | ||
| pool2 = torch.nn.MaxPool2d(5, 1, 2) | ||
| pool3 = torch.nn.MaxPool2d(7, 1, 3) | ||
| map_size = (heatmap.shape[1] + heatmap.shape[2]) / 2.0 |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable map_size is not used.
| # Assuming you have 'heatmaps' and 'poses' tensors | ||
| predictor.pose_nms(heatmaps, poses) | ||
| """ | ||
| pose_scores = poses[:, :, :, 2] |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable pose_scores is not used.
| assemblies.remove(store[j]) | ||
| for idx in store[j]._idx: | ||
| store[idx] = store[i] | ||
| except KeyError: |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'except' clause does nothing but pass and there is no explanatory comment.
| except KeyError: | |
| except KeyError: | |
| # Some links may reference indices that were never added to `store`; | |
| # in that case we intentionally skip merging for this link. |
| df = pd.read_hdf(h5_file) | ||
| try: | ||
| df.drop("single", axis=1, level="individuals", inplace=True) | ||
| except KeyError: |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'except' clause does nothing but pass and there is no explanatory comment.
| except KeyError: | |
| except KeyError: | |
| # The "single" individual column is optional; ignore if it is absent. |
| if int(vers[0]) == 2 or int(vers[0]) == 1 and int(vers[1]) > 12: | ||
| tf = tf.compat.v1 | ||
| else: | ||
| tf = tf |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assignment assigns a variable to itself.
| for link in assembly._links: | ||
| i, j = link.idx |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested for statement uses loop variable 'link' of enclosing for statement.
| for link in assembly._links: | |
| i, j = link.idx | |
| for assembly_link in assembly._links: | |
| i, j = assembly_link.idx |
| Returns: | ||
| Output tensor. | ||
| """ | ||
| b, n, _, h = *x.shape, self.heads |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left hand side of assignment contains 4 variables, but right hand side is a tuple of length 2.
|
pushed the state of this branch back to it's state before resolving merge conflicts (copilot suggestions broke the benchmark script) |
This pull requests updates DeepLabCut-Live for models exported with DeepLabCut 3.0. TensorFlow models can still be used, and the code is siloed so that only the engine used to run the code is required as a package (i.e. no need to install TensorFlow if you want to run live pose estimation with PyTorch models).
If you want to give this PR a try, you can install the code in your local
condaenvironment by running:pip install "git+https://github.com/DeepLabCut/DeepLabCut-live.git@dlclive3"