opensportslib 0.0.1.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/__init__.py +18 -0
- opensportslib/apis/__init__.py +21 -0
- opensportslib/apis/classification.py +361 -0
- opensportslib/apis/localization.py +228 -0
- opensportslib/config/classification.yaml +104 -0
- opensportslib/config/classification_tracking.yaml +103 -0
- opensportslib/config/graph_tracking_classification/avgpool.yaml +79 -0
- opensportslib/config/graph_tracking_classification/gin.yaml +79 -0
- opensportslib/config/graph_tracking_classification/graphconv.yaml +79 -0
- opensportslib/config/graph_tracking_classification/graphsage.yaml +79 -0
- opensportslib/config/graph_tracking_classification/maxpool.yaml +79 -0
- opensportslib/config/graph_tracking_classification/noedges.yaml +79 -0
- opensportslib/config/localization.yaml +132 -0
- opensportslib/config/sngar_frames.yaml +98 -0
- opensportslib/core/__init__.py +0 -0
- opensportslib/core/loss/__init__.py +0 -0
- opensportslib/core/loss/builder.py +40 -0
- opensportslib/core/loss/calf.py +258 -0
- opensportslib/core/loss/ce.py +23 -0
- opensportslib/core/loss/combine.py +42 -0
- opensportslib/core/loss/nll.py +25 -0
- opensportslib/core/optimizer/__init__.py +0 -0
- opensportslib/core/optimizer/builder.py +38 -0
- opensportslib/core/sampler/weighted_sampler.py +104 -0
- opensportslib/core/scheduler/__init__.py +0 -0
- opensportslib/core/scheduler/builder.py +77 -0
- opensportslib/core/trainer/__init__.py +0 -0
- opensportslib/core/trainer/classification_trainer.py +1131 -0
- opensportslib/core/trainer/localization_trainer.py +1009 -0
- opensportslib/core/utils/checkpoint.py +238 -0
- opensportslib/core/utils/config.py +199 -0
- opensportslib/core/utils/data.py +85 -0
- opensportslib/core/utils/ddp.py +77 -0
- opensportslib/core/utils/default_args.py +110 -0
- opensportslib/core/utils/load_annotations.py +485 -0
- opensportslib/core/utils/seed.py +26 -0
- opensportslib/core/utils/video_processing.py +389 -0
- opensportslib/core/utils/wandb.py +110 -0
- opensportslib/datasets/__init__.py +0 -0
- opensportslib/datasets/builder.py +42 -0
- opensportslib/datasets/classification_dataset.py +582 -0
- opensportslib/datasets/localization_dataset.py +813 -0
- opensportslib/datasets/utils/__init__.py +15 -0
- opensportslib/datasets/utils/tracking.py +615 -0
- opensportslib/metrics/classification_metric.py +176 -0
- opensportslib/metrics/localization_metric.py +1482 -0
- opensportslib/models/__init__.py +0 -0
- opensportslib/models/backbones/builder.py +590 -0
- opensportslib/models/base/e2e.py +252 -0
- opensportslib/models/base/tracking.py +73 -0
- opensportslib/models/base/vars.py +29 -0
- opensportslib/models/base/video.py +130 -0
- opensportslib/models/base/video_mae.py +60 -0
- opensportslib/models/builder.py +43 -0
- opensportslib/models/heads/builder.py +266 -0
- opensportslib/models/neck/builder.py +210 -0
- opensportslib/models/utils/common.py +176 -0
- opensportslib/models/utils/impl/__init__.py +0 -0
- opensportslib/models/utils/impl/asformer.py +390 -0
- opensportslib/models/utils/impl/calf.py +74 -0
- opensportslib/models/utils/impl/gsm.py +112 -0
- opensportslib/models/utils/impl/gtad.py +347 -0
- opensportslib/models/utils/impl/tsm.py +123 -0
- opensportslib/models/utils/litebase.py +59 -0
- opensportslib/models/utils/modules.py +120 -0
- opensportslib/models/utils/shift.py +135 -0
- opensportslib/models/utils/utils.py +276 -0
- opensportslib-0.0.1.dev2.dist-info/METADATA +566 -0
- opensportslib-0.0.1.dev2.dist-info/RECORD +73 -0
- opensportslib-0.0.1.dev2.dist-info/WHEEL +5 -0
- opensportslib-0.0.1.dev2.dist-info/licenses/LICENSE +661 -0
- opensportslib-0.0.1.dev2.dist-info/licenses/LICENSE-COMMERCIAL +5 -0
- opensportslib-0.0.1.dev2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opensportslib
|
|
3
|
+
Version: 0.0.1.dev2
|
|
4
|
+
Summary: OpenSportsLib is the professional library, designed for advanced video understanding in sports. It provides state-of-the-art tools for action recognition, spotting, retrieval, and captioning, making it ideal for researchers, analysts, and developers working with sports video data.
|
|
5
|
+
Author: Jeet Vora
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: LICENSE-COMMERCIAL
|
|
10
|
+
Requires-Dist: SoccerNet
|
|
11
|
+
Requires-Dist: av
|
|
12
|
+
Requires-Dist: decord; platform_system != "Darwin" and platform_machine != "arm64"
|
|
13
|
+
Requires-Dist: evaluate
|
|
14
|
+
Requires-Dist: scikit-learn
|
|
15
|
+
Requires-Dist: torch
|
|
16
|
+
Requires-Dist: torchvision
|
|
17
|
+
Requires-Dist: transformers==4.57.3
|
|
18
|
+
Requires-Dist: tokenizers==0.22.1
|
|
19
|
+
Requires-Dist: accelerate
|
|
20
|
+
Requires-Dist: wandb
|
|
21
|
+
Requires-Dist: opencv-python
|
|
22
|
+
Requires-Dist: omegaconf
|
|
23
|
+
Requires-Dist: timm
|
|
24
|
+
Provides-Extra: localization
|
|
25
|
+
Requires-Dist: nvidia-dali-cuda120; extra == "localization"
|
|
26
|
+
Requires-Dist: cupy-cuda12x; extra == "localization"
|
|
27
|
+
Requires-Dist: tabulate; extra == "localization"
|
|
28
|
+
Provides-Extra: tracking
|
|
29
|
+
Requires-Dist: torch-geometric; extra == "tracking"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# OpenSportsLib
|
|
33
|
+
OpenSportsLib is the professional library, designed for advanced video understanding in soccer. It provides state-of-the-art tools for action recognition, spotting, retrieval, and captioning, making it ideal for researchers, analysts, and developers working with soccer video data.
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
```bash
|
|
37
|
+
### Clone the github repo
|
|
38
|
+
git clone https://github.com/OpenSportsLab/opensportslib.git
|
|
39
|
+
|
|
40
|
+
### Requirements and installation ###
|
|
41
|
+
conda create -n osl python=3.12 pip
|
|
42
|
+
conda activate osl
|
|
43
|
+
pip install -e .
|
|
44
|
+
|
|
45
|
+
or
|
|
46
|
+
|
|
47
|
+
pip install -e .[localization]
|
|
48
|
+
or
|
|
49
|
+
pip install -e .[tracking]
|
|
50
|
+
|
|
51
|
+
### git branch and merge rules ###
|
|
52
|
+
1. Check and verify current branch is "dev" - git status
|
|
53
|
+
|
|
54
|
+
2. Create new branch from source "dev" -
|
|
55
|
+
git pull
|
|
56
|
+
git checkout -b <new_feature/fix/bug>
|
|
57
|
+
|
|
58
|
+
3. Raise PR request to merge your branch <new_feature/fix/bug> to "dev" branch
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
conda create -n osl python=3.12 pip
|
|
65
|
+
conda activate osl
|
|
66
|
+
pip install --pre opensportslib
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 🤝 Contributing & Developer Guide
|
|
70
|
+
|
|
71
|
+
We welcome contributions to OpenSportsLib.
|
|
72
|
+
|
|
73
|
+
- 📘 **Contributor Guide:** [CONTRIBUTING.md](opensportslib/docs/CONTRIBUTING.md)
|
|
74
|
+
- 🛠 **Developer Guide:** [DEVELOPERS.md](opensportslib/docs/DEVELOPERS.md)
|
|
75
|
+
|
|
76
|
+
These documents explain:
|
|
77
|
+
- How to add models and datasets
|
|
78
|
+
- Coding standards
|
|
79
|
+
- Training pipeline structure
|
|
80
|
+
- How to run and test the framework
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Configuration Sample (.yaml) file
|
|
84
|
+
1. Classification
|
|
85
|
+
```bash
|
|
86
|
+
TASK: classification
|
|
87
|
+
|
|
88
|
+
DATA:
|
|
89
|
+
dataset_name: mvfouls
|
|
90
|
+
data_dir: /home/vorajv/opensportslib/SoccerNet/mvfouls
|
|
91
|
+
data_modality: video
|
|
92
|
+
view_type: multi # multi or single
|
|
93
|
+
num_classes: 8 # mvfoul
|
|
94
|
+
train:
|
|
95
|
+
type: annotations_train.json
|
|
96
|
+
video_path: ${DATA.data_dir}/train
|
|
97
|
+
path: ${DATA.train.video_path}/annotations-train.json
|
|
98
|
+
dataloader:
|
|
99
|
+
batch_size: 8
|
|
100
|
+
shuffle: true
|
|
101
|
+
num_workers: 4
|
|
102
|
+
pin_memory: true
|
|
103
|
+
valid:
|
|
104
|
+
type: annotations_valid.json
|
|
105
|
+
video_path: ${DATA.data_dir}/valid
|
|
106
|
+
path: ${DATA.valid.video_path}/annotations-valid.json
|
|
107
|
+
dataloader:
|
|
108
|
+
batch_size: 1
|
|
109
|
+
num_workers: 1
|
|
110
|
+
shuffle: false
|
|
111
|
+
test:
|
|
112
|
+
type: annotations_test.json
|
|
113
|
+
video_path: ${DATA.data_dir}/test
|
|
114
|
+
path: ${DATA.test.video_path}/annotations-test.json
|
|
115
|
+
dataloader:
|
|
116
|
+
batch_size: 1
|
|
117
|
+
num_workers: 1
|
|
118
|
+
shuffle: false
|
|
119
|
+
num_frames: 16 # 8 before + 8 after the foul
|
|
120
|
+
input_fps: 25 # Original FPS of video
|
|
121
|
+
target_fps: 17 # Temporal downsampling to 1s clip (approx)
|
|
122
|
+
start_frame: 63 # Start frame of clip relative to foul frame
|
|
123
|
+
end_frame: 87 # End frame of clip relative to foul frame
|
|
124
|
+
frame_size: [224, 224] # Spatial resolution (HxW)
|
|
125
|
+
augmentations:
|
|
126
|
+
random_affine: true
|
|
127
|
+
translate: [0.1, 0.1]
|
|
128
|
+
affine_scale: [0.9, 1.0]
|
|
129
|
+
random_perspective: true
|
|
130
|
+
distortion_scale: 0.3
|
|
131
|
+
perspective_prob: 0.5
|
|
132
|
+
random_rotation: true
|
|
133
|
+
rotation_degrees: 5
|
|
134
|
+
color_jitter: true
|
|
135
|
+
jitter_params: [0.2, 0.2, 0.2, 0.1] # brightness, contrast, saturation, hue
|
|
136
|
+
random_horizontal_flip: true
|
|
137
|
+
flip_prob: 0.5
|
|
138
|
+
random_crop: false
|
|
139
|
+
|
|
140
|
+
MODEL:
|
|
141
|
+
type: custom # huggingface, custom
|
|
142
|
+
backbone:
|
|
143
|
+
type: mvit_v2_s # video_mae, r3d_18, mc3_18, r2plus1d_18, s3d, mvit_v2_s
|
|
144
|
+
neck:
|
|
145
|
+
type: MV_Aggregate
|
|
146
|
+
agr_type: max # max, mean, attention
|
|
147
|
+
head:
|
|
148
|
+
type: MV_LinearLayer
|
|
149
|
+
pretrained_model: mvit_v2_s # MCG-NJU/videomae-base, OpenGVLab/VideoMAEv2-Base, r3d_18, mc3_18, r2plus1d_18, s3d, mvit_v2_s
|
|
150
|
+
unfreeze_head: true # for videomae backbone
|
|
151
|
+
unfreeze_last_n_layers: 3 # for videomae backbone
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
TRAIN:
|
|
155
|
+
monitor: balanced_accuracy # balanced_accuracy, loss
|
|
156
|
+
mode: max # max or min
|
|
157
|
+
enabled: true
|
|
158
|
+
use_weighted_sampler: false
|
|
159
|
+
use_weighted_loss: true
|
|
160
|
+
epochs: 20 #20
|
|
161
|
+
save_dir: ./checkpoints
|
|
162
|
+
log_interval: 10
|
|
163
|
+
save_every: 2 #5
|
|
164
|
+
|
|
165
|
+
criterion:
|
|
166
|
+
type: CrossEntropyLoss
|
|
167
|
+
|
|
168
|
+
optimizer:
|
|
169
|
+
type: AdamW
|
|
170
|
+
lr: 0.0001 #0.001
|
|
171
|
+
backbone_lr: 0.00005
|
|
172
|
+
head_lr: 0.001
|
|
173
|
+
betas: [0.9, 0.999]
|
|
174
|
+
eps: 0.0000001
|
|
175
|
+
weight_decay: 0.001 #0.01 - videomae, 0.001 - others
|
|
176
|
+
amsgrad: false
|
|
177
|
+
|
|
178
|
+
scheduler:
|
|
179
|
+
type: StepLR
|
|
180
|
+
step_size: 3
|
|
181
|
+
gamma: 0.1
|
|
182
|
+
|
|
183
|
+
SYSTEM:
|
|
184
|
+
log_dir: ./logs
|
|
185
|
+
use_seed: false
|
|
186
|
+
seed: 42
|
|
187
|
+
GPU: 4
|
|
188
|
+
device: cuda # auto | cuda | cpu
|
|
189
|
+
gpu_id: 0
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
2. Classification (Tracking)
|
|
194
|
+
```bash
|
|
195
|
+
TASK: classification
|
|
196
|
+
|
|
197
|
+
DATA:
|
|
198
|
+
dataset_name: sngar
|
|
199
|
+
data_modality: tracking_parquet
|
|
200
|
+
data_dir: /home/karkid/opensportslib/sngar-tracking
|
|
201
|
+
preload_data: false
|
|
202
|
+
train:
|
|
203
|
+
type: annotations_train.json
|
|
204
|
+
video_path: ${DATA.data_dir}/train
|
|
205
|
+
path: ${DATA.train.video_path}/train.json
|
|
206
|
+
dataloader:
|
|
207
|
+
batch_size: 32
|
|
208
|
+
shuffle: true
|
|
209
|
+
num_workers: 8
|
|
210
|
+
pin_memory: true
|
|
211
|
+
valid:
|
|
212
|
+
type: annotations_valid.json
|
|
213
|
+
video_path: ${DATA.data_dir}/valid
|
|
214
|
+
path: ${DATA.valid.video_path}/valid.json
|
|
215
|
+
dataloader:
|
|
216
|
+
batch_size: 32
|
|
217
|
+
num_workers: 8
|
|
218
|
+
shuffle: false
|
|
219
|
+
test:
|
|
220
|
+
type: annotations_test.json
|
|
221
|
+
video_path: ${DATA.data_dir}/test
|
|
222
|
+
path: ${DATA.test.video_path}/test.json
|
|
223
|
+
dataloader:
|
|
224
|
+
batch_size: 32
|
|
225
|
+
num_workers: 8
|
|
226
|
+
shuffle: false
|
|
227
|
+
num_frames: 16
|
|
228
|
+
frame_interval: 9
|
|
229
|
+
augmentations:
|
|
230
|
+
vertical_flip: true
|
|
231
|
+
horizontal_flip: true
|
|
232
|
+
team_flip: true
|
|
233
|
+
normalize: true
|
|
234
|
+
num_objects: 23
|
|
235
|
+
feature_dim: 8
|
|
236
|
+
pitch_half_length: 85.0
|
|
237
|
+
pitch_half_width: 50.0
|
|
238
|
+
max_displacement: 110.0
|
|
239
|
+
max_ball_height: 30.0
|
|
240
|
+
|
|
241
|
+
MODEL:
|
|
242
|
+
type: custom
|
|
243
|
+
backbone:
|
|
244
|
+
type: graph_conv
|
|
245
|
+
encoder: graphconv
|
|
246
|
+
hidden_dim: 64
|
|
247
|
+
num_layers: 20
|
|
248
|
+
dropout: 0.1
|
|
249
|
+
neck:
|
|
250
|
+
type: TemporalAggregation
|
|
251
|
+
agr_type: maxpool
|
|
252
|
+
hidden_dim: 64
|
|
253
|
+
dropout: 0.1
|
|
254
|
+
head:
|
|
255
|
+
type: TrackingClassifier
|
|
256
|
+
hidden_dim: 64
|
|
257
|
+
dropout: 0.1
|
|
258
|
+
num_classes: 10
|
|
259
|
+
edge: positional
|
|
260
|
+
k: 8
|
|
261
|
+
r: 15.0
|
|
262
|
+
|
|
263
|
+
TRAIN:
|
|
264
|
+
monitor: loss # balanced_accuracy, loss
|
|
265
|
+
mode: min # max or min
|
|
266
|
+
enabled: true
|
|
267
|
+
use_weighted_sampler: true
|
|
268
|
+
use_weighted_loss: false
|
|
269
|
+
samples_per_class: 4000
|
|
270
|
+
epochs: 10
|
|
271
|
+
patience: 10
|
|
272
|
+
save_every: 20
|
|
273
|
+
detailed_results: true
|
|
274
|
+
|
|
275
|
+
optimizer:
|
|
276
|
+
type: Adam
|
|
277
|
+
lr: 0.001
|
|
278
|
+
|
|
279
|
+
scheduler:
|
|
280
|
+
type: ReduceLROnPlateau
|
|
281
|
+
mode: ${TRAIN.mode}
|
|
282
|
+
patience: 10
|
|
283
|
+
factor: 0.1
|
|
284
|
+
min_lr: 1e-8
|
|
285
|
+
|
|
286
|
+
criterion:
|
|
287
|
+
type: CrossEntropyLoss
|
|
288
|
+
|
|
289
|
+
save_dir: ./checkpoints_tracking
|
|
290
|
+
|
|
291
|
+
SYSTEM:
|
|
292
|
+
log_dir: ./logs
|
|
293
|
+
use_seed: true
|
|
294
|
+
seed: 42
|
|
295
|
+
GPU: 4
|
|
296
|
+
device: cuda # auto | cuda | cpu
|
|
297
|
+
gpu_id: 0
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
3. Localization
|
|
301
|
+
```bash
|
|
302
|
+
TASK: localization
|
|
303
|
+
|
|
304
|
+
dali: True
|
|
305
|
+
|
|
306
|
+
DATA:
|
|
307
|
+
dataset_name: SoccerNet
|
|
308
|
+
data_dir: /home/vorajv/opensportslib/SoccerNet/annotations/
|
|
309
|
+
classes:
|
|
310
|
+
- PASS
|
|
311
|
+
- DRIVE
|
|
312
|
+
- HEADER
|
|
313
|
+
- HIGH PASS
|
|
314
|
+
- OUT
|
|
315
|
+
- CROSS
|
|
316
|
+
- THROW IN
|
|
317
|
+
- SHOT
|
|
318
|
+
- BALL PLAYER BLOCK
|
|
319
|
+
- PLAYER SUCCESSFUL TACKLE
|
|
320
|
+
- FREE KICK
|
|
321
|
+
- GOAL
|
|
322
|
+
|
|
323
|
+
epoch_num_frames: 500000
|
|
324
|
+
mixup: true
|
|
325
|
+
modality: rgb
|
|
326
|
+
crop_dim: -1
|
|
327
|
+
dilate_len: 0 # Dilate ground truth labels
|
|
328
|
+
clip_len: 100
|
|
329
|
+
input_fps: 25
|
|
330
|
+
extract_fps: 2
|
|
331
|
+
imagenet_mean: [0.485, 0.456, 0.406]
|
|
332
|
+
imagenet_std: [0.229, 0.224, 0.225]
|
|
333
|
+
target_height: 224
|
|
334
|
+
target_width: 398
|
|
335
|
+
|
|
336
|
+
train:
|
|
337
|
+
type: VideoGameWithDali
|
|
338
|
+
classes: ${DATA.classes}
|
|
339
|
+
output_map: [data, label]
|
|
340
|
+
video_path: ${DATA.data_dir}/train/
|
|
341
|
+
path: ${DATA.train.video_path}/annotations-2024-224p-train.json
|
|
342
|
+
dataloader:
|
|
343
|
+
batch_size: 8
|
|
344
|
+
shuffle: true
|
|
345
|
+
num_workers: 4
|
|
346
|
+
pin_memory: true
|
|
347
|
+
|
|
348
|
+
valid:
|
|
349
|
+
type: VideoGameWithDali
|
|
350
|
+
classes: ${DATA.classes}
|
|
351
|
+
output_map: [data, label]
|
|
352
|
+
video_path: ${DATA.data_dir}/valid/
|
|
353
|
+
path: ${DATA.valid.video_path}/annotations-2024-224p-valid.json
|
|
354
|
+
dataloader:
|
|
355
|
+
batch_size: 8
|
|
356
|
+
shuffle: true
|
|
357
|
+
|
|
358
|
+
valid_data_frames:
|
|
359
|
+
type: VideoGameWithDaliVideo
|
|
360
|
+
classes: ${DATA.classes}
|
|
361
|
+
output_map: [data, label]
|
|
362
|
+
video_path: ${DATA.valid.video_path}
|
|
363
|
+
path: ${DATA.valid.path}
|
|
364
|
+
overlap_len: 0
|
|
365
|
+
dataloader:
|
|
366
|
+
batch_size: 4
|
|
367
|
+
shuffle: false
|
|
368
|
+
|
|
369
|
+
test:
|
|
370
|
+
type: VideoGameWithDaliVideo
|
|
371
|
+
classes: ${DATA.classes}
|
|
372
|
+
output_map: [data, label]
|
|
373
|
+
video_path: ${DATA.data_dir}/test/
|
|
374
|
+
path: ${DATA.test.video_path}/annotations-2024-224p-test.json
|
|
375
|
+
results: results_spotting_test
|
|
376
|
+
nms_window: 2
|
|
377
|
+
metric: tight
|
|
378
|
+
overlap_len: 50
|
|
379
|
+
dataloader:
|
|
380
|
+
batch_size: 4
|
|
381
|
+
shuffle: false
|
|
382
|
+
|
|
383
|
+
challenge:
|
|
384
|
+
type: VideoGameWithDaliVideo
|
|
385
|
+
overlap_len: 50
|
|
386
|
+
output_map: [data, label]
|
|
387
|
+
path: ${DATA.data_dir}/challenge/annotations.json
|
|
388
|
+
dataloader:
|
|
389
|
+
batch_size: 4
|
|
390
|
+
shuffle: false
|
|
391
|
+
|
|
392
|
+
MODEL:
|
|
393
|
+
type: E2E
|
|
394
|
+
runner:
|
|
395
|
+
type: runner_e2e
|
|
396
|
+
backbone:
|
|
397
|
+
type: rny008_gsm
|
|
398
|
+
head:
|
|
399
|
+
type: gru
|
|
400
|
+
multi_gpu: true
|
|
401
|
+
load_weights: null
|
|
402
|
+
save_dir: ./checkpoints
|
|
403
|
+
work_dir: ${MODEL.save_dir}
|
|
404
|
+
|
|
405
|
+
TRAIN:
|
|
406
|
+
type: trainer_e2e
|
|
407
|
+
num_epochs: 10
|
|
408
|
+
acc_grad_iter: 1
|
|
409
|
+
base_num_valid_epochs: 30
|
|
410
|
+
start_valid_epoch: 4
|
|
411
|
+
valid_map_every: 1
|
|
412
|
+
criterion_valid: map
|
|
413
|
+
|
|
414
|
+
criterion:
|
|
415
|
+
type: CrossEntropyLoss
|
|
416
|
+
|
|
417
|
+
optimizer:
|
|
418
|
+
type: AdamWithScaler
|
|
419
|
+
lr: 0.01
|
|
420
|
+
|
|
421
|
+
scheduler:
|
|
422
|
+
type: ChainedSchedulerE2E
|
|
423
|
+
acc_grad_iter: 1
|
|
424
|
+
num_epochs: ${TRAIN.num_epochs}
|
|
425
|
+
warm_up_epochs: 3
|
|
426
|
+
|
|
427
|
+
SYSTEM:
|
|
428
|
+
log_dir: ./logs
|
|
429
|
+
seed: 42
|
|
430
|
+
GPU: 4 # number of gpus to use
|
|
431
|
+
device: cuda # auto | cuda | cpu
|
|
432
|
+
gpu_id: 0 # device id for single gpu training
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## Annotations (train/valid/test) (.json) format
|
|
436
|
+
Download annotations file from below links
|
|
437
|
+
1. Classification
|
|
438
|
+
mvfouls = https://huggingface.co/datasets/OpenSportsLab/opensportslib-classification-vars/tree/mvfouls
|
|
439
|
+
svfouls = https://huggingface.co/datasets/OpenSportsLab/opensportslib-classification-vars/tree/svfouls
|
|
440
|
+
|
|
441
|
+
2. Localization
|
|
442
|
+
ball-action-spotting = https://huggingface.co/datasets/OpenSportsLab/opensportslib-localization-snbas/tree/main
|
|
443
|
+
|
|
444
|
+
# Download weights from HF
|
|
445
|
+
1. classification (mvit)
|
|
446
|
+
(MVFoul classification) https://huggingface.co/jeetv/snpro-classification-mvit/tree/main
|
|
447
|
+
|
|
448
|
+
2. Localization (E2E spot)
|
|
449
|
+
- (2023 Ball Action Spotting - 2 classes) https://huggingface.co/jeetv/snpro-snbas-2023/tree/main
|
|
450
|
+
- (2024 Ball Action Spotting - 12 classes) https://huggingface.co/jeetv/snpro-snbas-2024/tree/main
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
Usage:
|
|
454
|
+
```bash
|
|
455
|
+
### Load weights from HF ###
|
|
456
|
+
|
|
457
|
+
#### For Classification ####
|
|
458
|
+
myModel.infer(
|
|
459
|
+
test_set="/path/to/annotations.json",
|
|
460
|
+
pretrained="jeetv/snpro-classification-mvit", # classification (MViT)
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
#### For Localization ####
|
|
464
|
+
pretrained = "jeetv/snpro-snbas-2023" # SNBAS - 2 classes (E2E spot)
|
|
465
|
+
pretrained = "jeetv/snpro-snbas-2024" # SNBAS - 12 classes (E2E spot)
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## Train on SINGLE GPU
|
|
469
|
+
```bash
|
|
470
|
+
from opensportslib import model
|
|
471
|
+
import wandb
|
|
472
|
+
|
|
473
|
+
# Initialize model with config
|
|
474
|
+
myModel = model.classification(
|
|
475
|
+
config="/path/to/classification.yaml"
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
## Localization ##
|
|
479
|
+
# myModel = model.localization(
|
|
480
|
+
# config="/path/to/classification.yaml"
|
|
481
|
+
# )
|
|
482
|
+
|
|
483
|
+
# Train on your dataset
|
|
484
|
+
myModel.train(
|
|
485
|
+
train_set="/path/to/train_annotations.json",
|
|
486
|
+
valid_set="/path/to/valid_annotations.json",
|
|
487
|
+
pretrained=/path/to/ # or path to pretrained checkpoint
|
|
488
|
+
)
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
## Train on Multiple GPU (DDP)
|
|
492
|
+
```bash
|
|
493
|
+
from opensportslib import model
|
|
494
|
+
|
|
495
|
+
def main():
|
|
496
|
+
myModel = model.classification(
|
|
497
|
+
config="/path/to/classification.yaml",
|
|
498
|
+
data_dir="/path/to/dataset_root"
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
## Localization ##
|
|
502
|
+
# myModel = model.localization(
|
|
503
|
+
# config="/path/to/classification.yaml"
|
|
504
|
+
# )
|
|
505
|
+
|
|
506
|
+
myModel.train(
|
|
507
|
+
train_set="/path/to/train_annotations.json",
|
|
508
|
+
valid_set="/path/to/valid_annotations.json",
|
|
509
|
+
pretrained="/path/to/pretrained.pt", # optional
|
|
510
|
+
use_ddp=True, # IMPORTANT
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
if __name__ == "__main__":
|
|
514
|
+
main()
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
## Test / Inference on SINGLE GPU
|
|
519
|
+
```bash
|
|
520
|
+
from opensportslib import model
|
|
521
|
+
|
|
522
|
+
# Load trained model
|
|
523
|
+
myModel = model.classification(
|
|
524
|
+
config="/path/to/classification.yaml"
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
## Localization ##
|
|
528
|
+
# myModel = model.localization(
|
|
529
|
+
# config="/path/to/classification.yaml"
|
|
530
|
+
# )
|
|
531
|
+
|
|
532
|
+
# Run inference on test set
|
|
533
|
+
metrics = myModel.infer(
|
|
534
|
+
test_set="/path/to/test_annotations.json",
|
|
535
|
+
pretrained="/path/to/checkpoints/final_model",
|
|
536
|
+
predictions="/path/to/predictions.json"
|
|
537
|
+
)
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
## Test / Inference on Multiple GPU (DDP)
|
|
541
|
+
```bash
|
|
542
|
+
from opensportslib import model
|
|
543
|
+
|
|
544
|
+
def main():
|
|
545
|
+
myModel = model.classification(
|
|
546
|
+
config="/path/to/classification.yaml",
|
|
547
|
+
data_dir="/path/to/dataset_root"
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
## Localization ##
|
|
551
|
+
# myModel = model.localization(
|
|
552
|
+
# config="/path/to/classification.yaml"
|
|
553
|
+
# )
|
|
554
|
+
|
|
555
|
+
metrics = myModel.infer(
|
|
556
|
+
test_set="/path/to/test_annotations.json",
|
|
557
|
+
pretrained="/path/to/checkpoints/best.pt",
|
|
558
|
+
predictions="/path/to/predictions.json",
|
|
559
|
+
use_ddp=True, # optional (usually not needed)
|
|
560
|
+
)
|
|
561
|
+
|
|
562
|
+
print(metrics)
|
|
563
|
+
|
|
564
|
+
if __name__ == "__main__":
|
|
565
|
+
main()
|
|
566
|
+
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
opensportslib/__init__.py,sha256=TfWJS-l96bTYJGvqvXWEEhs7RqjLGgwLpJEofsfWnZQ,621
|
|
2
|
+
opensportslib/apis/__init__.py,sha256=3pfQ45yO62fa8EUzczw8EYzOTVrxK15ZsH22AFAvdGU,759
|
|
3
|
+
opensportslib/apis/classification.py,sha256=-VrP9VusqgoNNCClJhR6zYJm7ML1cGIdnaFQ6gbKy6w,12986
|
|
4
|
+
opensportslib/apis/localization.py,sha256=eyuSxmxLcvgt4kpezpsQ-FSlBwIuEygAkBXmmumw2oY,9878
|
|
5
|
+
opensportslib/config/classification.yaml,sha256=NWJhTjFHpVDSqZuSOBlHIUVswCkIsJ-T3DbPkpffHSE,2849
|
|
6
|
+
opensportslib/config/classification_tracking.yaml,sha256=CRZVGZ7Lk0JCYjHsdclDeyNECe49Q0NQVluCHRPQD6A,2050
|
|
7
|
+
opensportslib/config/localization.yaml,sha256=p0n3buxCHe9uTbQNJg55CG2ckO40PTnhDzb2p3PlEZQ,2769
|
|
8
|
+
opensportslib/config/sngar_frames.yaml,sha256=lSqtWAZcJ0asp4BVJebXgZ9a0miV09fPOksDeKLDN9w,2370
|
|
9
|
+
opensportslib/config/graph_tracking_classification/avgpool.yaml,sha256=s38HwcGt-2SyUgZm6giGcmtsSfm3-gOg1p3mNzhfoqM,1571
|
|
10
|
+
opensportslib/config/graph_tracking_classification/gin.yaml,sha256=_ODn7TBDECv2CUNEuKmf2OyNfd7MdyjlRnYUXB6TIjE,1571
|
|
11
|
+
opensportslib/config/graph_tracking_classification/graphconv.yaml,sha256=AvK1_hsl-p3xPgUDMvIHVnGdPK0d4md2I09rF2yszqk,1577
|
|
12
|
+
opensportslib/config/graph_tracking_classification/graphsage.yaml,sha256=XMADg6z2dECVuWx94V2tbojiVrNG-SXiMTNQ61LQwYY,1576
|
|
13
|
+
opensportslib/config/graph_tracking_classification/maxpool.yaml,sha256=_ODn7TBDECv2CUNEuKmf2OyNfd7MdyjlRnYUXB6TIjE,1571
|
|
14
|
+
opensportslib/config/graph_tracking_classification/noedges.yaml,sha256=DNwBjzIQQjXjSmeA-Ragi9Gw_WEIzUJE4hGadzLRXQM,1565
|
|
15
|
+
opensportslib/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
opensportslib/core/loss/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
opensportslib/core/loss/builder.py,sha256=DpiVHOH-7hD32wSfjVkXjb0mjQyMx58zy8RXZPjG1Og,1250
|
|
18
|
+
opensportslib/core/loss/calf.py,sha256=VmuN7hRMY1Q5fKjTceyQt7IMJacuYEbU6RJpbtMgJJc,7960
|
|
19
|
+
opensportslib/core/loss/ce.py,sha256=k7CwAHWRjouE_wKmaVyHkbm5i8L9FNb7TNIZXF7N4G4,632
|
|
20
|
+
opensportslib/core/loss/combine.py,sha256=9B03jOPC2LgKLW03ljys_d9eXm9MIyi-AWTCxbMWMPI,1193
|
|
21
|
+
opensportslib/core/loss/nll.py,sha256=VYmSXR9iWcBYNMpeT_UH6jNM9FVdm-QiU5Pv7LmbTpE,607
|
|
22
|
+
opensportslib/core/optimizer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
opensportslib/core/optimizer/builder.py,sha256=SnESpU7BcouAnOdfZo7wxgoFsaJZ4rEEe_cLaIP3a80,1167
|
|
24
|
+
opensportslib/core/sampler/weighted_sampler.py,sha256=3WVIP1GS5ksw0bwIY3EtvZ0-dUxqksWy9QShidTnzL8,3963
|
|
25
|
+
opensportslib/core/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
+
opensportslib/core/scheduler/builder.py,sha256=saSQidzRZhKoplwGAAPruQfr8473gvz5jitOkzhPPNc,3280
|
|
27
|
+
opensportslib/core/trainer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
+
opensportslib/core/trainer/classification_trainer.py,sha256=1NNWgXtHbxOpLvvNLHXgLZEirXwwUj7U2FwKwkynnYI,41303
|
|
29
|
+
opensportslib/core/trainer/localization_trainer.py,sha256=RRkMt7tKiZYqyX4FtC24piILZYIHgZQSF_BWonWkm50,40341
|
|
30
|
+
opensportslib/core/utils/checkpoint.py,sha256=MOSdN8wjLOA0dyItYMeAehqKLpDdzbE31mYNFDMWVok,8068
|
|
31
|
+
opensportslib/core/utils/config.py,sha256=jLyVu01b-BKTMYOAH7sSH_aLisLf43Vx3vrMu9Zl2gg,5503
|
|
32
|
+
opensportslib/core/utils/data.py,sha256=xmXfYCrfsU0TPVYPmzzEBtXFc6zgtfT1BoKMfGkXMkw,3142
|
|
33
|
+
opensportslib/core/utils/ddp.py,sha256=7NJuHnwB5f45d6OXgRSnrB81CNkomxIplEBn0MSlxgU,2241
|
|
34
|
+
opensportslib/core/utils/default_args.py,sha256=yTpZCGlsxT2Bq_q651mSliFNHd9kH-HszQMlX7kacII,3423
|
|
35
|
+
opensportslib/core/utils/load_annotations.py,sha256=fOFvHNlmmTnEgmPpOHt_FJ0gp3EXWW_HStuYiFhW110,16607
|
|
36
|
+
opensportslib/core/utils/seed.py,sha256=0MXbMWQw2jaEfUf5QcWN5eXj6V2RtqrbwvWwbjxBXKY,788
|
|
37
|
+
opensportslib/core/utils/video_processing.py,sha256=JYQuJpf7vnpCdkqJ5H3fK1Gpi4sTA3LYg2TnOnqKu9Q,13777
|
|
38
|
+
opensportslib/core/utils/wandb.py,sha256=oglwPyN2F__GIPSIbPb8nf7WHytFv0WbLOkaKBfkXtY,2829
|
|
39
|
+
opensportslib/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
|
+
opensportslib/datasets/builder.py,sha256=_vXzVCaeoup5OPo4T96q6dyx24H4vJ6Of3mH1oEyYrI,1805
|
|
41
|
+
opensportslib/datasets/classification_dataset.py,sha256=EyxFGtGvZ9o8lKG2gy47wNsa12i73pSKvqyTPGR0fB8,20213
|
|
42
|
+
opensportslib/datasets/localization_dataset.py,sha256=VUdn8EYSymuFhpaDH0btUlCVPsxNleFxMos1vs2OGp0,32317
|
|
43
|
+
opensportslib/datasets/utils/__init__.py,sha256=43aJF50ghFaoyioNwLoBawqjSDslL1CKPcs893VD52Y,240
|
|
44
|
+
opensportslib/datasets/utils/tracking.py,sha256=Xiln9ZihREJi6boZJsXIo1H0FcBTtzu93ol9jAJ_ZXk,20864
|
|
45
|
+
opensportslib/metrics/classification_metric.py,sha256=FaM2Dcweo0ykrROWObKMmY-cGNkTIVwSiao4DnuQ964,6823
|
|
46
|
+
opensportslib/metrics/localization_metric.py,sha256=srcztV5qH_E9RYDG1shpoC0Ua-6oi-wO1tQlma9v98I,51607
|
|
47
|
+
opensportslib/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
|
+
opensportslib/models/builder.py,sha256=5i_An-kP7UhdGaSFAmx2UAZ_r7R7GrrhbfTqIcBy8rU,1903
|
|
49
|
+
opensportslib/models/backbones/builder.py,sha256=xzPjsl20cRbQWLVjvZtFt62MFIzNiNP4Jw-m1cmQYk4,21548
|
|
50
|
+
opensportslib/models/base/e2e.py,sha256=zaSstTdaSHDtUkACgY5SHb4TzliCyyolOF_cB7bLAAk,9389
|
|
51
|
+
opensportslib/models/base/tracking.py,sha256=GacGqMpJlqVWNnfgAVv26D_muONZKnFN1LC7ukPhEZ8,2230
|
|
52
|
+
opensportslib/models/base/vars.py,sha256=2yuUKJPQxbmWox5wrtXcfEJmV7IlUs-FwyIJqqTfo4E,1004
|
|
53
|
+
opensportslib/models/base/video.py,sha256=k1vAeG5OoC-gAqE1Wk05xZ1EbsIo12cKrBhiW-UC7qE,4387
|
|
54
|
+
opensportslib/models/base/video_mae.py,sha256=5Er4x7FnY4H6Q7nVnpgS8YH1C8J6j_-k6lekGCR_NgE,2012
|
|
55
|
+
opensportslib/models/heads/builder.py,sha256=rCPCfNx-G1AQYoEG8aSaQTQzmMVmxTERj7fwQbi2kU8,10005
|
|
56
|
+
opensportslib/models/neck/builder.py,sha256=2hGvv9MsPq_nfnfzW2VbNrNwWcA4_B5y9Dffkx75LWQ,7505
|
|
57
|
+
opensportslib/models/utils/common.py,sha256=NdYcqjHjHEhiv_on1pIA8mC8Mup8Z2k4DyEfJ4E5YQ8,6062
|
|
58
|
+
opensportslib/models/utils/litebase.py,sha256=qXEJQUIUsmSJnlm8QeWwJ2BNzXcR9Rw25MI1B9LiSzg,1796
|
|
59
|
+
opensportslib/models/utils/modules.py,sha256=BhYJgTnCBiQZMR-h6-e49tEHj0o59iLCb8KX4uu0oNw,4003
|
|
60
|
+
opensportslib/models/utils/shift.py,sha256=FaLIvbqjfEUnZb1VMxljjxXd_IfkweseoBTmANL7B84,5441
|
|
61
|
+
opensportslib/models/utils/utils.py,sha256=Hgy-ZOz5O6txoGaX8Op4Gcmyjq1S6gzM0lo7hyngL14,9898
|
|
62
|
+
opensportslib/models/utils/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
63
|
+
opensportslib/models/utils/impl/asformer.py,sha256=WaUxiE76mnpygUVoQocZ6URuohdBEPp1xfx94UYi_kM,17276
|
|
64
|
+
opensportslib/models/utils/impl/calf.py,sha256=L_BBthf4EGGhCWZnRKjKAUUs2cqzVFnBrNMzIoAi-NY,2023
|
|
65
|
+
opensportslib/models/utils/impl/gsm.py,sha256=H-FotqzxPk3IKZnYE76VClQi8F2OESdrGQKKMX2Jio8,5259
|
|
66
|
+
opensportslib/models/utils/impl/gtad.py,sha256=QXae-tZj1Leyx501OYQuBKntHW7Rf0ggxVomxtV7Si4,16928
|
|
67
|
+
opensportslib/models/utils/impl/tsm.py,sha256=URU1PB48jVvpeokCT3MNX8xUo7bi2jiidt3BRzIhVSY,5180
|
|
68
|
+
opensportslib-0.0.1.dev2.dist-info/licenses/LICENSE,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
|
|
69
|
+
opensportslib-0.0.1.dev2.dist-info/licenses/LICENSE-COMMERCIAL,sha256=ECuFgJRmrIA9-urtAvmdBQg95DMVXjQry_quLxlphrg,161
|
|
70
|
+
opensportslib-0.0.1.dev2.dist-info/METADATA,sha256=7oiATjjL5iiSeuUhx9_-90A9HOecg-_baqWveOoS5pM,13761
|
|
71
|
+
opensportslib-0.0.1.dev2.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
72
|
+
opensportslib-0.0.1.dev2.dist-info/top_level.txt,sha256=XYrhCgrArYzt8sPlO6RTWZFaeLySOkT8GqHeS0xt0CY,14
|
|
73
|
+
opensportslib-0.0.1.dev2.dist-info/RECORD,,
|