opensportslib 0.3.3.dev3__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 +51 -1
- opensportslib/apis/classification.py +45 -35
- opensportslib/apis/localization.py +113 -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/loader.py +5 -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 +87 -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 +71 -13
- opensportslib/datasets/classification_dataset.py +43 -8
- opensportslib/datasets/hf_json.py +7 -4
- opensportslib/datasets/hf_tracking.py +77 -11
- opensportslib/datasets/localization_dataset.py +139 -12
- opensportslib/datasets/tdeed.py +284 -0
- opensportslib/datasets/utils/tracking.py +61 -10
- 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/tools/hf_transfer.py +45 -18
- opensportslib/tools/osl_json_to_parquet.py +45 -60
- opensportslib/tools/parquet_to_osl_json.py +22 -13
- opensportslib/tracking/__init__.py +5 -0
- opensportslib/tracking/native.py +252 -0
- opensportslib/tracking/tracab.py +391 -0
- opensportslib-0.3.4.dev2.dist-info/METADATA +176 -0
- opensportslib-0.3.4.dev2.dist-info/RECORD +490 -0
- {opensportslib-0.3.3.dev3.dist-info → opensportslib-0.3.4.dev2.dist-info}/WHEEL +1 -1
- scripts/run_h5_header_rule_inference.py +1 -1
- tests/helpers/tracab.py +47 -0
- 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_remote_sessions.py +23 -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 +37 -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_hf_json_tracking_spotting.py +24 -11
- tests/unit/data/test_hf_tracking_dataset.py +71 -4
- tests/unit/data/test_localization_intervals.py +64 -0
- tests/unit/data/test_tracking_tracab.py +258 -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 +199 -0
- tests/unit/tools/test_experiment_queue.py +1131 -0
- tests/unit/tools/test_experiment_release.py +585 -0
- tests/unit/tools/test_hf_transfer.py +164 -1
- 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.3.dev3.dist-info/METADATA +0 -332
- opensportslib-0.3.3.dev3.dist-info/RECORD +0 -241
- {opensportslib-0.3.3.dev3.dist-info → opensportslib-0.3.4.dev2.dist-info}/entry_points.txt +0 -0
- {opensportslib-0.3.3.dev3.dist-info → opensportslib-0.3.4.dev2.dist-info}/licenses/LICENSE +0 -0
- {opensportslib-0.3.3.dev3.dist-info → opensportslib-0.3.4.dev2.dist-info}/licenses/LICENSE-COMMERCIAL +0 -0
- {opensportslib-0.3.3.dev3.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)}
|
|
@@ -48,7 +48,7 @@ def _manifest_media_references(payload: dict[str, Any]):
|
|
|
48
48
|
for input_obj in inputs:
|
|
49
49
|
if not isinstance(input_obj, dict):
|
|
50
50
|
continue
|
|
51
|
-
for key in ("path", "ball_path"):
|
|
51
|
+
for key in ("path", "ball_path", "metadata_path", "tf05_path", "tf08_path"):
|
|
52
52
|
if isinstance(input_obj.get(key), str):
|
|
53
53
|
yield input_obj[key], lambda value, input_obj=input_obj, key=key: input_obj.__setitem__(key, value)
|
|
54
54
|
values = input_obj.get("paths")
|
|
@@ -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,
|
|
@@ -23,6 +23,7 @@ def _is_tracking_graph_modality(modality):
|
|
|
23
23
|
return str(modality).lower() in {
|
|
24
24
|
"tracking",
|
|
25
25
|
"tracking_parquet",
|
|
26
|
+
"tracking_tracab",
|
|
26
27
|
"tracking_h5",
|
|
27
28
|
"player_centroids_h5",
|
|
28
29
|
"player_joints_h5",
|
|
@@ -49,6 +50,13 @@ class ClassificationModel(BaseTaskModel):
|
|
|
49
50
|
if override is not None:
|
|
50
51
|
return expand(override)
|
|
51
52
|
|
|
53
|
+
from opensportslib.datasets.hf_json import hf_json_source, prepare_hf_json_split
|
|
54
|
+
if not self.is_remote and hf_json_source(self.config):
|
|
55
|
+
from opensportslib.core.config.accessors import set_split_source_path
|
|
56
|
+
prepared = prepare_hf_json_split(self.config, split)
|
|
57
|
+
set_split_source_path(self.config, split, str(prepared.source_path))
|
|
58
|
+
return str(prepared.annotation_path)
|
|
59
|
+
|
|
52
60
|
path = get_split_annotation_path(self.config, split)
|
|
53
61
|
if path:
|
|
54
62
|
return expand(path)
|
|
@@ -156,10 +164,7 @@ class ClassificationModel(BaseTaskModel):
|
|
|
156
164
|
world_size=world_size,
|
|
157
165
|
)
|
|
158
166
|
if rank == 0 and return_queue is not None:
|
|
159
|
-
|
|
160
|
-
return_queue.put(getattr(trainer, "predictions_path", None))
|
|
161
|
-
else:
|
|
162
|
-
return_queue.put(getattr(trainer, "predictions_payload", None))
|
|
167
|
+
return_queue.put(getattr(trainer, "predictions_payload", None))
|
|
163
168
|
finally:
|
|
164
169
|
if rank == 0 and use_wandb and getattr(wandb, "run", None) is not None:
|
|
165
170
|
try:
|
|
@@ -371,39 +376,44 @@ class ClassificationModel(BaseTaskModel):
|
|
|
371
376
|
use_ddp = use_ddp and world_size > 1
|
|
372
377
|
|
|
373
378
|
ctx = mp.get_context("spawn")
|
|
374
|
-
|
|
379
|
+
manager = ctx.Manager() if use_ddp else None
|
|
380
|
+
queue = manager.Queue() if manager is not None else ctx.Queue()
|
|
375
381
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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
|
+
)
|
|
405
412
|
|
|
406
|
-
|
|
413
|
+
predictions = queue.get()
|
|
414
|
+
finally:
|
|
415
|
+
if manager is not None:
|
|
416
|
+
manager.shutdown()
|
|
407
417
|
if use_ddp and isinstance(predictions, str):
|
|
408
418
|
with open(predictions, encoding="utf-8") as f:
|
|
409
419
|
predictions = json.load(f)
|
|
@@ -59,6 +59,15 @@ class LocalizationModel(BaseTaskModel):
|
|
|
59
59
|
set_split_source_path(self.config, "valid_data_frames", str(prepared.source_path))
|
|
60
60
|
return str(prepared.annotation_path)
|
|
61
61
|
|
|
62
|
+
from opensportslib.datasets.hf_tracking import hf_tracking_source, prepare_hf_tracking_split, stage_tracking_files
|
|
63
|
+
if hf_tracking_source(self.config):
|
|
64
|
+
prepared = prepare_hf_tracking_split(self.config, split)
|
|
65
|
+
root = stage_tracking_files(prepared)
|
|
66
|
+
set_split_source_path(self.config, split, str(root))
|
|
67
|
+
if split == "valid":
|
|
68
|
+
set_split_source_path(self.config, "valid_data_frames", str(root))
|
|
69
|
+
return str(prepared.annotations_path)
|
|
70
|
+
|
|
62
71
|
path = get_split_annotation_path(self.config, split)
|
|
63
72
|
if path:
|
|
64
73
|
return expand(path)
|
|
@@ -217,6 +226,13 @@ class LocalizationModel(BaseTaskModel):
|
|
|
217
226
|
weights: str | None = None,
|
|
218
227
|
**kwargs,
|
|
219
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
|
|
220
236
|
from opensportslib.models.builder import build_model
|
|
221
237
|
from opensportslib.core.utils.config import is_local_path, select_device
|
|
222
238
|
from opensportslib.core.utils.checkpoint import (
|
|
@@ -310,6 +326,11 @@ class LocalizationModel(BaseTaskModel):
|
|
|
310
326
|
use_wandb=True,
|
|
311
327
|
**kwargs,
|
|
312
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)
|
|
313
334
|
from opensportslib.datasets.builder import build_dataset
|
|
314
335
|
from opensportslib.models.builder import build_model
|
|
315
336
|
from opensportslib.core.trainer.localization_trainer import build_trainer
|
|
@@ -414,15 +435,14 @@ class LocalizationModel(BaseTaskModel):
|
|
|
414
435
|
|
|
415
436
|
logging.info("Start training")
|
|
416
437
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
get_train_trainer_type(self.config),
|
|
424
|
-
)
|
|
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),
|
|
425
444
|
)
|
|
445
|
+
self.trainer.train(**train_args)
|
|
426
446
|
|
|
427
447
|
self.best_checkpoint = self.trainer.best_checkpoint_path
|
|
428
448
|
self.last_loaded_weights = self.best_checkpoint
|
|
@@ -430,6 +450,67 @@ class LocalizationModel(BaseTaskModel):
|
|
|
430
450
|
logging.info(f"Total Execution Time is {time.time()-start} seconds")
|
|
431
451
|
return self.best_checkpoint
|
|
432
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
|
+
|
|
433
514
|
@config_operation
|
|
434
515
|
def infer(
|
|
435
516
|
self,
|
|
@@ -501,6 +582,9 @@ class LocalizationModel(BaseTaskModel):
|
|
|
501
582
|
return self.wait_for_remote_result(job["job_id"])["result"]["predictions"]
|
|
502
583
|
if remote_mode_provided:
|
|
503
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)
|
|
504
588
|
if video_path is not None:
|
|
505
589
|
from opensportslib.core.utils.direct_video import direct_video_manifest
|
|
506
590
|
from opensportslib.core.utils.config import resolve_config_omega
|
|
@@ -513,6 +597,11 @@ class LocalizationModel(BaseTaskModel):
|
|
|
513
597
|
weights=weights,
|
|
514
598
|
use_wandb=use_wandb,
|
|
515
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)
|
|
516
605
|
from opensportslib.datasets.builder import build_dataset
|
|
517
606
|
from opensportslib.models.builder import build_model
|
|
518
607
|
from opensportslib.core.trainer.localization_trainer import build_inferer
|
|
@@ -594,6 +683,11 @@ class LocalizationModel(BaseTaskModel):
|
|
|
594
683
|
use_wandb=True,
|
|
595
684
|
**kwargs,
|
|
596
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)
|
|
597
691
|
from opensportslib.core.trainer.localization_trainer import build_evaluator
|
|
598
692
|
from opensportslib.core.utils.config import resolve_config_omega
|
|
599
693
|
from opensportslib.core.utils.load_annotations import (
|
|
@@ -605,6 +699,14 @@ class LocalizationModel(BaseTaskModel):
|
|
|
605
699
|
|
|
606
700
|
del kwargs
|
|
607
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
|
+
|
|
608
710
|
test_set = self._resolve_split_path("test", test_set)
|
|
609
711
|
self._set_split_path("test", test_set)
|
|
610
712
|
self.config = self._effective_config(resolve_config_omega(self.config, weights=weights))
|
|
@@ -636,7 +738,9 @@ class LocalizationModel(BaseTaskModel):
|
|
|
636
738
|
logging.info("Ground truth labels detected -> running evaluation")
|
|
637
739
|
evaluator = build_evaluator(cfg=self.config)
|
|
638
740
|
eval_input = (
|
|
639
|
-
|
|
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")
|
|
640
744
|
if isinstance(predictions, dict)
|
|
641
745
|
else predictions
|
|
642
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)
|