Fix torch import guards in rtdetr_pose to allow execution without torch installed#11
Draft
Fix torch import guards in rtdetr_pose to allow execution without torch installed#11
Conversation
…errors Co-authored-by: thinksyncs <42225585+thinksyncs@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with code execution
Fix torch import guards in rtdetr_pose to allow execution without torch installed
Feb 22, 2026
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.
Several
rtdetr_posemodules imported directly fromtorchat module level with no fallback, causingModuleNotFoundErrorin any environment without torch — even when the code path being exercised has no torch dependency (e.g. argument parsing, run-dir defaulting).Root cause
The import chain
tools/train_minimal.py→rtdetr_pose.train_minimal→factory→models.backboneshit these unguarded imports before any torch-optional logic could execute:backbone_interface.py—from torch import Tensor, nnbackbone_projector.py—from torch import Tensor, nnmodels/backbones/blocks.py—import torch; from torch import nnmodels/backbones/csp_backbones.py—from torch import Tensor, nnmodels/backbones/torchvision_backbones.py—from torch import TensorChanges
try/except ImportErrorstubs, matching the existing pattern inmodel.py,losses.py,factory.py, etc.backbone_interface.pyuses a named stub_NNModuleStubrather thanobjectas thenn.Modulefallback —class BaseBackbone(object, ABC)triggers a Python MRO error; a non-object-rooted stub resolves it cleanly:✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.