Skip to content

Remove _has_warned attribute from detection models #3752

Closed
@datumbox

Description

@datumbox

🚀 Feature

Several detection models make use of an attribute _has_warned which was originally used by JIT to avoid throwing the same warning multiple times:

# used only on torchscript mode
self._has_warned = False

if not self._has_warned:
warnings.warn("RetinaNet always returns a (Losses, Detections) tuple in scripting")
self._has_warned = True

JIT should now be able to handle this automatically without the need of this variable. Thus we should remove the specific variable and confirm that calling forward multiple times on a JIT-scripted model produces a single warning. If that's indeed the case, we can remove it from all places:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions