Skip to content

Use os.path.basename for the smoothing output path - #1

Open
itzzdev09 wants to merge 1 commit into
tstanczyk95:mainfrom
itzzdev09:fix/smoothing-output-path-on-windows
Open

Use os.path.basename for the smoothing output path#1
itzzdev09 wants to merge 1 commit into
tstanczyk95:mainfrom
itzzdev09:fix/smoothing-output-path-on-windows

Conversation

@itzzdev09

Copy link
Copy Markdown

Hi Tomasz — small companion to McByte#6, which covers the same pattern in the other repo.

tools/optional_smoothing.py:26 takes a filename by splitting on a literal /:

seq_name = seq_txt.split('/')[-1]

glob returns OS-native separators, so on Windows the whole path survives the split. os.path.join discards its first argument when the second is absolute, so save_path is dropped entirely:

glob returned:  C:\...\in\MOT17-02.txt
current  destination -> C:\...\in\MOT17-02.txt      # back over the input
correct  destination -> C:\...\out\MOT17-02.txt

The interpolated results overwrite the tracking output they were just read from, so the original is lost.

Why this one line

demo_track__no_reid.py and demo_track__with_reid.py in this repo already use osp.basename throughout — zero occurrences of the split('/') pattern between them. This single line looks like it was simply missed, so the change just brings it in line with the rest of the repo.

No behaviour change on Linux

For '/data/res/MOT17-02.txt', 'res/MOT17-02.txt' and 'MOT17-02.txt', split('/')[-1] and os.path.basename return identical results. Only paths containing a backslash are affected, which cannot occur on POSIX.

🤖 Generated with Claude Code

tools/optional_smoothing.py takes a filename by splitting on a literal '/':

    seq_name = seq_txt.split('/')[-1]

glob returns OS-native separators, so on Windows the whole path survives the
split. os.path.join discards its first argument when the second is absolute, so
save_path is dropped and the interpolated results are written back over the
tracking output they were read from.

The demo_track__no_reid.py and demo_track__with_reid.py files in this repo
already use osp.basename throughout; this one line was missed.

No behaviour change on POSIX: for '/data/res/MOT17-02.txt', 'res/MOT17-02.txt'
and 'MOT17-02.txt', split('/')[-1] and os.path.basename return identical
results. Only paths containing a backslash are affected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant