scorevision: push artifact
Browse files- chute_config.yml +3 -5
- miner.py +107 -27
- person_weights.onnx +2 -2
chute_config.yml
CHANGED
|
@@ -9,11 +9,9 @@ NodeSelector:
|
|
| 9 |
gpu_count: 1
|
| 10 |
min_vram_gb_per_gpu: 16
|
| 11 |
max_hourly_price_per_gpu: 2.0
|
| 12 |
-
|
| 13 |
-
- '
|
| 14 |
-
-
|
| 15 |
-
- h200
|
| 16 |
-
- mi300x
|
| 17 |
Chute:
|
| 18 |
timeout_seconds: 900
|
| 19 |
concurrency: 4
|
|
|
|
| 9 |
gpu_count: 1
|
| 10 |
min_vram_gb_per_gpu: 16
|
| 11 |
max_hourly_price_per_gpu: 2.0
|
| 12 |
+
include:
|
| 13 |
+
- '4090'
|
| 14 |
+
- pro_6000
|
|
|
|
|
|
|
| 15 |
Chute:
|
| 16 |
timeout_seconds: 900
|
| 17 |
concurrency: 4
|
miner.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
"""
|
| 2 |
-
Score Vision SN44 β Unified miner v3.
|
| 3 |
-
Dual-model: vehicle (YOLO11m INT8 1280, CUDA) + person (
|
| 4 |
Pose model: YOLOv8n-pose FP16 640 for false-positive filtering + keypoint box refinement.
|
| 5 |
Vehicle weights loaded from secondary HF repo (meaculpitt/ScoreVision-Vehicle).
|
| 6 |
Person weights loaded from primary HF repo (template downloads automatically).
|
|
@@ -13,7 +13,7 @@ Vehicle model (vehicle_weights.onnx):
|
|
| 13 |
Flip TTA always enabled β compensates for higher confidence thresholds.
|
| 14 |
|
| 15 |
Person model (person_weights.onnx):
|
| 16 |
-
|
| 17 |
Background TRT build: starts on CUDA immediately, builds TRT FP16 engine in background
|
| 18 |
thread (~18min on fresh node), swaps to TRT atomically when ready. Cached thereafter.
|
| 19 |
SAHI-style tiling: full + 2 adaptive tiles + flip TTA, max-conf NMS merge.
|
|
@@ -39,56 +39,120 @@ import logging as _logging
|
|
| 39 |
_cuda_log = _logging.getLogger(__name__)
|
| 40 |
|
| 41 |
def _preload_cuda_libs():
|
| 42 |
-
"""Pre-load CUDA + TensorRT libs from pip packages so ORT GPU/TRT providers work.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
try:
|
|
|
|
| 44 |
lib_dirs = []
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
for mod_name in ['nvidia.cudnn', 'nvidia.cublas', 'nvidia.cuda_runtime',
|
| 47 |
'nvidia.cufft', 'nvidia.curand', 'nvidia.cusolver',
|
| 48 |
'nvidia.cusparse', 'nvidia.nvjitlink']:
|
| 49 |
try:
|
| 50 |
mod = __import__(mod_name, fromlist=['__file__'])
|
| 51 |
lib_dir = os.path.join(os.path.dirname(mod.__file__), 'lib')
|
| 52 |
-
if os.path.isdir(lib_dir):
|
| 53 |
lib_dirs.append(lib_dir)
|
| 54 |
except ImportError:
|
| 55 |
pass
|
| 56 |
|
| 57 |
-
# TensorRT libs β
|
| 58 |
-
import sys as
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
break
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
break
|
| 77 |
-
if
|
| 78 |
break
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
return
|
|
|
|
|
|
|
| 82 |
existing = os.environ.get('LD_LIBRARY_PATH', '')
|
| 83 |
os.environ['LD_LIBRARY_PATH'] = ':'.join(lib_dirs + ([existing] if existing else []))
|
|
|
|
|
|
|
| 84 |
for lib_dir in lib_dirs:
|
|
|
|
|
|
|
| 85 |
for so in sorted(_glob.glob(os.path.join(lib_dir, 'lib*.so*'))):
|
| 86 |
try:
|
| 87 |
ctypes.CDLL(so, mode=ctypes.RTLD_GLOBAL)
|
| 88 |
except OSError:
|
| 89 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
except Exception as e:
|
| 91 |
-
_cuda_log.warning(
|
| 92 |
|
| 93 |
_preload_cuda_libs()
|
| 94 |
|
|
@@ -1128,6 +1192,14 @@ class Miner:
|
|
| 1128 |
inp = np.ascontiguousarray(inp.transpose(2, 0, 1)[np.newaxis])
|
| 1129 |
return inp, ratio, pl, pt
|
| 1130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1131 |
def _per_decode(self, raw, ratio, pl, pt, oh, ow, conf_thresh):
|
| 1132 |
pred = raw[0]
|
| 1133 |
if pred.ndim != 2:
|
|
@@ -1676,6 +1748,14 @@ class Miner:
|
|
| 1676 |
all_boxes.append(boxes_flip)
|
| 1677 |
all_confs.append(confs_flip)
|
| 1678 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1679 |
if not all_boxes:
|
| 1680 |
return []
|
| 1681 |
|
|
|
|
| 1 |
"""
|
| 2 |
+
Score Vision SN44 β Unified miner v3.16 (2026-04-03). YOLO12s + TRT + CLAHE.
|
| 3 |
+
Dual-model: vehicle (YOLO11m INT8 1280, CUDA) + person (YOLO12s FP16 960 end2end, TRT).
|
| 4 |
Pose model: YOLOv8n-pose FP16 640 for false-positive filtering + keypoint box refinement.
|
| 5 |
Vehicle weights loaded from secondary HF repo (meaculpitt/ScoreVision-Vehicle).
|
| 6 |
Person weights loaded from primary HF repo (template downloads automatically).
|
|
|
|
| 13 |
Flip TTA always enabled β compensates for higher confidence thresholds.
|
| 14 |
|
| 15 |
Person model (person_weights.onnx):
|
| 16 |
+
YOLO12s FP16 960px end2end [1,300,6]. Single class: 0=person.
|
| 17 |
Background TRT build: starts on CUDA immediately, builds TRT FP16 engine in background
|
| 18 |
thread (~18min on fresh node), swaps to TRT atomically when ready. Cached thereafter.
|
| 19 |
SAHI-style tiling: full + 2 adaptive tiles + flip TTA, max-conf NMS merge.
|
|
|
|
| 39 |
_cuda_log = _logging.getLogger(__name__)
|
| 40 |
|
| 41 |
def _preload_cuda_libs():
|
| 42 |
+
"""Pre-load CUDA + TensorRT libs from pip packages so ORT GPU/TRT providers work.
|
| 43 |
+
|
| 44 |
+
Search order for TRT libs (libnvinfer.so, libnvonnxparser.so):
|
| 45 |
+
1. sys.path entries containing tensorrt_libs/ subdirectory
|
| 46 |
+
2. site.getsitepackages() + user site-packages for tensorrt_libs/ or tensorrt/
|
| 47 |
+
3. ctypes.util.find_library('nvinfer') as system-wide fallback
|
| 48 |
+
If not found, logs clearly and skips TRT β never attempts pip operations.
|
| 49 |
+
"""
|
| 50 |
try:
|
| 51 |
+
import ctypes.util as _ctypes_util
|
| 52 |
lib_dirs = []
|
| 53 |
+
loaded = set()
|
| 54 |
+
|
| 55 |
+
# ββ CUDA libs from nvidia pip packages ββ
|
| 56 |
for mod_name in ['nvidia.cudnn', 'nvidia.cublas', 'nvidia.cuda_runtime',
|
| 57 |
'nvidia.cufft', 'nvidia.curand', 'nvidia.cusolver',
|
| 58 |
'nvidia.cusparse', 'nvidia.nvjitlink']:
|
| 59 |
try:
|
| 60 |
mod = __import__(mod_name, fromlist=['__file__'])
|
| 61 |
lib_dir = os.path.join(os.path.dirname(mod.__file__), 'lib')
|
| 62 |
+
if os.path.isdir(lib_dir) and lib_dir not in lib_dirs:
|
| 63 |
lib_dirs.append(lib_dir)
|
| 64 |
except ImportError:
|
| 65 |
pass
|
| 66 |
|
| 67 |
+
# ββ TensorRT libs β multi-strategy search ββ
|
| 68 |
+
import sys as _sys
|
| 69 |
+
_trt_dir = None
|
| 70 |
+
|
| 71 |
+
# Strategy 1: sys.path (covers standard pip installs)
|
| 72 |
+
for p in _sys.path:
|
| 73 |
+
for subdir in ('tensorrt_libs', 'tensorrt'):
|
| 74 |
+
candidate = os.path.join(p, subdir)
|
| 75 |
+
if os.path.isdir(candidate) and _glob.glob(os.path.join(candidate, 'libnvinfer*')):
|
| 76 |
+
_trt_dir = candidate
|
| 77 |
+
break
|
| 78 |
+
if _trt_dir:
|
| 79 |
break
|
| 80 |
+
|
| 81 |
+
# Strategy 2: site-packages directories (covers user installs, venvs)
|
| 82 |
+
if not _trt_dir:
|
| 83 |
+
import site
|
| 84 |
+
search_dirs = list(site.getsitepackages()) if hasattr(site, 'getsitepackages') else []
|
| 85 |
+
user_site = getattr(site, 'getusersitepackages', lambda: None)()
|
| 86 |
+
if user_site:
|
| 87 |
+
search_dirs.append(user_site)
|
| 88 |
+
# Also check common paths not always in site
|
| 89 |
+
search_dirs.extend([
|
| 90 |
+
'/usr/local/lib/python3.12/dist-packages',
|
| 91 |
+
os.path.expanduser('~/.local/lib/python3.12/site-packages'),
|
| 92 |
+
'/home/miner/.local/lib/python3.12/site-packages',
|
| 93 |
+
])
|
| 94 |
+
for sp in search_dirs:
|
| 95 |
+
for subdir in ('tensorrt_libs', 'tensorrt'):
|
| 96 |
+
candidate = os.path.join(sp, subdir)
|
| 97 |
+
if os.path.isdir(candidate) and _glob.glob(os.path.join(candidate, 'libnvinfer*')):
|
| 98 |
+
_trt_dir = candidate
|
| 99 |
break
|
| 100 |
+
if _trt_dir:
|
| 101 |
break
|
| 102 |
|
| 103 |
+
# Strategy 3: ctypes.util.find_library (system-wide LD search)
|
| 104 |
+
if not _trt_dir:
|
| 105 |
+
nvinfer_path = _ctypes_util.find_library('nvinfer')
|
| 106 |
+
if nvinfer_path:
|
| 107 |
+
_cuda_log.info('TRT found via system library: %s', nvinfer_path)
|
| 108 |
+
try:
|
| 109 |
+
ctypes.CDLL(nvinfer_path, mode=ctypes.RTLD_GLOBAL)
|
| 110 |
+
loaded.add('nvinfer')
|
| 111 |
+
except OSError as e:
|
| 112 |
+
_cuda_log.warning('Failed to load system nvinfer: %s', e)
|
| 113 |
+
|
| 114 |
+
if _trt_dir:
|
| 115 |
+
if _trt_dir not in lib_dirs:
|
| 116 |
+
lib_dirs.append(_trt_dir)
|
| 117 |
+
_cuda_log.info('TRT libs directory: %s', _trt_dir)
|
| 118 |
+
elif 'nvinfer' not in loaded:
|
| 119 |
+
_cuda_log.info('TensorRT libs not found β TRT EP will be unavailable (CUDA EP still works)')
|
| 120 |
+
|
| 121 |
+
if not lib_dirs and not loaded:
|
| 122 |
+
_cuda_log.warning('No CUDA or TRT libs found to preload')
|
| 123 |
return
|
| 124 |
+
|
| 125 |
+
# Set LD_LIBRARY_PATH for any child processes / dlopen fallbacks
|
| 126 |
existing = os.environ.get('LD_LIBRARY_PATH', '')
|
| 127 |
os.environ['LD_LIBRARY_PATH'] = ':'.join(lib_dirs + ([existing] if existing else []))
|
| 128 |
+
|
| 129 |
+
# Load CUDA libs (glob all .so in nvidia dirs)
|
| 130 |
for lib_dir in lib_dirs:
|
| 131 |
+
if 'tensorrt' in lib_dir:
|
| 132 |
+
continue # TRT libs loaded selectively below
|
| 133 |
for so in sorted(_glob.glob(os.path.join(lib_dir, 'lib*.so*'))):
|
| 134 |
try:
|
| 135 |
ctypes.CDLL(so, mode=ctypes.RTLD_GLOBAL)
|
| 136 |
except OSError:
|
| 137 |
pass
|
| 138 |
+
|
| 139 |
+
# Load TRT libs selectively (only the essentials, not builder resources)
|
| 140 |
+
if _trt_dir:
|
| 141 |
+
for lib_name in ['libnvinfer.so', 'libnvinfer_plugin.so', 'libnvonnxparser.so']:
|
| 142 |
+
matches = _glob.glob(os.path.join(_trt_dir, lib_name + '*'))
|
| 143 |
+
if matches:
|
| 144 |
+
try:
|
| 145 |
+
ctypes.CDLL(matches[0], mode=ctypes.RTLD_GLOBAL)
|
| 146 |
+
loaded.add(lib_name.split('.')[0])
|
| 147 |
+
except OSError as e:
|
| 148 |
+
_cuda_log.warning('Failed to load %s: %s', lib_name, e)
|
| 149 |
+
else:
|
| 150 |
+
_cuda_log.info('%s not found in %s', lib_name, _trt_dir)
|
| 151 |
+
|
| 152 |
+
if loaded:
|
| 153 |
+
_cuda_log.info('Preloaded libs: %s', ', '.join(sorted(loaded)))
|
| 154 |
except Exception as e:
|
| 155 |
+
_cuda_log.warning('CUDA/TRT preload error: %s', e)
|
| 156 |
|
| 157 |
_preload_cuda_libs()
|
| 158 |
|
|
|
|
| 1192 |
inp = np.ascontiguousarray(inp.transpose(2, 0, 1)[np.newaxis])
|
| 1193 |
return inp, ratio, pl, pt
|
| 1194 |
|
| 1195 |
+
def _per_enhance(self, img_bgr):
|
| 1196 |
+
"""CLAHE contrast enhancement (clip=12) on LAB L-channel."""
|
| 1197 |
+
lab = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2LAB)
|
| 1198 |
+
l, a, b = cv2.split(lab)
|
| 1199 |
+
clahe = cv2.createCLAHE(clipLimit=12.0, tileGridSize=(8, 8))
|
| 1200 |
+
l = clahe.apply(l)
|
| 1201 |
+
return cv2.cvtColor(cv2.merge([l, a, b]), cv2.COLOR_LAB2BGR)
|
| 1202 |
+
|
| 1203 |
def _per_decode(self, raw, ratio, pl, pt, oh, ow, conf_thresh):
|
| 1204 |
pred = raw[0]
|
| 1205 |
if pred.ndim != 2:
|
|
|
|
| 1748 |
all_boxes.append(boxes_flip)
|
| 1749 |
all_confs.append(confs_flip)
|
| 1750 |
|
| 1751 |
+
# Pass 5: CLAHE enhanced preprocessing pass
|
| 1752 |
+
if time.monotonic() - t_start < PER_RTF_BUDGET / 4:
|
| 1753 |
+
enhanced = self._per_enhance(image_bgr)
|
| 1754 |
+
boxes_enh, confs_enh = self._per_run_pass(enhanced, PER_CONF_LOW)
|
| 1755 |
+
if len(boxes_enh) > 0:
|
| 1756 |
+
all_boxes.append(boxes_enh)
|
| 1757 |
+
all_confs.append(confs_enh)
|
| 1758 |
+
|
| 1759 |
if not all_boxes:
|
| 1760 |
return []
|
| 1761 |
|
person_weights.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:84e9a6adf84703b2fa13e5e587f1a7ffc8ab69f6d45c2fc7ae71ded6ff9a926f
|
| 3 |
+
size 18860997
|