Lordplay commited on
Commit
253e6ec
·
1 Parent(s): 99b1324

Add model files and configurations with LFS

Browse files
.gitattributes CHANGED
@@ -33,3 +33,7 @@ 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
+ *.so filter=lfs diff=lfs merge=lfs -text
37
+ models/osnet_model.pth.tar-100 filter=lfs diff=lfs merge=lfs -text
38
+ keypoint filter=lfs diff=lfs merge=lfs -text
39
+ osnet_model.pth.tar-100 filter=lfs diff=lfs merge=lfs -text
chute_config.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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" "Pillow"
7
+ - pip install scikit-learn
8
+ - pip install onnxruntime-gpu
9
+ - pip install lapx
10
+ set_workdir: /app
11
+ readme: "Image for chutes"
12
+
13
+ NodeSelector:
14
+ gpu_count: 1
15
+ min_vram_gb_per_gpu: 24
16
+ min_cpu_count: 8
17
+ min_memory_gb: 16
18
+ exclude:
19
+ - b200
20
+ - h200
21
+ - mi300x
22
+
23
+ Chute:
24
+ timeout_seconds: 900
25
+ concurrency: 4
26
+ max_instances: 5
27
+ scaling_threshold: 0.5
28
+ shutdown_after_seconds: 96000
football_pitch_template.png ADDED
keypoints_convert.cpython-312-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57dc1ff1747bb9394a64ae1d3ac36be297e18ca8bf345979b09710e1d522397a
3
+ size 22452368
keypoints_cy_all.cpython-312-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:556f305991967aa60fb04458e789dc793d855765ae52a207ecf16ff8dada9f0c
3
+ size 1422656
miner.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ from pathlib import Path
4
+ from typing import List, Tuple
5
+
6
+ from numpy import ndarray
7
+ from pydantic import BaseModel
8
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
9
+
10
+ # from inference import predict_batch, load_model
11
+ import importlib.util
12
+ from pathlib import Path
13
+
14
+ def manual_import(name, filename):
15
+ curr_dir = Path(__file__).parent
16
+ file_path = curr_dir / filename
17
+
18
+ if not file_path.exists():
19
+ raise FileNotFoundError(f"Could not find {file_path}")
20
+
21
+ spec = importlib.util.spec_from_file_location(name, file_path)
22
+ if spec is None:
23
+ raise ImportError(f"Could not load spec for {name} from {file_path}")
24
+
25
+ module = importlib.util.module_from_spec(spec)
26
+ # No sys.modules registration needed - pipeline.py uses regular classes, not dataclasses
27
+ spec.loader.exec_module(module)
28
+ return module
29
+
30
+
31
+ def manual_import_pipeline(name: str):
32
+ """
33
+ Manual import for pipeline module, bypassing sys.meta_path.
34
+ Tries .py first (development), then .so (production).
35
+ """
36
+ curr_dir = Path(__file__).parent
37
+ last_error = None
38
+
39
+ # Try .py first (development)
40
+ py_path = curr_dir / f"{name}.py"
41
+ if py_path.is_file():
42
+ try:
43
+ return manual_import(name, f"{name}.py")
44
+ except Exception as e:
45
+ last_error = e # Save error, try .so next
46
+
47
+ # Try .so files (production)
48
+ so_candidates = sorted(curr_dir.glob(f"{name}*.so"))
49
+ if so_candidates:
50
+ so_filename = so_candidates[0].name
51
+ try:
52
+ return manual_import(name, so_filename)
53
+ except Exception as e:
54
+ last_error = e
55
+
56
+ # If we have a saved error, raise it with context
57
+ if last_error:
58
+ raise ImportError(f"Could not import {name} from {curr_dir}: {last_error}") from last_error
59
+ raise ImportError(f"Could not find {name}.py or {name}*.so in {curr_dir}")
60
+
61
+ class BoundingBox(BaseModel):
62
+ x1: int
63
+ y1: int
64
+ x2: int
65
+ y2: int
66
+ cls_id: int
67
+ conf: float
68
+ team_id: str | None = None
69
+
70
+
71
+ class TVFrameResult(BaseModel):
72
+ frame_id: int
73
+ boxes: List[BoundingBox]
74
+ keypoints: List[Tuple[float, float]]
75
+
76
+
77
+ class Miner:
78
+ def __init__(self, path_hf_repo: Path) -> None:
79
+ print("model laoding")
80
+ self.health = 'Okay-turbo-16'
81
+ self.pipeline = None
82
+ self.path_hf_repo = path_hf_repo
83
+ self.is_start = False
84
+
85
+ def __repr__(self) -> str:
86
+ return self.health
87
+
88
+ def predict_batch(self, batch_images: List[ndarray], offset: int, n_keypoints: int) -> List[TVFrameResult]:
89
+ if self.is_start == False:
90
+ self.is_start = True
91
+ return []
92
+ if self.pipeline is None:
93
+ pipeline_module = manual_import_pipeline("pipeline")
94
+ self.pipeline = pipeline_module.MinerPipeline(repo_root=self.path_hf_repo)
95
+ results = self.pipeline.predict_batch(
96
+ batch_images,
97
+ offset,
98
+ n_keypoints,
99
+ )
100
+ return results
models/ball-detection-model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1bde814c8d4a64225f517444d1f96edce86bd54bdee41bf23dbc3a45646a7d04
3
+ size 10418757
models/keypoint-detection-model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74596f774653549499503e1b5d9ef23815f6c3f36fa395f0cddc51458e24c1bc
3
+ size 10422736
models/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
models/person-detection-model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:305fb39579bb3473db25acce3dd4a3944c63a3994eac573e46c6a3c372098e34
3
+ size 10420354
pipeline.cpython-312-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d428a68aaa1934191c9ea531d088ecbf8c463b040dac257560175b7b58f966e5
3
+ size 3720144