Skip to content

Commit

Permalink
Refactor detection id
Browse files Browse the repository at this point in the history
  • Loading branch information
VlSomers committed Feb 9, 2024
1 parent 212ee10 commit 1103ef1
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions tracklab/wrappers/datasets/soccernet/soccernet_game_state.py
Original file line number Diff line number Diff line change
@@ -252,10 +252,9 @@ def load_set(dataset_path, nvid=-1, vids_filter_set=None):
# Person id as unique 0-based index
detections['person_id'] = pd.factorize(detections['person_id'])[0]

# Sort to obtain deterministic ids and index
# Use video_id, image_id, track_id as unique id
detections = detections.sort_values(by=['video_id', 'image_id', 'track_id'], ascending=[True, True, True])
detections = detections.reset_index(drop=True)
detections['id'] = detections.index
detections['id'] = detections['video_id'].astype(str) + "_" + detections['image_id'].astype(str) + "_" + detections['track_id'].astype(str)

# add camera parameters and pitch as ground truth
pitch_camera = pd.concat(annotations_pitch_camera_list, ignore_index=True)
6 changes: 3 additions & 3 deletions tracklab/wrappers/datasets/soccernet/soccernet_mot.py
Original file line number Diff line number Diff line change
@@ -208,10 +208,10 @@ def load_set(dataset_path, nvid=-1, vids_filter_set=None):
image_metadata = pd.concat(image_metadata_list, ignore_index=True)
detections = pd.concat(detections_list, ignore_index=True)

# Sort to obtain deterministic ids and index
# Use video_id, image_id, track_id as unique id
detections = detections.sort_values(by=['video_id', 'image_id', 'track_id'], ascending=[True, True, True])
detections = detections.reset_index(drop=True)
detections['id'] = detections.index
detections['id'] = detections['video_id'].astype(str) + "_" + detections['image_id'].astype(str) + "_" + detections[
'track_id'].astype(str)

# Add category id to detections
category_to_id = {category['name']: category['id'] for category in categories_list}

0 comments on commit 1103ef1

Please sign in to comment.