Upload folder using huggingface_hub
Browse files- .gitattributes +7 -0
- chute_config.yml +27 -0
- football_object_detection.onnx +3 -0
- football_pitch_template.png +0 -0
- hrnetv2_w48.yaml +35 -0
- inference.cpython-312-x86_64-linux-gnu.so +3 -0
- keypoint +3 -0
- keypoint_helper.cpython-312-x86_64-linux-gnu.so +3 -0
- keypoint_utils.py +25 -0
- miner.py +80 -0
- osnet_ain.pyc +0 -0
- osnet_model.pth.tar-100 +3 -0
- pitch.cpython-312-x86_64-linux-gnu.so +3 -0
- team_cluster.pyc +0 -0
- template_caches_0 +3 -0
- template_caches_1 +3 -0
- utils.pyc +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,10 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
inference.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
keypoint filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
keypoint_helper.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
osnet_model.pth.tar-100 filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
pitch.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
template_caches_0 filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
template_caches_1 filter=lfs diff=lfs merge=lfs -text
|
chute_config.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Image:
|
| 2 |
+
from_base: parachutes/python:3.12
|
| 3 |
+
run_command:
|
| 4 |
+
- pip install --upgrade setuptools wheel
|
| 5 |
+
- pip install --index-url https://download.pytorch.org/whl/cu128 torch torchvision
|
| 6 |
+
- pip install "ultralytics==8.3.222" "opencv-python-headless" "numpy" "pydantic"
|
| 7 |
+
- pip install scikit-learn cryptography
|
| 8 |
+
- pip install onnxruntime-gpu numba scipy joblib
|
| 9 |
+
set_workdir: /app
|
| 10 |
+
readme: "Image for chutes"
|
| 11 |
+
|
| 12 |
+
NodeSelector:
|
| 13 |
+
gpu_count: 1
|
| 14 |
+
min_vram_gb_per_gpu: 24
|
| 15 |
+
min_memory_gb: 32
|
| 16 |
+
exclude:
|
| 17 |
+
- "5090"
|
| 18 |
+
- b200
|
| 19 |
+
- h200
|
| 20 |
+
- mi300x
|
| 21 |
+
|
| 22 |
+
Chute:
|
| 23 |
+
timeout_seconds: 900
|
| 24 |
+
concurrency: 4
|
| 25 |
+
max_instances: 5
|
| 26 |
+
scaling_threshold: 0.5
|
| 27 |
+
shutdown_after_seconds: 96000
|
football_object_detection.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:13076d529e6a54f45e38be5e43f45b2fd00d6aa0838349e4fd137bd65d5f8a74
|
| 3 |
+
size 38568385
|
football_pitch_template.png
ADDED
|
hrnetv2_w48.yaml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MODEL:
|
| 2 |
+
IMAGE_SIZE: [960, 540]
|
| 3 |
+
NUM_JOINTS: 58
|
| 4 |
+
PRETRAIN: ''
|
| 5 |
+
EXTRA:
|
| 6 |
+
FINAL_CONV_KERNEL: 1
|
| 7 |
+
STAGE1:
|
| 8 |
+
NUM_MODULES: 1
|
| 9 |
+
NUM_BRANCHES: 1
|
| 10 |
+
BLOCK: BOTTLENECK
|
| 11 |
+
NUM_BLOCKS: [4]
|
| 12 |
+
NUM_CHANNELS: [64]
|
| 13 |
+
FUSE_METHOD: SUM
|
| 14 |
+
STAGE2:
|
| 15 |
+
NUM_MODULES: 1
|
| 16 |
+
NUM_BRANCHES: 2
|
| 17 |
+
BLOCK: BASIC
|
| 18 |
+
NUM_BLOCKS: [4, 4]
|
| 19 |
+
NUM_CHANNELS: [48, 96]
|
| 20 |
+
FUSE_METHOD: SUM
|
| 21 |
+
STAGE3:
|
| 22 |
+
NUM_MODULES: 4
|
| 23 |
+
NUM_BRANCHES: 3
|
| 24 |
+
BLOCK: BASIC
|
| 25 |
+
NUM_BLOCKS: [4, 4, 4]
|
| 26 |
+
NUM_CHANNELS: [48, 96, 192]
|
| 27 |
+
FUSE_METHOD: SUM
|
| 28 |
+
STAGE4:
|
| 29 |
+
NUM_MODULES: 3
|
| 30 |
+
NUM_BRANCHES: 4
|
| 31 |
+
BLOCK: BASIC
|
| 32 |
+
NUM_BLOCKS: [4, 4, 4, 4]
|
| 33 |
+
NUM_CHANNELS: [48, 96, 192, 384]
|
| 34 |
+
FUSE_METHOD: SUM
|
| 35 |
+
|
inference.cpython-312-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:099621792c6d8e8f6aa3410d9c98c420c4d2b032dfd21bde3451b2a99924f310
|
| 3 |
+
size 585656
|
keypoint
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c415cc6005d769eaa02cb7c8e00d50ffca44034e58bffdf5f93033c8cb128564
|
| 3 |
+
size 264964689
|
keypoint_helper.cpython-312-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c741e913bfb46469cfd30ef438ff4da0d5ef3e626606cf0b6aae4875c3a47f52
|
| 3 |
+
size 901256
|
keypoint_utils.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from numba import njit, prange
|
| 3 |
+
|
| 4 |
+
@njit(fastmath=True, cache=True)
|
| 5 |
+
def score_mask_numba_fast(pred, expected, ground, pixels_on_lines):
|
| 6 |
+
h, w = pred.shape
|
| 7 |
+
pp = 0
|
| 8 |
+
po = 0
|
| 9 |
+
|
| 10 |
+
for y in prange(h):
|
| 11 |
+
for x in range(w):
|
| 12 |
+
p_val = pred[y, x]
|
| 13 |
+
g_val = ground[y, x]
|
| 14 |
+
e_val = expected[y, x]
|
| 15 |
+
p = (p_val != 0) & (g_val != 0)
|
| 16 |
+
e = e_val != 0
|
| 17 |
+
pp += p
|
| 18 |
+
po += p & e
|
| 19 |
+
if pp == 0:
|
| 20 |
+
return 0.0
|
| 21 |
+
pr = pp - po
|
| 22 |
+
total = pixels_on_lines + pp - po
|
| 23 |
+
if total == 0 or pr * 10 > total * 9:
|
| 24 |
+
return 0.0
|
| 25 |
+
return po / (pixels_on_lines + 1e-8)
|
miner.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
from typing import List, Tuple, Dict
|
| 5 |
+
import sys
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
from numpy import ndarray
|
| 9 |
+
from pydantic import BaseModel
|
| 10 |
+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
| 11 |
+
|
| 12 |
+
# from inference import predict_batch, load_model
|
| 13 |
+
import importlib.util
|
| 14 |
+
from pathlib import Path
|
| 15 |
+
|
| 16 |
+
def manual_import(name, filename):
|
| 17 |
+
"""
|
| 18 |
+
Manually loads a module (.so, .pyc, or .py) from a specific file path,
|
| 19 |
+
bypassing sys.meta_path import hooks.
|
| 20 |
+
"""
|
| 21 |
+
# Locate the file relative to the current miner.py
|
| 22 |
+
curr_dir = Path(__file__).parent
|
| 23 |
+
file_path = curr_dir / filename
|
| 24 |
+
|
| 25 |
+
if not file_path.exists():
|
| 26 |
+
raise FileNotFoundError(f"Could not find {file_path}")
|
| 27 |
+
|
| 28 |
+
# Load the spec directly from the file path
|
| 29 |
+
spec = importlib.util.spec_from_file_location(name, file_path)
|
| 30 |
+
if spec is None:
|
| 31 |
+
raise ImportError(f"Could not load spec for {name} from {file_path}")
|
| 32 |
+
|
| 33 |
+
# Create the module and register it in sys.modules
|
| 34 |
+
module = importlib.util.module_from_spec(spec)
|
| 35 |
+
sys.modules[name] = module
|
| 36 |
+
|
| 37 |
+
# Execute the module
|
| 38 |
+
spec.loader.exec_module(module)
|
| 39 |
+
return module
|
| 40 |
+
|
| 41 |
+
class BoundingBox(BaseModel):
|
| 42 |
+
x1: int
|
| 43 |
+
y1: int
|
| 44 |
+
x2: int
|
| 45 |
+
y2: int
|
| 46 |
+
cls_id: int
|
| 47 |
+
conf: float
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class TVFrameResult(BaseModel):
|
| 51 |
+
frame_id: int
|
| 52 |
+
boxes: List[BoundingBox]
|
| 53 |
+
keypoints: List[Tuple[int, int]]
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class Miner:
|
| 57 |
+
def __init__(self, path_hf_repo: Path) -> None:
|
| 58 |
+
print("model laoding")
|
| 59 |
+
self.health = 'Okay'
|
| 60 |
+
self.inference = None
|
| 61 |
+
self.path_hf_repo = path_hf_repo
|
| 62 |
+
self.is_start = False
|
| 63 |
+
|
| 64 |
+
def __repr__(self) -> str:
|
| 65 |
+
return self.health
|
| 66 |
+
|
| 67 |
+
def predict_batch(self, batch_images: List[ndarray], offset: int, n_keypoints: int) -> List[TVFrameResult]:
|
| 68 |
+
if self.is_start == False:
|
| 69 |
+
self.is_start = True
|
| 70 |
+
return None
|
| 71 |
+
if self.inference is None:
|
| 72 |
+
self.inference = manual_import("inference", "inference.cpython-312-x86_64-linux-gnu.so")
|
| 73 |
+
self.inference.load_model(self.path_hf_repo)
|
| 74 |
+
|
| 75 |
+
results = self.inference.predict_batch(
|
| 76 |
+
batch_images,
|
| 77 |
+
offset,
|
| 78 |
+
n_keypoints,
|
| 79 |
+
)
|
| 80 |
+
return results
|
osnet_ain.pyc
ADDED
|
Binary file (24.2 kB). View file
|
|
|
osnet_model.pth.tar-100
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:374cbb3b832091776436f29794e1a911c2009c08d20949faec16c03fe614e474
|
| 3 |
+
size 36189570
|
pitch.cpython-312-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:173f19a4fe01cd6892cadcd7799faa0a8049848c1552d0a0b2b312f23545cd6b
|
| 3 |
+
size 593736
|
team_cluster.pyc
ADDED
|
Binary file (7.62 kB). View file
|
|
|
template_caches_0
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:77fab72dc09bf3d4613c05d8386324305e517dab040eb5ba86c864f8bb44edf5
|
| 3 |
+
size 1659115263
|
template_caches_1
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:25cc8230874004ac1662189852d48b3af9b5bd40ceae15df1306371087e931f6
|
| 3 |
+
size 1502035167
|
utils.pyc
ADDED
|
Binary file (20.6 kB). View file
|
|
|