calibration: use .iloc[0] so positional access works under pandas 2.x#37
Open
narr2atnarrable wants to merge 1 commit into
Open
calibration: use .iloc[0] so positional access works under pandas 2.x#37narr2atnarrable wants to merge 1 commit into
narr2atnarrable wants to merge 1 commit into
Conversation
BaselineCalibration, NBJW_Calib and PnLCalib all read the first row of
the per-image metadata DataFrame with metadatas["<col>"][0]. That is
label-based lookup and raises KeyError as soon as the DataFrame's index
is not 0-based.
The ExternalVideo wrapper (dataset=video) keeps the original image_id
as the index, so under pandas 2.x every calibration module crashes with
KeyError: 0
on the first frame. Switching to .iloc[0] selects the first positional
row regardless of the index, which is what the code intends.
No behavioural change on datasets that do reset_index(drop=True) before
calling the calibration module, because then index 0 == position 0.
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.
Summary
Three calibration modules read the first row of their per-image metadata DataFrame with label-based lookup:
sn_gamestate/calibration/baseline.py—metadatas["lines"][0]sn_gamestate/calibration/nbjw_calib.py—metadatas["keypoints"][0]sn_gamestate/calibration/pnlcalib.py—metadatas["keypoints"][0]andmetadatas["lines_det"][0]Under pandas 2.x these crash as soon as the DataFrame's index is not 0-based. The
ExternalVideowrapper (dataset=video) keeps the originalimage_idas the index, so the first frame immediately raises:.iloc[0]selects the first positional row regardless of the index, which is what all three modules intend.Reproduction
Any pandas 2.x install,
dataset=video(ExternalVideo wrapper or any path that preserves the caller's index), calibration module set tobaseline,nbjw_caliborpnlcalib:pip install "pandas>=2.0" python -m tracklab.main -cn soccernet \ dataset=video \ modules.calibration=nbjw_calib \ dataset.video_path=/path/to/clip.mp4First frame raises
KeyError: 0from the calibration module.Change
Four label-lookups → positional lookups:
Risk
None on datasets that do
reset_index(drop=True)before the calibration module runs — then index 0 == position 0 and.iloc[0]returns the same row as[0]would. The change is strictly a bug fix: it makes the code work for the full range of DataFrame indexes, not just the 0-based case.Context
Encountered running
sn-gamestateend-to-end on a Blackwell (sm_120) GPU with a fresh pandas 2.x install. Filed alongside a sibling PR toTrackingLaboratory/tracklabfor a related Windows-path fix; both were needed to get a mixed-OS pipeline running.