Prepare TensorFlow deprecation - add deeplabcut.api#3382
Draft
deruyter92 wants to merge 38 commits into
Draft
Conversation
only migrate pose estimation, the dataset creation can be addressed in a separate PR
Collaborator
Author
|
(Needs formatted docstrings and typed configs still) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preparation for full TensorFlow deprecation
deeplabcut.compatand split into PyTorch-onlydeeplabcut.apiand TF-onlydeeplabcut.tensorflow_compatBackground
TensorFlow support will be dropped soon and a clean preparation is needed to make the transition smooth. Although the pose_estimation code was already cleanly branched in
deeplabcut/compat.py, this brought the disadvantage that the main entrypoint for DeepLabCut is actually mixed API, which was not ideal to test and remains a small obstacle to eventually remove TF cleanly.This PR makes a large step towards clean TF deprecation, by splitting the
compatmodule into our new clean user-facing API (Pytorch-only) with a fallback for TensorFlow instead of mixed API. It introduces some new packages and removesdeeplabcut.compatas the entry point for the public API.New
deeplabcut.api: the new home for user-facing API functions. Currently covers all pose estimation functions (train_network, evaluate_network, analyze_videos, analyze_images, etc.), but can cover other main API as well.deeplabcut.tensorflow_compat— an isolated compatibility layer that holds the TensorFlow-specific branches, split out of compat.py. This module is explicitly marked as temporary and will be deleted wholesale when TF support is dropped.deeplabcut.api._tf_routing— a new decorator-based routing system (@with_tensorflow_fallback) that automatically intercepts calls to functions in deeplabcut.api, resolves the engine and delegates todeeplabcut.tensorflow_compathandling TF-only legacy kwargs. ADLCDeprecationWarningis emitted to inform user about the migration.Next steps
This PR intentionally scopes to pose estimation only. (I included
generate_training_datasetas well first, it's probably better to work in incremental changes, rather than one big PR).Several other areas still go through compat or have TF branches inline and need similar treatment in follow-up PRs:
generate_training_dataset) — the largest remaining concern.deeplabcut.utils— scattered TF-conditional helpers.deeplabcut.modelzoo— TF-specific download / inference paths.The goal is that every user-facing function ultimately lives under deeplabcut.api with a clean, PyTorch-only signature, while all TF code is quarantined in deeplabcut.tensorflow_compat and removable in a single future commit.
Test coverage
tests/api/test_pose_estimation.py(480 lines) — smoke tests for the new deeplabcut.api pose estimation surface: parameter forwarding, engine routing, legacy kwarg handling.tests/api/test_tf_routing.py(360 lines) — unit tests for the _tf_routing machinery: engine resolution, renamed/dropped param warnings, gputouse normalisation, multi-shuffle validation.tests/core/test_visualization.py(191 lines) — new coverage for deeplabcut.core.visualization helpers.tests/pose_estimation_pytorch/apis/test_apis_utils.py(102 lines) — new coverage for PyTorch API utilities.