Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'ExponentialMovingAverage' object has no attribute 'gamma' #137

Open
1 of 2 tasks
Minokiti11 opened this issue Jan 18, 2024 · 3 comments
Open
1 of 2 tasks
Labels
bug Something isn't working

Comments

@Minokiti11
Copy link

Minokiti11 commented Jan 18, 2024

Search before asking

  • I have searched the SportsLabKit issues and found no similar bug report.

SportsLabKit Component

No response

Bug

I got this error when trying to run 06_tracking_the_players.ipynb:

スクリーンショット 2024-01-17 14 01 28

Maybe this error is concerned version of torch or other libraries but I couldn't fix this error.

Environment

  • SportsLabKit: 0.3.1 torch: 2.1.2 MacOS:14.2.1(23C71) Python 3.10.0

Minimal Reproducible Example

from sportslabkit.mot import TeamTracker
import numpy as np 

slk.logger.set_log_level('INFO')
det_model = slk.detection_model.load(
    model_name='yolov8',
    model=root/'models/yolov8/model=yolov8x-imgsz=512.pt',
    conf=0.25,
    iou=0.6,
    imgsz=640,
    device='mps',
    classes=0,
    augment=True,
    max_det=35
)

image_model = slk.image_model.load(
    model_name='mobilenetv2_x1_0',
    image_size=(32,32),
    device='cpu'
)

motion_model = slk.motion_model.load(
    model_name='ExponentialMovingAverage',
)
# motion_model = slk.motion_model.load(
#     model_name='SingleTargetLSTM',
#     model='/Users/atom/Github/SoccerTrack/models/teamtrack/LSTM-F_Soccer_Tsukuba3-epoch=79-val_nll_loss=-2.74.ckpt',
# )

keypoint_json = root / 'notebooks/02_user_guide/assets/soccer_keypoints.json'
cam.source_keypoints, cam.target_keypoints = slk.utils.load_keypoints(keypoint_json)

# calibration model return a 3x3 homography matrix for each frame
calibration_model = slk.calibration_model.load(
    model_name='DummyCalibrationModel',
    homographies=cam.H,
    mode='constant'
)

first_matching_fn = slk.matching.MotionVisualMatchingFunction(
    motion_metric=slk.metrics.EuclideanCMM2D(use_pred_pt=True),
    motion_metric_gate=0.2,
    visual_metric=slk.metrics.CosineCMM(),
    visual_metric_gate=0.2,
    beta=0.9,
)

second_matching_fn = slk.matching.SimpleMatchingFunction(
    metric=slk.metrics.EuclideanCMM2D(use_pred_pt=True),
    gate=0.9,
)

# team_detection_callback = slk.callbacks.TeamDetectionCallback(classication_model=TeamClassifier())

class PrintingCallback(): # removed 'slk.callbacks.Callback' because there is no 'Callback' class in mot/callbacks
    def on_track_sequence_start(self, tracker):
        tracklets = tracker.alive_tracklets + tracker.dead_tracklets
        print(f"Tracking started with {len(tracklets)} tracklets")
    
    def on_track_sequence_end(self, tracker):
        tracklets = tracker.alive_tracklets + tracker.dead_tracklets
        print(f"Tracking ended with {len(tracklets)} tracklets")

callbacks = [PrintingCallback()]

tracker = TeamTracker(
    detection_model=det_model,
    image_model=image_model,
    motion_model=motion_model,
    calibration_model=calibration_model,
    first_matching_fn=first_matching_fn,
    second_matching_fn=second_matching_fn,
    detection_score_threshold=0.6,
    max_staleness=2,
    min_length=2,
    callbacks=callbacks,
)

tracker.track(frames)[0]

Additional

'SingleTargetLinear' is not available, so I used EMA instead of it.

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@Minokiti11 Minokiti11 added the bug Something isn't working label Jan 18, 2024
@AtomScott
Copy link
Owner

Thanks for the PR! I will check it this weekend, sorry for the late response!

@hangingter
Copy link

hangingter commented Apr 8, 2024

image
add one line in init fix this.
self.gamma = gamma

@Minokiti11
Copy link
Author

@hangingter
Thanks a lot!
I'll try it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants