Skip to content

fix(MOT17/reid): multiple compatibility and reliability issues in basemodel.py #523

Description

@iron-prog

What happened:

examples/MOT17/multiedge_inference_bench/pedestrian_tracking/testalgorithms/reid/m3l/basemodel.py contains multiple issues that affect portability, reliability, and PyTorch compatibility:

  1. Checkpoint architecture parsing assumes filenames follow a strict pattern and crashes with AttributeError when they do not.
  2. Hardcoded .cuda() calls fail on CPU-only and Apple Silicon (MPS) environments.
  3. Deprecated addmm_() overload triggers warnings on PyTorch 2.x.
  4. Runtime messages use print() instead of the project's logging infrastructure.

These issues were reproduced on macOS Apple Silicon using PyTorch 2.8.0.


What you expected to happen:

  1. Invalid checkpoint filenames should raise a clear error message instead of an unhandled exception.
  2. Device selection should automatically support CUDA, MPS, and CPU environments.
  3. Distance computation should run without PyTorch deprecation warnings.
  4. Runtime output should use the project's logger rather than direct print() statements.

How to reproduce it (as minimally and precisely as possible):

Bug 1: Invalid checkpoint filename crash

Current code:

arch = re.compile("_([a-zA-Z]+).pth").search(model_url).group(1)

Reproduction:

import re

for url in [
    "model_v2.pth",
    "checkpoint.pth",
    "/path/to/model.pth",
]:
    re.compile("_([a-zA-Z]+).pth").search(url).group(1)

Result:

AttributeError: 'NoneType' object has no attribute 'group'

Bug 2: Hardcoded CUDA dependency

Current code:

self.model.cuda()
inputs = to_torch(inputs).cuda()

Reproduction:

import torch

x = torch.tensor([1])
x.cuda()

Result:

AssertionError: Torch not compiled with CUDA enabled

Bug 3: Deprecated addmm_() overload

Current code:

dist_m.addmm_(1, -2, x, y.t())

Result:

UserWarning: This overload of addmm_ is deprecated:
addmm_(Number beta, Number alpha, Tensor mat1, Tensor mat2)

Bug 4: Direct print() statements

Current code:

print("=> Loaded checkpoint '{}'".format(model_url))
print("Extract Features: [{}/{}]\t"...)

These bypass the project's logging framework and produce inconsistent runtime output.


Anything else we need to know?:

Environment:

  • OS: macOS 14 (Apple Silicon ARM64)
  • Python: 3.9
  • PyTorch: 2.8.0
  • CUDA: Not available
  • MPS: Available

I have prepared fixes and regression tests covering all four issues in basemodel.py.

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions