tactifoot-vision 0.3.0__tar.gz

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.
Files changed (80) hide show
  1. tactifoot_vision-0.3.0/.gitignore +30 -0
  2. tactifoot_vision-0.3.0/LICENSE +201 -0
  3. tactifoot_vision-0.3.0/PKG-INFO +112 -0
  4. tactifoot_vision-0.3.0/README.md +61 -0
  5. tactifoot_vision-0.3.0/pyproject.toml +114 -0
  6. tactifoot_vision-0.3.0/src/tactifoot_vision/__init__.py +124 -0
  7. tactifoot_vision-0.3.0/src/tactifoot_vision/__main__.py +5 -0
  8. tactifoot_vision-0.3.0/src/tactifoot_vision/analysis/__init__.py +24 -0
  9. tactifoot_vision-0.3.0/src/tactifoot_vision/analysis/carriers.py +250 -0
  10. tactifoot_vision-0.3.0/src/tactifoot_vision/analysis/direction.py +56 -0
  11. tactifoot_vision-0.3.0/src/tactifoot_vision/analysis/space.py +321 -0
  12. tactifoot_vision-0.3.0/src/tactifoot_vision/analysis/velocity.py +129 -0
  13. tactifoot_vision-0.3.0/src/tactifoot_vision/augment/__init__.py +45 -0
  14. tactifoot_vision-0.3.0/src/tactifoot_vision/augment/base.py +109 -0
  15. tactifoot_vision-0.3.0/src/tactifoot_vision/augment/dataset.py +145 -0
  16. tactifoot_vision-0.3.0/src/tactifoot_vision/augment/geometric.py +165 -0
  17. tactifoot_vision-0.3.0/src/tactifoot_vision/augment/photometric.py +151 -0
  18. tactifoot_vision-0.3.0/src/tactifoot_vision/cli.py +286 -0
  19. tactifoot_vision-0.3.0/src/tactifoot_vision/data/__init__.py +43 -0
  20. tactifoot_vision-0.3.0/src/tactifoot_vision/data/_files.py +209 -0
  21. tactifoot_vision-0.3.0/src/tactifoot_vision/data/annotations.py +113 -0
  22. tactifoot_vision-0.3.0/src/tactifoot_vision/data/coco.py +224 -0
  23. tactifoot_vision-0.3.0/src/tactifoot_vision/data/dataset.py +432 -0
  24. tactifoot_vision-0.3.0/src/tactifoot_vision/data/demo.py +323 -0
  25. tactifoot_vision-0.3.0/src/tactifoot_vision/data/labelled_clip.py +110 -0
  26. tactifoot_vision-0.3.0/src/tactifoot_vision/data/soccernet.py +402 -0
  27. tactifoot_vision-0.3.0/src/tactifoot_vision/data/statsbomb.py +102 -0
  28. tactifoot_vision-0.3.0/src/tactifoot_vision/data/synthetic.py +234 -0
  29. tactifoot_vision-0.3.0/src/tactifoot_vision/data/video.py +167 -0
  30. tactifoot_vision-0.3.0/src/tactifoot_vision/data/yolo.py +242 -0
  31. tactifoot_vision-0.3.0/src/tactifoot_vision/enums.py +212 -0
  32. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/__init__.py +75 -0
  33. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/detection.py +137 -0
  34. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/homography.py +416 -0
  35. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/hota.py +123 -0
  36. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/keypoints.py +111 -0
  37. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/metrics.py +199 -0
  38. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/statsbomb.py +204 -0
  39. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/teams.py +272 -0
  40. tactifoot_vision-0.3.0/src/tactifoot_vision/evaluation/tracking.py +338 -0
  41. tactifoot_vision-0.3.0/src/tactifoot_vision/models/__init__.py +30 -0
  42. tactifoot_vision-0.3.0/src/tactifoot_vision/models/base.py +301 -0
  43. tactifoot_vision-0.3.0/src/tactifoot_vision/models/rfdetr.py +432 -0
  44. tactifoot_vision-0.3.0/src/tactifoot_vision/models/ultralytics.py +550 -0
  45. tactifoot_vision-0.3.0/src/tactifoot_vision/pipeline/__init__.py +35 -0
  46. tactifoot_vision-0.3.0/src/tactifoot_vision/pipeline/ball.py +441 -0
  47. tactifoot_vision-0.3.0/src/tactifoot_vision/pipeline/homographies.py +160 -0
  48. tactifoot_vision-0.3.0/src/tactifoot_vision/pipeline/pipeline.py +546 -0
  49. tactifoot_vision-0.3.0/src/tactifoot_vision/pipeline/postprocess.py +166 -0
  50. tactifoot_vision-0.3.0/src/tactifoot_vision/pipeline/result.py +607 -0
  51. tactifoot_vision-0.3.0/src/tactifoot_vision/pipeline/roles.py +497 -0
  52. tactifoot_vision-0.3.0/src/tactifoot_vision/pipeline/tracks.py +192 -0
  53. tactifoot_vision-0.3.0/src/tactifoot_vision/pitch/__init__.py +24 -0
  54. tactifoot_vision-0.3.0/src/tactifoot_vision/pitch/homography.py +246 -0
  55. tactifoot_vision-0.3.0/src/tactifoot_vision/pitch/lines.py +393 -0
  56. tactifoot_vision-0.3.0/src/tactifoot_vision/pitch/pitch.py +143 -0
  57. tactifoot_vision-0.3.0/src/tactifoot_vision/pitch/projection.py +24 -0
  58. tactifoot_vision-0.3.0/src/tactifoot_vision/pitch/undistortion.py +62 -0
  59. tactifoot_vision-0.3.0/src/tactifoot_vision/py.typed +0 -0
  60. tactifoot_vision-0.3.0/src/tactifoot_vision/registry.py +53 -0
  61. tactifoot_vision-0.3.0/src/tactifoot_vision/run_file.py +531 -0
  62. tactifoot_vision-0.3.0/src/tactifoot_vision/run_files/default.yaml +59 -0
  63. tactifoot_vision-0.3.0/src/tactifoot_vision/run_files/rfdetr_sam2.yaml +54 -0
  64. tactifoot_vision-0.3.0/src/tactifoot_vision/teams/__init__.py +21 -0
  65. tactifoot_vision-0.3.0/src/tactifoot_vision/teams/classifier.py +172 -0
  66. tactifoot_vision-0.3.0/src/tactifoot_vision/teams/crops.py +51 -0
  67. tactifoot_vision-0.3.0/src/tactifoot_vision/teams/embedders.py +197 -0
  68. tactifoot_vision-0.3.0/src/tactifoot_vision/tracking/__init__.py +22 -0
  69. tactifoot_vision-0.3.0/src/tactifoot_vision/tracking/base.py +37 -0
  70. tactifoot_vision-0.3.0/src/tactifoot_vision/tracking/bytetrack.py +69 -0
  71. tactifoot_vision-0.3.0/src/tactifoot_vision/tracking/sam2.py +388 -0
  72. tactifoot_vision-0.3.0/src/tactifoot_vision/utils.py +78 -0
  73. tactifoot_vision-0.3.0/src/tactifoot_vision/viz/__init__.py +56 -0
  74. tactifoot_vision-0.3.0/src/tactifoot_vision/viz/annotate.py +440 -0
  75. tactifoot_vision-0.3.0/src/tactifoot_vision/viz/birds_eye.py +110 -0
  76. tactifoot_vision-0.3.0/src/tactifoot_vision/viz/plots.py +948 -0
  77. tactifoot_vision-0.3.0/src/tactifoot_vision/viz/radar.py +642 -0
  78. tactifoot_vision-0.3.0/src/tactifoot_vision/viz/subpixel.py +28 -0
  79. tactifoot_vision-0.3.0/src/tactifoot_vision/viz/trail.py +84 -0
  80. tactifoot_vision-0.3.0/src/tactifoot_vision/viz/video.py +284 -0
@@ -0,0 +1,30 @@
1
+ # .gitignore
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+ .env
7
+ .venv
8
+ venv/
9
+ env/
10
+ *.egg-info/
11
+ dist/
12
+ /build/
13
+ .pytest_cache/
14
+ .ruff_cache/
15
+ .ipynb_checkpoints/
16
+ *.log
17
+
18
+ # Data, weights and run artefacts (kept outside git; see notebooks/README.md "Local data and weights")
19
+ /data/
20
+ /models/
21
+ output/
22
+ outputs/
23
+ results/
24
+ external/
25
+ runs/
26
+ *.pt
27
+ *.pth
28
+ *.onnx
29
+ *.safetensors
30
+ *.mp4
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.5
2
+ Name: tactifoot-vision
3
+ Version: 0.3.0
4
+ Summary: Football video analysis: detection, tracking, team classification and pitch homography, from dataset preparation to tactical maps.
5
+ Project-URL: Homepage, https://github.com/RedHot099/TactiFootVision
6
+ Project-URL: Repository, https://github.com/RedHot099/TactiFootVision
7
+ Project-URL: Issues, https://github.com/RedHot099/TactiFootVision/issues
8
+ Project-URL: Changelog, https://github.com/RedHot099/TactiFootVision/releases
9
+ Author-email: Jakub Eichner <redhotdevil996@gmail.com>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: computer-vision,football,homography,object-detection,soccer,sports-analytics,tracking
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Multimedia :: Video
19
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
20
+ Requires-Python: >=3.13
21
+ Requires-Dist: huggingface-hub<2,>=0.36.2
22
+ Requires-Dist: matplotlib>=3.10
23
+ Requires-Dist: numpy<3,>=2.1
24
+ Requires-Dist: opencv-python>=5.0.0.93
25
+ Requires-Dist: pandas>=2.2.3
26
+ Requires-Dist: pillow>=11.3
27
+ Requires-Dist: pyarrow>=23.0.1
28
+ Requires-Dist: pydantic<3,>=2.14.1
29
+ Requires-Dist: pyyaml>=6.0.3
30
+ Requires-Dist: scikit-learn>=1.6.1
31
+ Requires-Dist: scipy>=1.16.3
32
+ Requires-Dist: supervision<0.26,>=0.25.1
33
+ Requires-Dist: torch<3,>=2.11
34
+ Requires-Dist: torchvision>=0.26
35
+ Requires-Dist: tqdm>=4.67.3
36
+ Requires-Dist: transformers<6,>=4.57.6
37
+ Requires-Dist: ultralytics<9,>=8.4.201
38
+ Requires-Dist: umap-learn>=0.5.12
39
+ Provides-Extra: all
40
+ Requires-Dist: numpy<2.4; extra == 'all'
41
+ Requires-Dist: rfdetr<1.4,>=1.3.0; extra == 'all'
42
+ Requires-Dist: transformers<5; extra == 'all'
43
+ Provides-Extra: rfdetr
44
+ Requires-Dist: numpy<2.4; extra == 'rfdetr'
45
+ Requires-Dist: rfdetr<1.4,>=1.3.0; extra == 'rfdetr'
46
+ Requires-Dist: transformers<5; extra == 'rfdetr'
47
+ Provides-Extra: sam2
48
+ Requires-Dist: hydra-core>=1.3.2; extra == 'sam2'
49
+ Requires-Dist: iopath>=0.1.10; extra == 'sam2'
50
+ Description-Content-Type: text/markdown
51
+
52
+ # TactiFoot Vision
53
+
54
+ ![TactiFoot Vision on one attacking move](https://raw.githubusercontent.com/RedHot099/TactiFootVision/master/docs/media/tactifoot_promo.avif)
55
+
56
+ TactiFoot Vision turns football match video into tactical data. It finds and follows every player and the ball, works out who plays for which team, and maps the action onto the pitch in metres.
57
+
58
+ - **Data:** load, convert, split and augment annotated football datasets.
59
+ - **Models:** train and evaluate YOLO, RF-DETR and pitch-keypoint models through one interface.
60
+ - **Pipeline:** detection, tracking, team classification and homography to pitch coordinates.
61
+ - **Output:** tracks, StatsBomb-style freeze frames, annotated video and a tactical radar.
62
+
63
+ ## Quick start
64
+
65
+ To see the whole workflow without installing anything, open the overview
66
+ notebook in Google Colab. It downloads an open demo match, trains a player
67
+ detector for a few minutes, tracks the players and draws the tactical map:
68
+
69
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/RedHot099/TactiFootVision/blob/v0.3.0/notebooks/00_overview.ipynb)
70
+
71
+ To use the package on your own footage, install it from PyPI (Python 3.13):
72
+
73
+ ```bash
74
+ pip install tactifoot-vision
75
+ ```
76
+
77
+ ```python
78
+ import tactifoot_vision as tv
79
+
80
+ pipeline = tv.Pipeline(
81
+ detector=tv.load_model("yolo", "models/detector_yolo11l.pt"),
82
+ keypoint_model=tv.load_model("yolo_pose", "models/pitch_yolo11m_pose.pt"),
83
+ team_classifier=tv.teams.TeamClassifier("siglip"),
84
+ )
85
+ result = pipeline.run("match.mp4")
86
+ tv.viz.render_video(result, "match.mp4", "annotated.mp4")
87
+ ```
88
+
89
+ The same pipeline runs from the command line:
90
+
91
+ ```bash
92
+ tactifoot init pipeline.yaml # a commented run file to edit
93
+ tactifoot run pipeline.yaml --video match.mp4 --output-dir outputs/match
94
+ ```
95
+
96
+ ## Contributing
97
+
98
+ ```bash
99
+ git clone https://github.com/RedHot099/TactiFootVision.git && cd TactiFootVision
100
+ uv sync # the package, its dev tools and the notebook kernel
101
+ uv run pytest -q # the fast suite
102
+ ```
103
+
104
+ The notebooks are generated from `notebooks/build/`. All but the overview
105
+ notebook, and the examples, expect local data and weights; see the
106
+ [notebooks README](https://github.com/RedHot099/TactiFootVision/blob/master/notebooks/README.md).
107
+
108
+ ## Learn more
109
+
110
+ - **[Notebooks](https://github.com/RedHot099/TactiFootVision/blob/master/notebooks/README.md):** executed walkthroughs of every module, from data to visualisation. Start with `00_overview`, which also runs in Colab.
111
+ - **[Architecture](https://github.com/RedHot099/TactiFootVision/blob/master/docs/ARCHITECTURE.md):** modules, interfaces, run files and the CLI.
112
+ - **[Examples](https://github.com/RedHot099/TactiFootVision/tree/master/examples):** runnable scripts for each area and the CLI.
@@ -0,0 +1,61 @@
1
+ # TactiFoot Vision
2
+
3
+ ![TactiFoot Vision on one attacking move](https://raw.githubusercontent.com/RedHot099/TactiFootVision/master/docs/media/tactifoot_promo.avif)
4
+
5
+ TactiFoot Vision turns football match video into tactical data. It finds and follows every player and the ball, works out who plays for which team, and maps the action onto the pitch in metres.
6
+
7
+ - **Data:** load, convert, split and augment annotated football datasets.
8
+ - **Models:** train and evaluate YOLO, RF-DETR and pitch-keypoint models through one interface.
9
+ - **Pipeline:** detection, tracking, team classification and homography to pitch coordinates.
10
+ - **Output:** tracks, StatsBomb-style freeze frames, annotated video and a tactical radar.
11
+
12
+ ## Quick start
13
+
14
+ To see the whole workflow without installing anything, open the overview
15
+ notebook in Google Colab. It downloads an open demo match, trains a player
16
+ detector for a few minutes, tracks the players and draws the tactical map:
17
+
18
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/RedHot099/TactiFootVision/blob/v0.3.0/notebooks/00_overview.ipynb)
19
+
20
+ To use the package on your own footage, install it from PyPI (Python 3.13):
21
+
22
+ ```bash
23
+ pip install tactifoot-vision
24
+ ```
25
+
26
+ ```python
27
+ import tactifoot_vision as tv
28
+
29
+ pipeline = tv.Pipeline(
30
+ detector=tv.load_model("yolo", "models/detector_yolo11l.pt"),
31
+ keypoint_model=tv.load_model("yolo_pose", "models/pitch_yolo11m_pose.pt"),
32
+ team_classifier=tv.teams.TeamClassifier("siglip"),
33
+ )
34
+ result = pipeline.run("match.mp4")
35
+ tv.viz.render_video(result, "match.mp4", "annotated.mp4")
36
+ ```
37
+
38
+ The same pipeline runs from the command line:
39
+
40
+ ```bash
41
+ tactifoot init pipeline.yaml # a commented run file to edit
42
+ tactifoot run pipeline.yaml --video match.mp4 --output-dir outputs/match
43
+ ```
44
+
45
+ ## Contributing
46
+
47
+ ```bash
48
+ git clone https://github.com/RedHot099/TactiFootVision.git && cd TactiFootVision
49
+ uv sync # the package, its dev tools and the notebook kernel
50
+ uv run pytest -q # the fast suite
51
+ ```
52
+
53
+ The notebooks are generated from `notebooks/build/`. All but the overview
54
+ notebook, and the examples, expect local data and weights; see the
55
+ [notebooks README](https://github.com/RedHot099/TactiFootVision/blob/master/notebooks/README.md).
56
+
57
+ ## Learn more
58
+
59
+ - **[Notebooks](https://github.com/RedHot099/TactiFootVision/blob/master/notebooks/README.md):** executed walkthroughs of every module, from data to visualisation. Start with `00_overview`, which also runs in Colab.
60
+ - **[Architecture](https://github.com/RedHot099/TactiFootVision/blob/master/docs/ARCHITECTURE.md):** modules, interfaces, run files and the CLI.
61
+ - **[Examples](https://github.com/RedHot099/TactiFootVision/tree/master/examples):** runnable scripts for each area and the CLI.
@@ -0,0 +1,114 @@
1
+ [project]
2
+ name = "tactifoot-vision"
3
+ dynamic = ["version"] # from the git tag vX.Y.Z (hatch-vcs); untagged: a dev version
4
+ description = "Football video analysis: detection, tracking, team classification and pitch homography, from dataset preparation to tactical maps."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ requires-python = ">=3.13"
8
+ authors = [
9
+ { name = "Jakub Eichner", email = "redhotdevil996@gmail.com" }
10
+ ]
11
+ keywords = ["football", "soccer", "computer-vision", "object-detection", "tracking", "homography", "sports-analytics"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Science/Research",
15
+ "License :: OSI Approved :: Apache Software License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Topic :: Scientific/Engineering :: Image Recognition",
19
+ "Topic :: Multimedia :: Video",
20
+ ]
21
+ # The core runs the default preset: YOLO detection and pitch keypoints,
22
+ # ByteTrack, SigLIP teams (transformers, umap-learn), the roles post-process
23
+ # (scikit-learn).
24
+ # Lower bounds are the lowest versions a run has verified (the lock, or the
25
+ # default Google Colab runtime in tests/colab-constraints.txt); upper bounds
26
+ # only at the next major of the libraries with a history of breaking changes.
27
+ # The ranges must resolve on Colab without downgrading anything it ships
28
+ # (checked by the colab smoke job in CI).
29
+ dependencies = [
30
+ "huggingface-hub>=0.36.2,<2", # download_demo; Colab ships 1.x
31
+ "numpy>=2.1,<3", # 2.1 verified by the previous lock; the rfdetr extra caps it below 2.4
32
+ "ultralytics>=8.4.201,<9",
33
+ "pydantic>=2.14.1,<3",
34
+ "pyyaml>=6.0.3",
35
+ "supervision>=0.25.1,<0.26", # 0.26 removed sv.ByteTrack (moved to the trackers library)
36
+ "opencv-python>=5.0.0.93", # what ultralytics and supervision pull too
37
+ "torch>=2.11,<3",
38
+ "torchvision>=0.26",
39
+ "tqdm>=4.67.3",
40
+ "pyarrow>=23.0.1", # pandas parquet engine (PipelineResult.to_parquet)
41
+ "scipy>=1.16.3",
42
+ "transformers>=4.57.6,<6",
43
+ "umap-learn>=0.5.12",
44
+ "scikit-learn>=1.6.1",
45
+ "pandas>=2.2.3",
46
+ "pillow>=11.3",
47
+ "matplotlib>=3.10",
48
+ ]
49
+
50
+ # Optional backends; a missing one says which extra to install (utils.require_extra).
51
+ [project.optional-dependencies]
52
+ # RF-DETR detector. 1.4+ pins supervision>=0.29 and transformers>=5 and changes
53
+ # the internals this backend uses; upgrading is its own ticket.
54
+ # 1.3 imports transformers 4 internals and, in its COCO metrics, converts a
55
+ # 1-element array to a scalar, an error since numpy 2.4 (Colab ships 2.4, so
56
+ # this extra downgrades numpy there; the rfdetr upgrade is backlog ticket 06).
57
+ rfdetr = ["rfdetr>=1.3.0,<1.4", "transformers<5", "numpy<2.4"]
58
+ # The SAM2 tracker also needs https://github.com/Gy920/segment-anything-2-real-time
59
+ # cloned to external/ (it is not pip-installable).
60
+ sam2 = ["hydra-core>=1.3.2", "iopath>=0.1.10"]
61
+ all = ["tactifoot-vision[rfdetr]"]
62
+
63
+ [project.urls]
64
+ Homepage = "https://github.com/RedHot099/TactiFootVision"
65
+ Repository = "https://github.com/RedHot099/TactiFootVision"
66
+ Issues = "https://github.com/RedHot099/TactiFootVision/issues"
67
+ Changelog = "https://github.com/RedHot099/TactiFootVision/releases"
68
+
69
+ [project.scripts]
70
+ tactifoot = "tactifoot_vision.cli:main"
71
+
72
+ [dependency-groups]
73
+ # The dev environment has every optional backend, so `uv run pytest -m model`
74
+ # covers them; the Colab smoke checks the core on its own.
75
+ dev = [
76
+ "tactifoot-vision[rfdetr,sam2]",
77
+ "hatchling>=1.24.0",
78
+ "hatch-vcs>=0.4.0",
79
+ "ipykernel>=6.29.5,<7.0.0",
80
+ "nbclient>=0.10.0",
81
+ "nbformat>=5.10.0",
82
+ "pytest>=8.3.0",
83
+ "ruff>=0.11.2,<0.12.0",
84
+ ]
85
+
86
+ [tool.uv.sources]
87
+ tactifoot-vision = { workspace = true }
88
+
89
+ [build-system]
90
+ requires = ["hatchling>=1.24.0", "hatch-vcs>=0.4.0"]
91
+ build-backend = "hatchling.build"
92
+
93
+ [tool.hatch.version]
94
+ source = "vcs"
95
+
96
+ [tool.hatch.build.targets.sdist]
97
+ only-include = ["src/tactifoot_vision", "README.md", "LICENSE", "pyproject.toml"]
98
+
99
+ [tool.hatch.build.targets.wheel]
100
+ packages = ["src/tactifoot_vision"]
101
+
102
+ [tool.pytest.ini_options]
103
+ testpaths = ["tests"]
104
+ addopts = "-m 'not model'"
105
+ markers = [
106
+ "model: needs real model weights and/or a GPU (run with -m model)",
107
+ ]
108
+
109
+ [tool.ruff]
110
+ src = ["src", "tests"]
111
+
112
+ [tool.ruff.lint]
113
+ select = ["E", "F", "I", "UP", "B"]
114
+ ignore = ["E501"]
@@ -0,0 +1,124 @@
1
+ """TactiFoot Vision: football video analysis from dataset to tactical map.
2
+
3
+ import tactifoot_vision as tv
4
+
5
+ ds = tv.load_dataset("data/datasets/football_yolo/data.yaml") # data preparation
6
+ aug = tv.augment.Compose([tv.augment.HorizontalFlip(), ...]) # augmentation
7
+ run = tv.train("yolo", ds, weights="yolo11n.pt", epochs=10) # training
8
+ result = tv.Pipeline(detector=run.load()).run("match.mp4") # inference
9
+ tv.viz.render_video(result, "match.mp4", "annotated.mp4") # visualisation
10
+
11
+ Submodules are imported lazily, so ``import tactifoot_vision`` stays fast and
12
+ heavy dependencies (torch, ultralytics, rfdetr, transformers) load on first use.
13
+ """
14
+
15
+ import importlib
16
+ from importlib.metadata import PackageNotFoundError, version
17
+ from typing import TYPE_CHECKING, Any
18
+
19
+ try:
20
+ __version__ = version("tactifoot-vision")
21
+ except PackageNotFoundError: # running from a source tree without installation
22
+ __version__ = "0.0.0"
23
+
24
+ _SUBMODULES = (
25
+ "analysis",
26
+ "augment",
27
+ "data",
28
+ "enums",
29
+ "evaluation",
30
+ "models",
31
+ "pipeline",
32
+ "pitch",
33
+ "run_file",
34
+ "teams",
35
+ "tracking",
36
+ "utils",
37
+ "viz",
38
+ )
39
+
40
+ # Shortcuts for the most common entry points: name -> (module, attribute).
41
+ _EXPORTS: dict[str, tuple[str, str]] = {
42
+ "Dataset": ("data", "Dataset"),
43
+ "load_dataset": ("data", "load_dataset"),
44
+ "VideoReader": ("data", "VideoReader"),
45
+ "load_model": ("models", "load_model"),
46
+ "train": ("models", "train"),
47
+ "TrainConfig": ("models", "TrainConfig"),
48
+ "evaluate": ("evaluation", "evaluate"),
49
+ "Pipeline": ("pipeline", "Pipeline"),
50
+ "PipelineResult": ("pipeline", "PipelineResult"),
51
+ "SoccerPitch": ("pitch", "SoccerPitch"),
52
+ "show": ("viz", "show"),
53
+ "setup_logging": ("utils", "setup_logging"),
54
+ }
55
+
56
+ __all__ = [
57
+ "__version__",
58
+ "analysis",
59
+ "augment",
60
+ "data",
61
+ "enums",
62
+ "evaluation",
63
+ "models",
64
+ "pipeline",
65
+ "pitch",
66
+ "run_file",
67
+ "teams",
68
+ "tracking",
69
+ "utils",
70
+ "viz",
71
+ "Dataset",
72
+ "load_dataset",
73
+ "VideoReader",
74
+ "load_model",
75
+ "train",
76
+ "TrainConfig",
77
+ "evaluate",
78
+ "Pipeline",
79
+ "PipelineResult",
80
+ "SoccerPitch",
81
+ "show",
82
+ "setup_logging",
83
+ ]
84
+
85
+ if TYPE_CHECKING:
86
+ from tactifoot_vision import (
87
+ analysis,
88
+ augment,
89
+ data,
90
+ enums,
91
+ evaluation,
92
+ models,
93
+ pipeline,
94
+ pitch,
95
+ run_file,
96
+ teams,
97
+ tracking,
98
+ utils,
99
+ viz,
100
+ )
101
+ from tactifoot_vision.data import Dataset, VideoReader, load_dataset
102
+ from tactifoot_vision.evaluation import evaluate
103
+ from tactifoot_vision.models import TrainConfig, load_model, train
104
+ from tactifoot_vision.pipeline import Pipeline, PipelineResult
105
+ from tactifoot_vision.pitch import SoccerPitch
106
+ from tactifoot_vision.utils import setup_logging
107
+ from tactifoot_vision.viz import show
108
+ else:
109
+
110
+ def __getattr__(name: str) -> Any:
111
+ if name in _SUBMODULES:
112
+ module = importlib.import_module(f"{__name__}.{name}")
113
+ elif name in _EXPORTS:
114
+ module_name, attribute = _EXPORTS[name]
115
+ module = getattr(
116
+ importlib.import_module(f"{__name__}.{module_name}"), attribute
117
+ )
118
+ else:
119
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
120
+ globals()[name] = module
121
+ return module
122
+
123
+ def __dir__() -> list[str]:
124
+ return sorted(set(globals()) | set(__all__))
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from tactifoot_vision.cli import main
4
+
5
+ sys.exit(main())
@@ -0,0 +1,24 @@
1
+ """Match analysis: pure functions over a :class:`~tactifoot_vision.pipeline.PipelineResult`."""
2
+
3
+ from tactifoot_vision.analysis.carriers import (
4
+ ball_carriers,
5
+ carrier_table,
6
+ pass_counts,
7
+ passes,
8
+ possession,
9
+ )
10
+ from tactifoot_vision.analysis.direction import attack_direction
11
+ from tactifoot_vision.analysis.space import SpaceControl, space_control
12
+ from tactifoot_vision.analysis.velocity import velocities
13
+
14
+ __all__ = [
15
+ "SpaceControl",
16
+ "attack_direction",
17
+ "ball_carriers",
18
+ "carrier_table",
19
+ "pass_counts",
20
+ "passes",
21
+ "possession",
22
+ "space_control",
23
+ "velocities",
24
+ ]