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

#137 · open · 3 comments

View on GitHub ↗

Minokiti11

### Search before asking - [X] I have searched the SportsLabKit [issues](https://github.com/AtomScott/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: <img width="1550" alt="スクリーンショット 2024-01-17 14 01 28" src="https://github.com/AtomScott/SportsLabKit/assets/69467687/3b1177b2-c50c-4ae2-9c58-98dba0cc5d39"> 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 ```python:example.py 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!

Comments

AtomScott

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

hangingter

![image](https://github.com/AtomScott/SportsLabKit/assets/28148069/9d332470-4bda-4c9f-b82b-6332852eb60a) add one line in __init__ fix this. self.gamma = gamma

Minokiti11

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