opensportslib 0.3.4.dev1__py3-none-any.whl → 0.3.4.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opensportslib/apis/_streaming.py +158 -0
- opensportslib/apis/base_task_model.py +50 -0
- opensportslib/apis/classification.py +37 -35
- opensportslib/apis/localization.py +104 -9
- opensportslib/cli.py +3 -0
- opensportslib/configs/classification/sngar_frames.yaml +1 -1
- opensportslib/configs/classification/sngar_tracking.yaml +1 -1
- opensportslib/configs/classification/video.yaml +1 -1
- opensportslib/configs/localization/calf_resnetpca512.yaml +1 -1
- opensportslib/configs/localization/e2espot/finediving_big_rgb.yaml +198 -0
- opensportslib/configs/localization/e2espot/finediving_head_asformer.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_head_deeper_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_head_mstcn.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_head_multiscale_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_length_16.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_length_25.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_length_250.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_length_50.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_length_8.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_no_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_no_gsm.yaml +204 -0
- opensportslib/configs/localization/e2espot/finediving_no_gsm_no_gru.yaml +205 -0
- opensportslib/configs/localization/e2espot/finediving_resolution_112.yaml +205 -0
- opensportslib/configs/localization/e2espot/finediving_small_rgb.yaml +198 -0
- opensportslib/configs/localization/e2espot/finediving_tsm.yaml +204 -0
- opensportslib/configs/localization/e2espot/finegym_big_rgb.yaml +226 -0
- opensportslib/configs/localization/e2espot/finegym_head_asformer.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_head_deeper_gru.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_head_mstcn.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_head_multiscale_gru.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_length_16.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_length_25.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_length_250.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_length_50.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_length_500.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_length_8.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_no_gru.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_no_gsm.yaml +232 -0
- opensportslib/configs/localization/e2espot/finegym_no_gsm_no_gru.yaml +233 -0
- opensportslib/configs/localization/e2espot/finegym_resolution_112.yaml +233 -0
- opensportslib/configs/localization/e2espot/finegym_small_rgb.yaml +226 -0
- opensportslib/configs/localization/e2espot/finegym_tsm.yaml +232 -0
- opensportslib/configs/localization/e2espot/fs_comp_big_rgb.yaml +198 -0
- opensportslib/configs/localization/e2espot/fs_comp_head_asformer.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_head_deeper_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_head_mstcn.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_head_multiscale_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_length_16.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_length_25.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_length_250.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_length_50.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_length_500.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_length_8.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_no_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_no_gsm.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_comp_no_gsm_no_gru.yaml +205 -0
- opensportslib/configs/localization/e2espot/fs_comp_resolution_112.yaml +205 -0
- opensportslib/configs/localization/e2espot/fs_comp_small_rgb.yaml +198 -0
- opensportslib/configs/localization/e2espot/fs_comp_tsm.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_big_rgb.yaml +198 -0
- opensportslib/configs/localization/e2espot/fs_perf_head_asformer.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_head_deeper_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_head_mstcn.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_head_multiscale_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_length_16.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_length_25.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_length_250.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_length_50.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_length_500.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_length_8.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_no_gru.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_no_gsm.yaml +204 -0
- opensportslib/configs/localization/e2espot/fs_perf_no_gsm_no_gru.yaml +205 -0
- opensportslib/configs/localization/e2espot/fs_perf_resolution_112.yaml +205 -0
- opensportslib/configs/localization/e2espot/fs_perf_small_rgb.yaml +198 -0
- opensportslib/configs/localization/e2espot/fs_perf_tsm.yaml +204 -0
- opensportslib/configs/localization/e2espot/soccernet_big_rgb.yaml +210 -0
- opensportslib/configs/localization/e2espot/soccernet_small_rgb.yaml +210 -0
- opensportslib/configs/localization/e2espot/soccernetball_big_rgb.yaml +205 -0
- opensportslib/configs/localization/e2espot/soccernetball_small_rgb.yaml +205 -0
- opensportslib/configs/localization/e2espot/tennis_big_rgb.yaml +200 -0
- opensportslib/configs/localization/e2espot/tennis_head_asformer.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_head_deeper_gru.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_head_mstcn.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_head_multiscale_gru.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_length_16.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_length_25.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_length_250.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_length_50.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_length_500.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_length_8.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_no_gru.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_no_gsm.yaml +206 -0
- opensportslib/configs/localization/e2espot/tennis_no_gsm_no_gru.yaml +207 -0
- opensportslib/configs/localization/e2espot/tennis_resolution_112.yaml +207 -0
- opensportslib/configs/localization/e2espot/tennis_small_rgb.yaml +200 -0
- opensportslib/configs/localization/e2espot/tennis_tsm.yaml +206 -0
- opensportslib/configs/localization/feature-pooling/soccernet_netrvlad_baidu.yaml +174 -0
- opensportslib/configs/localization/feature-pooling/soccernet_netrvlad_resnet_pca512.yaml +174 -0
- opensportslib/configs/localization/feature-pooling/soccernet_netrvladpp_baidu.yaml +174 -0
- opensportslib/configs/localization/feature-pooling/soccernet_netrvladpp_resnet_pca512.yaml +174 -0
- opensportslib/configs/localization/feature-pooling/soccernet_netvlad_baidu.yaml +174 -0
- opensportslib/configs/localization/feature-pooling/soccernet_netvlad_resnet_pca512.yaml +174 -0
- opensportslib/configs/localization/feature-pooling/soccernet_netvladpp_baidu.yaml +174 -0
- opensportslib/configs/localization/feature-pooling/soccernet_netvladpp_resnet_pca512.yaml +174 -0
- opensportslib/configs/localization/h5_header_distance.yaml +2 -2
- opensportslib/configs/localization/h5_header_skeleton.yaml +2 -2
- opensportslib/configs/localization/netvladpp_resnetpca512.yaml +1 -1
- opensportslib/configs/localization/tdeed/FigureSkatingComp_big.yaml +129 -0
- opensportslib/configs/localization/tdeed/FigureSkatingComp_small.yaml +129 -0
- opensportslib/configs/localization/tdeed/FigureSkatingComp_small_paper.yaml +129 -0
- opensportslib/configs/localization/tdeed/FigureSkatingPerf_big.yaml +129 -0
- opensportslib/configs/localization/tdeed/FigureSkatingPerf_small.yaml +129 -0
- opensportslib/configs/localization/tdeed/FigureSkatingPerf_small_paper.yaml +129 -0
- opensportslib/configs/localization/tdeed/FineDiving_big.yaml +129 -0
- opensportslib/configs/localization/tdeed/FineDiving_small.yaml +129 -0
- opensportslib/configs/localization/tdeed/FineGym_big.yaml +157 -0
- opensportslib/configs/localization/tdeed/FineGym_small.yaml +157 -0
- opensportslib/configs/localization/tdeed/SoccerNetBall_challenge1.yaml +166 -0
- opensportslib/configs/localization/tdeed/SoccerNetBall_challenge1_bas_only.yaml +137 -0
- opensportslib/configs/localization/tdeed/SoccerNetBall_challenge2.yaml +166 -0
- opensportslib/configs/localization/tdeed/SoccerNetBall_challenge2_bas_only.yaml +137 -0
- opensportslib/configs/localization/tdeed/SoccerNet_big.yaml +143 -0
- opensportslib/configs/localization/tdeed/SoccerNet_small.yaml +143 -0
- opensportslib/configs/localization/tdeed/Tennis_big.yaml +131 -0
- opensportslib/configs/localization/tdeed/Tennis_small.yaml +131 -0
- opensportslib/configs/localization/tdeed/finediving_dilation_0.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_dilation_1.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_displacement_1.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_displacement_2.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_gsf_all.yaml +130 -0
- opensportslib/configs/localization/tdeed/finediving_gsf_half.yaml +130 -0
- opensportslib/configs/localization/tdeed/finediving_gsm_all.yaml +130 -0
- opensportslib/configs/localization/tdeed/finediving_gsm_half.yaml +130 -0
- opensportslib/configs/localization/tdeed/finediving_length_100.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_length_200.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_length_25.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_length_50.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_nms.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_plain_gru.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_plain_sgp.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_plain_transformer.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_sgp_mixer_concat.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_sgp_mixer_sum.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_skip_concat.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_skip_none.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_skip_sum.yaml +129 -0
- opensportslib/configs/localization/tdeed/finediving_soft_nms.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_dilation_0.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_dilation_1.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_displacement_1.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_displacement_2.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_gsf_all.yaml +130 -0
- opensportslib/configs/localization/tdeed/fs_comp_gsf_half.yaml +130 -0
- opensportslib/configs/localization/tdeed/fs_comp_gsm_all.yaml +130 -0
- opensportslib/configs/localization/tdeed/fs_comp_gsm_half.yaml +130 -0
- opensportslib/configs/localization/tdeed/fs_comp_length_100.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_length_200.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_length_25.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_length_50.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_nms.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_plain_gru.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_plain_sgp.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_plain_transformer.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_sgp_mixer_concat.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_sgp_mixer_sum.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_skip_concat.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_skip_none.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_skip_sum.yaml +129 -0
- opensportslib/configs/localization/tdeed/fs_comp_soft_nms.yaml +129 -0
- opensportslib/configs/localization/tracking_action_spotting.yaml +1 -1
- opensportslib/configs/localization/video_dali.yaml +1 -1
- opensportslib/configs/localization/video_ocv.yaml +1 -1
- opensportslib/configs/vqa/qwen_sngar_frames.yaml +1 -1
- opensportslib/core/config/validate.py +38 -0
- opensportslib/core/loss/nll.py +2 -0
- opensportslib/core/scheduler/builder.py +3 -0
- opensportslib/core/trainer/classification_trainer.py +86 -41
- opensportslib/core/trainer/localization_trainer.py +102 -24
- opensportslib/core/trainer/tdeed_trainer.py +565 -0
- opensportslib/core/utils/data.py +15 -3
- opensportslib/core/utils/lightning.py +27 -2
- opensportslib/core/utils/load_annotations.py +24 -2
- opensportslib/datasets/classification_dataset.py +30 -0
- opensportslib/datasets/localization_dataset.py +117 -5
- opensportslib/datasets/tdeed.py +284 -0
- opensportslib/datasets/video_dali.py +129 -0
- opensportslib/datasets/video_raw.py +266 -0
- opensportslib/legacy_config/classification.yaml +1 -1
- opensportslib/legacy_config/localization-e2e-ocv.yaml +1 -1
- opensportslib/legacy_config/localization-json_calf_resnetpca512.yaml +1 -1
- opensportslib/legacy_config/localization-json_netvlad++_resnetpca512.yaml +1 -1
- opensportslib/legacy_config/localization.yaml +1 -1
- opensportslib/legacy_config/sngar-frames.yaml +1 -1
- opensportslib/legacy_config/sngar-tracking.yaml +1 -1
- opensportslib/metrics/localization_metric.py +36 -25
- opensportslib/metrics/tdeed.py +197 -0
- opensportslib/models/backbones/builder.py +31 -8
- opensportslib/models/base/e2e.py +47 -8
- opensportslib/models/base/learnablepooling.py +45 -2
- opensportslib/models/base/tdeed.py +256 -0
- opensportslib/models/base/tracking.py +28 -2
- opensportslib/models/builder.py +5 -1
- opensportslib/models/heads/builder.py +3 -1
- opensportslib/models/preprocessors.py +280 -0
- opensportslib/models/utils/impl/tdeed/LICENSE +674 -0
- opensportslib/models/utils/impl/tdeed/LICENSE-E2E-Spot +27 -0
- opensportslib/models/utils/impl/tdeed/__init__.py +1 -0
- opensportslib/models/utils/impl/tdeed/ablations.py +95 -0
- opensportslib/models/utils/impl/tdeed/deterministic.py +72 -0
- opensportslib/models/utils/impl/tdeed/gsf.py +96 -0
- opensportslib/models/utils/impl/tdeed/gsm.py +119 -0
- opensportslib/models/utils/impl/tdeed/modules.py +337 -0
- opensportslib/models/utils/impl/tdeed/network.py +180 -0
- opensportslib/models/utils/impl/tdeed/shift.py +97 -0
- opensportslib/models/utils/modules.py +33 -0
- opensportslib/preprocessing/__init__.py +7 -0
- opensportslib/preprocessing/__main__.py +45 -0
- opensportslib/preprocessing/backend.py +169 -0
- opensportslib/preprocessing/benchmark.py +194 -0
- opensportslib/preprocessing/cache.py +163 -0
- opensportslib/preprocessing/config.py +52 -0
- opensportslib/preprocessing/diagnostics.py +67 -0
- opensportslib/preprocessing/records.py +115 -0
- opensportslib/preprocessing/sampling.py +41 -0
- opensportslib/preprocessing/selection.py +149 -0
- opensportslib/preprocessing/session.py +182 -0
- opensportslib/preprocessing/visualization.py +224 -0
- opensportslib/preprocessing/windows.py +78 -0
- opensportslib/setup/setup.py +44 -1
- opensportslib-0.3.4.dev2.dist-info/METADATA +176 -0
- opensportslib-0.3.4.dev2.dist-info/RECORD +490 -0
- {opensportslib-0.3.4.dev1.dist-info → opensportslib-0.3.4.dev2.dist-info}/WHEEL +1 -1
- scripts/run_h5_header_rule_inference.py +1 -1
- tests/helpers/video_pose.py +87 -0
- tests/integration/classification/test_pipeline.py +131 -0
- tests/integration/localization/test_pipeline.py +389 -0
- tests/integration/localization/test_tdeed.py +169 -0
- tests/release/test_video_skeleton_release.py +66 -0
- tests/unit/api/test_from_pretrained.py +60 -0
- tests/unit/api/test_task_model_contract.py +43 -0
- tests/unit/api/test_vqa.py +1 -1
- tests/unit/config/test_architecture.py +27 -0
- tests/unit/config/test_split_overrides.py +7 -7
- tests/unit/contracts/test_dependencies.py +1 -0
- tests/unit/core/test_classification_trainer.py +90 -0
- tests/unit/core/test_localization_trainer.py +132 -0
- tests/unit/core/test_training_components.py +19 -0
- tests/unit/core/test_video_processing.py +35 -0
- tests/unit/data/test_localization_intervals.py +64 -0
- tests/unit/data/test_video_skeleton.py +461 -0
- tests/unit/models/test_e2e.py +51 -0
- tests/unit/models/test_localization_metrics.py +17 -0
- tests/unit/models/test_tdeed.py +181 -0
- tests/unit/tools/test_conversion.py +173 -0
- tests/unit/tools/test_experiment_queue.py +1131 -0
- tests/unit/tools/test_experiment_release.py +585 -0
- tests/unit/tools/test_paper_queue.py +179 -0
- tests/unit/tools/test_record_training.py +73 -0
- tests/unit/tools/test_setup.py +51 -0
- tests/unit/tools/test_spotting_classification.py +494 -0
- tests/unit/tools/test_tdeed_reproduction.py +197 -0
- tools/convert/audit_spotting_dataset.py +117 -0
- tools/convert/build_soccernet_gar_action_spotting.py +2 -2
- tools/convert/clean_tennis_spotting.py +140 -0
- tools/convert/dallas_to_classification.py +200 -0
- tools/convert/lossless_video.py +53 -0
- tools/convert/prepare_figureskating_spotting.py +91 -0
- tools/convert/prepare_finediving_spotting.py +161 -0
- tools/convert/prepare_finegym_spotting.py +137 -0
- tools/convert/tennis_to_classification.py +423 -0
- tools/download/rebuild_finegym_from_opendatalab.py +502 -0
- tools/inference/inspect_video.py +153 -0
- tools/reproduction/audit_soccernet_media.py +99 -0
- tools/reproduction/build_e2espot_configs.py +236 -0
- tools/reproduction/check_e2espot_parity.py +245 -0
- tools/reproduction/check_tdeed_parity.py +144 -0
- tools/reproduction/export_tdeed.py +183 -0
- tools/reproduction/paper_queue.py +245 -0
- tools/reproduction/prepare_tdeed_soccer.py +329 -0
- tools/reproduction/public_evidence.py +174 -0
- tools/reproduction/record_training.py +170 -0
- tools/reproduction/release_catalog.py +247 -0
- tools/reproduction/smoke_tdeed.py +79 -0
- tools/reproduction/tdeed.py +558 -0
- tools/reproduction/validate_publication.py +74 -0
- tools/slurm/dataset_cards.py +425 -0
- tools/slurm/experiment_adapters.py +459 -0
- tools/slurm/experiment_data.py +378 -0
- tools/slurm/experiment_io.py +116 -0
- tools/slurm/experiment_release.py +292 -0
- tools/slurm/experiment_retries.py +314 -0
- tools/slurm/feature_data.py +122 -0
- tools/slurm/model_cards.py +655 -0
- tools/slurm/prediction_exports.py +193 -0
- tools/slurm/queue_experiments.py +763 -0
- tools/slurm/reproduce_localization.py +376 -0
- tools/train/train_tennis_dallas.py +283 -0
- tools/train/train_tennis_dallas_spotting.py +236 -0
- tools/train/train_tennis_skeleton.py +78 -0
- tools/upload/upload_figureskating_spotting.py +138 -0
- tools/upload/upload_finediving_spotting.py +162 -0
- tools/upload/upload_sngar_tracking_full.py +1 -1
- tools/upload/upload_sngar_videos.py +1 -1
- tools/upload/upload_tennis_classification.py +189 -0
- tools/upload/upload_tennis_dallas.py +208 -0
- tools/upload/upload_tennis_spotting_cleanup.py +129 -0
- opensportslib-0.3.4.dev1.dist-info/METADATA +0 -348
- opensportslib-0.3.4.dev1.dist-info/RECORD +0 -246
- {opensportslib-0.3.4.dev1.dist-info → opensportslib-0.3.4.dev2.dist-info}/entry_points.txt +0 -0
- {opensportslib-0.3.4.dev1.dist-info → opensportslib-0.3.4.dev2.dist-info}/licenses/LICENSE +0 -0
- {opensportslib-0.3.4.dev1.dist-info → opensportslib-0.3.4.dev2.dist-info}/licenses/LICENSE-COMMERCIAL +0 -0
- {opensportslib-0.3.4.dev1.dist-info → opensportslib-0.3.4.dev2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Small action-task orchestration helpers; no alternative model framework."""
|
|
2
|
+
from collections import deque
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
from opensportslib.core.config.accessors import (
|
|
9
|
+
get_data_sampling, get_data_classes, get_split_cfg,
|
|
10
|
+
)
|
|
11
|
+
from opensportslib.preprocessing.windows import iter_windows, RollingScores, sequence_batch
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def manifest_sources(config, annotation_path):
|
|
15
|
+
"""Resolve video sources from ordinary action annotations."""
|
|
16
|
+
root = Path(getattr(get_split_cfg(config, 'test'), 'source_path', '.') or '.')
|
|
17
|
+
document = json.loads(Path(annotation_path).read_text())
|
|
18
|
+
from opensportslib.core.utils.load_annotations import expand_localization_intervals
|
|
19
|
+
for record in document['data']:
|
|
20
|
+
for segment in expand_localization_intervals(record):
|
|
21
|
+
segment['output_path'] = str(root / segment['logical_path'])
|
|
22
|
+
yield segment['id'], root / segment['source_path'], segment
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class EventFinalizer:
|
|
26
|
+
"""Bounded symmetric local-max suppression, matching existing NMS ties.
|
|
27
|
+
|
|
28
|
+
Keep raw neighboring scores even when their own event was suppressed.
|
|
29
|
+
This matches non_maximum_supression rather than greedy peak removal.
|
|
30
|
+
"""
|
|
31
|
+
def __init__(self, classes, fps, radius=0, threshold=.01, observer=None, offset_seconds=0.):
|
|
32
|
+
self.observer = observer
|
|
33
|
+
self.offset_seconds = offset_seconds
|
|
34
|
+
self.classes, self.fps = classes, fps
|
|
35
|
+
self.radius, self.threshold = int(radius), threshold
|
|
36
|
+
self.pending, self.history = deque(), deque()
|
|
37
|
+
|
|
38
|
+
def _index(self, frame):
|
|
39
|
+
return int((frame.timestamp-self.offset_seconds)*self.fps+1e-7)
|
|
40
|
+
|
|
41
|
+
def push(self, frame, scores):
|
|
42
|
+
self.pending.append((frame, scores))
|
|
43
|
+
current = self._index(frame)
|
|
44
|
+
while self.pending and current >= self._index(self.pending[0][0])+self.radius:
|
|
45
|
+
yield from self._pop()
|
|
46
|
+
|
|
47
|
+
def _pop(self):
|
|
48
|
+
from opensportslib.metrics.localization_metric import frame_score_events
|
|
49
|
+
frame, scores = self.pending.popleft()
|
|
50
|
+
index = self._index(frame)
|
|
51
|
+
while self.history and self._index(self.history[0][0]) < index-self.radius:
|
|
52
|
+
self.history.popleft()
|
|
53
|
+
neighbors = list(self.history) + list(self.pending)
|
|
54
|
+
row = np.asarray(scores).copy()
|
|
55
|
+
for other, other_scores in neighbors:
|
|
56
|
+
other_index = self._index(other)
|
|
57
|
+
if other_index != index and abs(other_index-index) <= self.radius:
|
|
58
|
+
row[np.asarray(other_scores) > scores] = -np.inf
|
|
59
|
+
events = frame_score_events(row, self.classes, int((frame.timestamp-self.offset_seconds)*1000+1e-7), index, self.threshold)
|
|
60
|
+
self.history.append((frame, scores))
|
|
61
|
+
if self.observer is not None:
|
|
62
|
+
self.observer(frame, scores)
|
|
63
|
+
yield from events
|
|
64
|
+
|
|
65
|
+
def finish(self):
|
|
66
|
+
while self.pending:
|
|
67
|
+
yield from self._pop()
|
|
68
|
+
self.history.clear()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def spotting_events(model, config, frames, observer=None, *, fps=None, offset_seconds=0.):
|
|
72
|
+
"""Yield finalized event batches; retain O(window + suppression radius)."""
|
|
73
|
+
sampling = get_data_sampling(config)
|
|
74
|
+
length = int(sampling.get('clip_len', 64))
|
|
75
|
+
split = get_split_cfg(config, 'test')
|
|
76
|
+
overlap = int(getattr(split, 'overlap_len', length//2))
|
|
77
|
+
fps = float(fps if fps is not None else sampling.get('extract_fps', 25))
|
|
78
|
+
rolling = RollingScores()
|
|
79
|
+
finalizer = EventFinalizer(get_data_classes(config), fps,
|
|
80
|
+
getattr(split, 'nms_window', 0) or 0, observer=observer, offset_seconds=offset_seconds)
|
|
81
|
+
shot = None
|
|
82
|
+
|
|
83
|
+
def finalized(rows):
|
|
84
|
+
nonlocal shot
|
|
85
|
+
events = []
|
|
86
|
+
for _, frame, scores in rows:
|
|
87
|
+
if shot is not None and frame.shot_id != shot:
|
|
88
|
+
events.extend(finalizer.finish())
|
|
89
|
+
shot = frame.shot_id
|
|
90
|
+
events.extend(finalizer.push(frame, scores))
|
|
91
|
+
return events
|
|
92
|
+
|
|
93
|
+
source = iter_windows(frames, length, overlap, include_boundaries=True)
|
|
94
|
+
try:
|
|
95
|
+
for window in source:
|
|
96
|
+
if window is None:
|
|
97
|
+
events = finalized(rolling.finish())
|
|
98
|
+
events.extend(finalizer.finish())
|
|
99
|
+
shot = None
|
|
100
|
+
if events:
|
|
101
|
+
yield events
|
|
102
|
+
continue
|
|
103
|
+
events = finalized(rolling.finalize_before(window.indices[0]))
|
|
104
|
+
batch = sequence_batch(window)
|
|
105
|
+
_, scores = model.predict(batch, use_amp=False)
|
|
106
|
+
rolling.add(window, scores[0])
|
|
107
|
+
if events:
|
|
108
|
+
yield events
|
|
109
|
+
events = finalized(rolling.finish())
|
|
110
|
+
events.extend(finalizer.finish())
|
|
111
|
+
if events:
|
|
112
|
+
yield events
|
|
113
|
+
finally:
|
|
114
|
+
close = getattr(frames, 'close', None)
|
|
115
|
+
if close:
|
|
116
|
+
close()
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def evaluate_spotting(config, annotation_path, predictions):
|
|
120
|
+
"""Use OSL mAP/F1 implementations directly on in-memory predictions."""
|
|
121
|
+
from opensportslib.metrics.localization_metric import compute_mAPs_E2E, ForegroundF1
|
|
122
|
+
fps = float(get_data_sampling(config).get('extract_fps', 25))
|
|
123
|
+
classes = {name: i+1 for i, name in enumerate(get_data_classes(config))}
|
|
124
|
+
document = json.loads(Path(annotation_path).read_text())
|
|
125
|
+
if not any(record.get('events') for record in document['data']):
|
|
126
|
+
return None
|
|
127
|
+
sources = list(manifest_sources(config, annotation_path))
|
|
128
|
+
truth = []
|
|
129
|
+
expected = {}
|
|
130
|
+
for identity, path, segment in sources:
|
|
131
|
+
if segment['annotation_status'] != 'verified':
|
|
132
|
+
continue
|
|
133
|
+
events = [dict(label=e['label'], frame=int(float(e['position_ms'])*fps/1000))
|
|
134
|
+
for e in segment['events']]
|
|
135
|
+
name = segment['output_path']
|
|
136
|
+
truth.append({'path': name, 'events': events})
|
|
137
|
+
expected[name] = {e['frame']: classes[e['label']] for e in events}
|
|
138
|
+
pred = []
|
|
139
|
+
f1 = ForegroundF1()
|
|
140
|
+
for record in predictions['data']:
|
|
141
|
+
path = record['inputs'][0]['path']
|
|
142
|
+
if path not in expected:
|
|
143
|
+
continue
|
|
144
|
+
# A common evaluation clock supports videos with different effective FPS.
|
|
145
|
+
events = [{**e, 'frame': int(float(e['position_ms'])*fps/1000)} for e in record['events']]
|
|
146
|
+
pred.append({'video': path, 'events': events})
|
|
147
|
+
# Existing event JSON can contain multiple classes at a frame; choose
|
|
148
|
+
# the strongest emitted event for exact-frame foreground F1.
|
|
149
|
+
strongest = {}
|
|
150
|
+
for event in sorted(events, key=lambda e:e['confidence']):
|
|
151
|
+
strongest[event['frame']] = classes[event['label']]
|
|
152
|
+
frames = sorted(set(expected[path]) | set(strongest))
|
|
153
|
+
for index in frames:
|
|
154
|
+
f1.update(expected[path].get(index,0), strongest.get(index,0))
|
|
155
|
+
tolerances = [int(round(s*fps)) for s in (0,1,2,3,4)]
|
|
156
|
+
maps, _ = compute_mAPs_E2E(truth, pred, tolerances=tolerances)
|
|
157
|
+
return {'mAP': float(np.mean(maps)), 'mAP_by_tolerance_seconds': dict(zip((0,1,2,3,4),maps)),
|
|
158
|
+
'event_foreground_f1': f1.get(None)}
|
|
@@ -60,6 +60,56 @@ def _manifest_media_references(payload: dict[str, Any]):
|
|
|
60
60
|
class BaseTaskModel(ConfigurationMixin, ABC):
|
|
61
61
|
"""Thin shared contract for task-level OpenSportsLib wrappers."""
|
|
62
62
|
|
|
63
|
+
@classmethod
|
|
64
|
+
def from_pretrained(
|
|
65
|
+
cls,
|
|
66
|
+
repo_id: str,
|
|
67
|
+
*,
|
|
68
|
+
revision: str,
|
|
69
|
+
weights_filename: str = "model.pth",
|
|
70
|
+
device: str | None = None,
|
|
71
|
+
cache_dir: str | Path | None = None,
|
|
72
|
+
token: str | bool | None = None,
|
|
73
|
+
local_files_only: bool = False,
|
|
74
|
+
):
|
|
75
|
+
"""Load config.yaml and checkpoint weights from one Hub model revision.
|
|
76
|
+
|
|
77
|
+
Both files are resolved in a single immutable cached snapshot. A tag,
|
|
78
|
+
branch or commit SHA is required explicitly. This checkpoint-file API
|
|
79
|
+
leaves existing constructors and load_weights behavior unchanged.
|
|
80
|
+
"""
|
|
81
|
+
from huggingface_hub import snapshot_download
|
|
82
|
+
|
|
83
|
+
if not isinstance(revision, str) or not revision.strip():
|
|
84
|
+
raise ValueError("revision must be a nonempty Hub tag, branch or commit SHA")
|
|
85
|
+
filename = Path(weights_filename)
|
|
86
|
+
if (
|
|
87
|
+
not weights_filename or filename.is_absolute()
|
|
88
|
+
or ".." in filename.parts or weights_filename == "config.yaml"
|
|
89
|
+
):
|
|
90
|
+
raise ValueError("weights_filename must be a relative checkpoint file path")
|
|
91
|
+
snapshot = Path(snapshot_download(
|
|
92
|
+
repo_id=repo_id, repo_type="model", revision=revision,
|
|
93
|
+
allow_patterns=["config.yaml", filename.as_posix()],
|
|
94
|
+
cache_dir=cache_dir, token=token, local_files_only=local_files_only,
|
|
95
|
+
))
|
|
96
|
+
config_path, checkpoint = snapshot / "config.yaml", snapshot / filename
|
|
97
|
+
for path in [config_path, checkpoint]:
|
|
98
|
+
if not path.is_file():
|
|
99
|
+
raise FileNotFoundError(
|
|
100
|
+
f"{repo_id}@{revision} has no {path.relative_to(snapshot)}; "
|
|
101
|
+
"select a model revision containing config.yaml and its checkpoint"
|
|
102
|
+
)
|
|
103
|
+
config = Config.from_file(config_path)
|
|
104
|
+
if device is not None:
|
|
105
|
+
config.update(runtime={"device": device})
|
|
106
|
+
model = cls(config=config)
|
|
107
|
+
model.load_weights(weights=str(checkpoint))
|
|
108
|
+
model.hf_repo_id = repo_id
|
|
109
|
+
model.hf_revision = revision
|
|
110
|
+
model.hf_snapshot_path = str(snapshot)
|
|
111
|
+
return model
|
|
112
|
+
|
|
63
113
|
def __init__(
|
|
64
114
|
self,
|
|
65
115
|
config=None,
|
|
@@ -164,10 +164,7 @@ class ClassificationModel(BaseTaskModel):
|
|
|
164
164
|
world_size=world_size,
|
|
165
165
|
)
|
|
166
166
|
if rank == 0 and return_queue is not None:
|
|
167
|
-
|
|
168
|
-
return_queue.put(getattr(trainer, "predictions_path", None))
|
|
169
|
-
else:
|
|
170
|
-
return_queue.put(getattr(trainer, "predictions_payload", None))
|
|
167
|
+
return_queue.put(getattr(trainer, "predictions_payload", None))
|
|
171
168
|
finally:
|
|
172
169
|
if rank == 0 and use_wandb and getattr(wandb, "run", None) is not None:
|
|
173
170
|
try:
|
|
@@ -379,39 +376,44 @@ class ClassificationModel(BaseTaskModel):
|
|
|
379
376
|
use_ddp = use_ddp and world_size > 1
|
|
380
377
|
|
|
381
378
|
ctx = mp.get_context("spawn")
|
|
382
|
-
|
|
379
|
+
manager = ctx.Manager() if use_ddp else None
|
|
380
|
+
queue = manager.Queue() if manager is not None else ctx.Queue()
|
|
383
381
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
382
|
+
try:
|
|
383
|
+
if use_ddp:
|
|
384
|
+
mp.spawn(
|
|
385
|
+
ClassificationModel._worker_ddp,
|
|
386
|
+
args=(
|
|
387
|
+
world_size,
|
|
388
|
+
"infer",
|
|
389
|
+
self.config_path,
|
|
390
|
+
self.config,
|
|
391
|
+
queue,
|
|
392
|
+
None,
|
|
393
|
+
None,
|
|
394
|
+
test_set,
|
|
395
|
+
effective_weights,
|
|
396
|
+
use_wandb,
|
|
397
|
+
),
|
|
398
|
+
nprocs=world_size,
|
|
399
|
+
)
|
|
400
|
+
else:
|
|
401
|
+
ClassificationModel._worker_ddp(
|
|
402
|
+
rank=0,
|
|
403
|
+
world_size=1,
|
|
404
|
+
mode="infer",
|
|
405
|
+
config_path=self.config_path,
|
|
406
|
+
config=self.config,
|
|
407
|
+
return_queue=queue,
|
|
408
|
+
test_set=test_set,
|
|
409
|
+
weights=effective_weights,
|
|
410
|
+
use_wandb=use_wandb,
|
|
411
|
+
)
|
|
413
412
|
|
|
414
|
-
|
|
413
|
+
predictions = queue.get()
|
|
414
|
+
finally:
|
|
415
|
+
if manager is not None:
|
|
416
|
+
manager.shutdown()
|
|
415
417
|
if use_ddp and isinstance(predictions, str):
|
|
416
418
|
with open(predictions, encoding="utf-8") as f:
|
|
417
419
|
predictions = json.load(f)
|
|
@@ -226,6 +226,13 @@ class LocalizationModel(BaseTaskModel):
|
|
|
226
226
|
weights: str | None = None,
|
|
227
227
|
**kwargs,
|
|
228
228
|
) -> None:
|
|
229
|
+
if str(get_model_family(self.config)).lower() == "tdeed":
|
|
230
|
+
from opensportslib.core.trainer.tdeed_trainer import ensure_model
|
|
231
|
+
if weights is None:
|
|
232
|
+
raise ValueError("`weights` must be provided to load_weights().")
|
|
233
|
+
ensure_model(self, weights)
|
|
234
|
+
self.best_checkpoint = str(weights)
|
|
235
|
+
return
|
|
229
236
|
from opensportslib.models.builder import build_model
|
|
230
237
|
from opensportslib.core.utils.config import is_local_path, select_device
|
|
231
238
|
from opensportslib.core.utils.checkpoint import (
|
|
@@ -319,6 +326,11 @@ class LocalizationModel(BaseTaskModel):
|
|
|
319
326
|
use_wandb=True,
|
|
320
327
|
**kwargs,
|
|
321
328
|
):
|
|
329
|
+
if str(get_model_family(self.config)).lower() == "tdeed":
|
|
330
|
+
from opensportslib.core.trainer.tdeed_trainer import train
|
|
331
|
+
if kwargs:
|
|
332
|
+
raise TypeError(f"Unsupported T-DEED training options: {', '.join(kwargs)}")
|
|
333
|
+
return train(self, train_set, valid_set, weights)
|
|
322
334
|
from opensportslib.datasets.builder import build_dataset
|
|
323
335
|
from opensportslib.models.builder import build_model
|
|
324
336
|
from opensportslib.core.trainer.localization_trainer import build_trainer
|
|
@@ -423,15 +435,14 @@ class LocalizationModel(BaseTaskModel):
|
|
|
423
435
|
|
|
424
436
|
logging.info("Start training")
|
|
425
437
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
get_train_trainer_type(self.config),
|
|
433
|
-
)
|
|
438
|
+
train_args = get_default_args_train(
|
|
439
|
+
self.model,
|
|
440
|
+
train_loader,
|
|
441
|
+
valid_loader,
|
|
442
|
+
get_data_classes(self.config),
|
|
443
|
+
get_train_trainer_type(self.config),
|
|
434
444
|
)
|
|
445
|
+
self.trainer.train(**train_args)
|
|
435
446
|
|
|
436
447
|
self.best_checkpoint = self.trainer.best_checkpoint_path
|
|
437
448
|
self.last_loaded_weights = self.best_checkpoint
|
|
@@ -439,6 +450,67 @@ class LocalizationModel(BaseTaskModel):
|
|
|
439
450
|
logging.info(f"Total Execution Time is {time.time()-start} seconds")
|
|
440
451
|
return self.best_checkpoint
|
|
441
452
|
|
|
453
|
+
def _prepare_streaming_model(self, weights=None):
|
|
454
|
+
from opensportslib.core.utils.config import resolve_config_omega, select_device
|
|
455
|
+
from opensportslib.models.builder import build_model
|
|
456
|
+
self.config = self._effective_config(resolve_config_omega(self.config, weights=weights))
|
|
457
|
+
self.config = resolve_inference_class_metadata(self.config)
|
|
458
|
+
effective_weights = weights or self.last_loaded_weights
|
|
459
|
+
if effective_weights and (self.model is None or self.last_loaded_weights != effective_weights):
|
|
460
|
+
self.load_weights(effective_weights)
|
|
461
|
+
if self.model is None:
|
|
462
|
+
self.model = build_model(self.config, select_device(self.config.SYSTEM))
|
|
463
|
+
return self.model
|
|
464
|
+
|
|
465
|
+
def infer_stream(self, video_path, weights=None):
|
|
466
|
+
"""Yield finalized OSL event batches with bounded working memory.
|
|
467
|
+
|
|
468
|
+
This uses completed bidirectional windows, not causal prediction.
|
|
469
|
+
Closing the iterator releases the per-video extraction session.
|
|
470
|
+
"""
|
|
471
|
+
from opensportslib.preprocessing.config import requires_raw_video
|
|
472
|
+
from opensportslib.apis._streaming import spotting_events
|
|
473
|
+
from opensportslib.metrics.localization_metric import build_snpro_prediction_json
|
|
474
|
+
from opensportslib.core.config.accessors import get_data_sampling
|
|
475
|
+
if self.is_remote or not requires_raw_video(self.config):
|
|
476
|
+
raise ValueError('infer_stream requires a local pose_tracking spotting model')
|
|
477
|
+
model = self._prepare_streaming_model(weights)
|
|
478
|
+
config = self.config
|
|
479
|
+
from opensportslib.datasets.video_raw import effective_fps
|
|
480
|
+
fps = effective_fps(video_path, float(get_data_sampling(config).get('extract_fps', 25)))
|
|
481
|
+
|
|
482
|
+
def stream():
|
|
483
|
+
events = spotting_events(model, config, model.preprocessor.iter_video(video_path, config), fps=fps)
|
|
484
|
+
try:
|
|
485
|
+
for batch in events:
|
|
486
|
+
yield build_snpro_prediction_json([{'video': str(video_path), 'fps': fps, 'events': batch}],
|
|
487
|
+
split='test')
|
|
488
|
+
finally:
|
|
489
|
+
events.close()
|
|
490
|
+
return stream()
|
|
491
|
+
|
|
492
|
+
def _infer_streaming(self, video_path, test_set, weights):
|
|
493
|
+
from pathlib import Path
|
|
494
|
+
from opensportslib.apis._streaming import manifest_sources, spotting_events
|
|
495
|
+
from opensportslib.core.config.accessors import get_data_sampling
|
|
496
|
+
from opensportslib.metrics.localization_metric import build_snpro_prediction_json
|
|
497
|
+
model = self._prepare_streaming_model(weights)
|
|
498
|
+
fps = float(get_data_sampling(self.config).get('extract_fps', 25))
|
|
499
|
+
sources = [(Path(video_path).stem, Path(video_path), {'start_time_ms':0,'end_time_ms':None,'output_path':str(video_path)})] if video_path else manifest_sources(
|
|
500
|
+
self.config, self._resolve_split_path('test', test_set))
|
|
501
|
+
predictions = []
|
|
502
|
+
for identity, path, segment in sources:
|
|
503
|
+
from opensportslib.datasets.video_raw import effective_fps
|
|
504
|
+
rate = effective_fps(path, fps)
|
|
505
|
+
observations = model.preprocessor.iter_video(path, self.config,
|
|
506
|
+
start_time_ms=segment['start_time_ms'], end_time_ms=segment['end_time_ms'])
|
|
507
|
+
events = []
|
|
508
|
+
for batch in spotting_events(model, self.config, observations, fps=rate,
|
|
509
|
+
offset_seconds=segment['start_time_ms']/1000):
|
|
510
|
+
events.extend(batch)
|
|
511
|
+
predictions.append({'video': segment['output_path'], 'fps': rate, 'events': events})
|
|
512
|
+
return build_snpro_prediction_json(predictions, split='test')
|
|
513
|
+
|
|
442
514
|
@config_operation
|
|
443
515
|
def infer(
|
|
444
516
|
self,
|
|
@@ -510,6 +582,9 @@ class LocalizationModel(BaseTaskModel):
|
|
|
510
582
|
return self.wait_for_remote_result(job["job_id"])["result"]["predictions"]
|
|
511
583
|
if remote_mode_provided:
|
|
512
584
|
raise ValueError("`remote_mode` is available only when `remote` is configured.")
|
|
585
|
+
from opensportslib.preprocessing.config import requires_raw_video
|
|
586
|
+
if requires_raw_video(self.config):
|
|
587
|
+
return self._infer_streaming(video_path, test_set, weights)
|
|
513
588
|
if video_path is not None:
|
|
514
589
|
from opensportslib.core.utils.direct_video import direct_video_manifest
|
|
515
590
|
from opensportslib.core.utils.config import resolve_config_omega
|
|
@@ -522,6 +597,11 @@ class LocalizationModel(BaseTaskModel):
|
|
|
522
597
|
weights=weights,
|
|
523
598
|
use_wandb=use_wandb,
|
|
524
599
|
)
|
|
600
|
+
if str(get_model_family(self.config)).lower() == "tdeed":
|
|
601
|
+
from opensportslib.core.trainer.tdeed_trainer import infer
|
|
602
|
+
if kwargs:
|
|
603
|
+
raise TypeError(f"Unsupported T-DEED inference options: {', '.join(kwargs)}")
|
|
604
|
+
return infer(self, test_set, weights)
|
|
525
605
|
from opensportslib.datasets.builder import build_dataset
|
|
526
606
|
from opensportslib.models.builder import build_model
|
|
527
607
|
from opensportslib.core.trainer.localization_trainer import build_inferer
|
|
@@ -603,6 +683,11 @@ class LocalizationModel(BaseTaskModel):
|
|
|
603
683
|
use_wandb=True,
|
|
604
684
|
**kwargs,
|
|
605
685
|
):
|
|
686
|
+
if str(get_model_family(self.config)).lower() == "tdeed":
|
|
687
|
+
from opensportslib.core.trainer.tdeed_trainer import evaluate
|
|
688
|
+
if kwargs:
|
|
689
|
+
raise TypeError(f"Unsupported T-DEED evaluation options: {', '.join(kwargs)}")
|
|
690
|
+
return evaluate(self, test_set, weights, predictions)
|
|
606
691
|
from opensportslib.core.trainer.localization_trainer import build_evaluator
|
|
607
692
|
from opensportslib.core.utils.config import resolve_config_omega
|
|
608
693
|
from opensportslib.core.utils.load_annotations import (
|
|
@@ -614,6 +699,14 @@ class LocalizationModel(BaseTaskModel):
|
|
|
614
699
|
|
|
615
700
|
del kwargs
|
|
616
701
|
|
|
702
|
+
from opensportslib.preprocessing.config import requires_raw_video
|
|
703
|
+
if requires_raw_video(self.config):
|
|
704
|
+
from opensportslib.apis._streaming import evaluate_spotting
|
|
705
|
+
test_set = self._resolve_split_path("test", test_set)
|
|
706
|
+
if predictions is None:
|
|
707
|
+
predictions = self.infer(test_set=test_set, weights=weights, use_wandb=use_wandb)
|
|
708
|
+
return evaluate_spotting(self.config, test_set, predictions)
|
|
709
|
+
|
|
617
710
|
test_set = self._resolve_split_path("test", test_set)
|
|
618
711
|
self._set_split_path("test", test_set)
|
|
619
712
|
self.config = self._effective_config(resolve_config_omega(self.config, weights=weights))
|
|
@@ -645,7 +738,9 @@ class LocalizationModel(BaseTaskModel):
|
|
|
645
738
|
logging.info("Ground truth labels detected -> running evaluation")
|
|
646
739
|
evaluator = build_evaluator(cfg=self.config)
|
|
647
740
|
eval_input = (
|
|
648
|
-
|
|
741
|
+
predictions if (str(get_model_family(self.config)).lower() == "learnablepooling"
|
|
742
|
+
or getattr(get_split_cfg(self.config, "test"), "metric", None) == "precise")
|
|
743
|
+
else getattr(get_split_cfg(self.config, "test"), "results")
|
|
649
744
|
if isinstance(predictions, dict)
|
|
650
745
|
else predictions
|
|
651
746
|
)
|
opensportslib/cli.py
CHANGED
|
@@ -9,6 +9,7 @@ from opensportslib.setup.setup import setup
|
|
|
9
9
|
def main(argv: Optional[list[str]] = None) -> int:
|
|
10
10
|
parser = argparse.ArgumentParser(prog="opensportslib")
|
|
11
11
|
parser.add_argument("command", choices=["setup"])
|
|
12
|
+
parser.add_argument("--pose", action="store_true")
|
|
12
13
|
parser.add_argument("--pyg", action="store_true")
|
|
13
14
|
parser.add_argument("--pyg_extensions", action="store_true")
|
|
14
15
|
parser.add_argument("--dali", action="store_true")
|
|
@@ -26,6 +27,8 @@ def main(argv: Optional[list[str]] = None) -> int:
|
|
|
26
27
|
)
|
|
27
28
|
# Preserve the established setup() call contract unless the new,
|
|
28
29
|
# opt-in extension install was explicitly requested.
|
|
30
|
+
if args.pose:
|
|
31
|
+
setup_kwargs["pose"] = True
|
|
29
32
|
if args.pyg_extensions:
|
|
30
33
|
setup_kwargs["pyg_extensions"] = True
|
|
31
34
|
setup(**setup_kwargs)
|