alfred8995 commited on
Commit
6593d45
·
verified ·
1 Parent(s): cfcf1c1

Upload folder using huggingface_hub

Browse files
__pycache__/infer.cpython-312.pyc ADDED
Binary file (5.35 kB). View file
 
__pycache__/miner.cpython-312.pyc ADDED
Binary file (28.2 kB). View file
 
chute_config.yml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Image:
2
+ from_base: parachutes/python:3.12
3
+ run_command:
4
+ - pip install --upgrade setuptools wheel
5
+ - pip install 'numpy>=1.23' 'onnxruntime-gpu[cuda,cudnn]>=1.16' 'opencv-python>=4.7' 'pillow>=9.5' 'huggingface_hub>=0.19.4' 'pydantic>=2.0' 'pyyaml>=6.0' 'aiohttp>=3.9'
6
+ - pip install torch torchvision
7
+
8
+ NodeSelector:
9
+ gpu_count: 1
10
+ min_vram_gb_per_gpu: 16
11
+ max_hourly_price_per_gpu: 2
12
+ include:
13
+ - pro_6000
14
+
15
+ Chute:
16
+ timeout_seconds: 900
17
+ concurrency: 4
18
+ max_instances: 5
19
+ scaling_threshold: 0.5
20
+ shutdown_after_seconds: 288000
21
+ tee: true
miner.py ADDED
@@ -0,0 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import math
3
+
4
+ import cv2
5
+ import numpy as np
6
+ import onnxruntime as ort
7
+ from numpy import ndarray
8
+ from pydantic import BaseModel
9
+
10
+
11
+ class BoundingBox(BaseModel):
12
+ x1: int
13
+ y1: int
14
+ x2: int
15
+ y2: int
16
+ cls_id: int
17
+ conf: float
18
+
19
+
20
+ class TVFrameResult(BaseModel):
21
+ frame_id: int
22
+ boxes: list[BoundingBox]
23
+ keypoints: list[tuple[int, int]]
24
+
25
+
26
+ class Miner:
27
+ """ONNX Runtime miner for single-class road-sign detection.
28
+
29
+ Pipeline: letterbox → ORT → conf filter (+ rescue) → unletterbox →
30
+ sanity filter → per-class hard NMS → cap max_det.
31
+ """
32
+
33
+ class_names = ["road_sign"]
34
+ _model_class_order = ["road_sign"]
35
+
36
+ iou_thres = 0.5
37
+ max_det = 150
38
+
39
+ _conf_thres_array = np.array([0.175], dtype=np.float32)
40
+ _bonus_array = np.array([0.1], dtype=np.float32)
41
+
42
+ min_box_area = 8 * 8
43
+ min_side = 3
44
+ max_aspect_ratio = 12.0
45
+
46
+ def __init__(self, path_hf_repo: Path) -> None:
47
+ model_path = path_hf_repo / "weights.onnx"
48
+ print("ORT version:", ort.__version__)
49
+
50
+ try:
51
+ ort.preload_dlls()
52
+ print("✅ onnxruntime.preload_dlls() success")
53
+ except Exception as e:
54
+ print(f"⚠️ preload_dlls failed: {e}")
55
+
56
+ print("ORT available providers BEFORE session:", ort.get_available_providers())
57
+
58
+ sess_options = ort.SessionOptions()
59
+ sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
60
+ sess_options.intra_op_num_threads = 2
61
+ sess_options.inter_op_num_threads = 1
62
+ sess_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
63
+
64
+ self.session = ort.InferenceSession(
65
+ str(model_path),
66
+ sess_options=sess_options,
67
+ providers=["CPUExecutionProvider"],
68
+ )
69
+ print("ORT session providers:", self.session.get_providers())
70
+
71
+ model_class_order = self._read_model_class_order()
72
+ if model_class_order is None:
73
+ model_class_order = list(self._model_class_order)
74
+ print(f"cls order: no usable ONNX metadata, FALLBACK {model_class_order}")
75
+ else:
76
+ print(f"cls order: from ONNX metadata {model_class_order}")
77
+ self.cls_remap = np.array(
78
+ [self.class_names.index(n) for n in model_class_order],
79
+ dtype=np.int32,
80
+ )
81
+
82
+ for inp in self.session.get_inputs():
83
+ print("INPUT:", inp.name, inp.shape, inp.type)
84
+ for out in self.session.get_outputs():
85
+ print("OUTPUT:", out.name, out.shape, out.type)
86
+
87
+ self.input_name = self.session.get_inputs()[0].name
88
+ self.output_names = [output.name for output in self.session.get_outputs()]
89
+ self.input_shape = self.session.get_inputs()[0].shape
90
+ self.input_height = self._safe_dim(self.input_shape[2], default=1280)
91
+ self.input_width = self._safe_dim(self.input_shape[3], default=1280)
92
+
93
+ print(f"✅ ONNX model loaded from: {model_path}")
94
+ print(f"✅ ONNX input: name={self.input_name}, shape={self.input_shape}")
95
+ print(f"✅ ONNX input size: {self.input_width}x{self.input_height}")
96
+ print(
97
+ "per-class conf: "
98
+ + ", ".join(
99
+ f"{n}={t:.3f}"
100
+ for n, t in zip(self.class_names, self._conf_thres_array.tolist())
101
+ )
102
+ )
103
+
104
+ self._warmup()
105
+
106
+ def _warmup(self, iters: int = 3) -> None:
107
+ try:
108
+ dummy = np.zeros((720, 1280, 3), dtype=np.uint8)
109
+ for _ in range(max(1, iters)):
110
+ self.predict_batch(batch_images=[dummy], offset=0, n_keypoints=0)
111
+ print(f"✅ warmup: {iters} dummy predict_batch call(s) done")
112
+ except Exception as e:
113
+ print(f"⚠️ warmup skipped: {e}")
114
+
115
+ def _read_model_class_order(self) -> list[str] | None:
116
+ try:
117
+ import ast
118
+
119
+ meta = self.session.get_modelmeta().custom_metadata_map
120
+ names = ast.literal_eval(meta["names"])
121
+ if isinstance(names, dict):
122
+ order = [str(names[i]) for i in sorted(names)]
123
+ else:
124
+ order = [str(n) for n in names]
125
+ except Exception as e:
126
+ print(f"cls order: could not read ONNX names metadata ({e})")
127
+ return None
128
+ if sorted(order) != sorted(self.class_names):
129
+ print(
130
+ f"cls order: ONNX names {order} do not match expected classes "
131
+ f"{self.class_names}; ignoring metadata"
132
+ )
133
+ return None
134
+ return order
135
+
136
+ def __repr__(self) -> str:
137
+ return (
138
+ f"ONNXRuntime(session={type(self.session).__name__}, "
139
+ f"providers={self.session.get_providers()})"
140
+ )
141
+
142
+ @staticmethod
143
+ def _safe_dim(value, default: int) -> int:
144
+ return value if isinstance(value, int) and value > 0 else default
145
+
146
+ def _letterbox(
147
+ self,
148
+ image: ndarray,
149
+ new_shape: tuple[int, int],
150
+ color=(114, 114, 114),
151
+ ) -> tuple[ndarray, float, tuple[float, float]]:
152
+ h, w = image.shape[:2]
153
+ new_w, new_h = new_shape
154
+
155
+ ratio = min(new_w / w, new_h / h)
156
+ resized_w = int(round(w * ratio))
157
+ resized_h = int(round(h * ratio))
158
+
159
+ if (resized_w, resized_h) != (w, h):
160
+ interp = cv2.INTER_CUBIC if ratio > 1.0 else cv2.INTER_LINEAR
161
+ image = cv2.resize(image, (resized_w, resized_h), interpolation=interp)
162
+
163
+ dw = (new_w - resized_w) / 2.0
164
+ dh = (new_h - resized_h) / 2.0
165
+ left = int(round(dw - 0.1))
166
+ right = int(round(dw + 0.1))
167
+ top = int(round(dh - 0.1))
168
+ bottom = int(round(dh + 0.1))
169
+
170
+ padded = cv2.copyMakeBorder(
171
+ image,
172
+ top,
173
+ bottom,
174
+ left,
175
+ right,
176
+ borderType=cv2.BORDER_CONSTANT,
177
+ value=color,
178
+ )
179
+ return padded, ratio, (dw, dh)
180
+
181
+ def _preprocess(
182
+ self, image: ndarray
183
+ ) -> tuple[np.ndarray, float, tuple[float, float], tuple[int, int]]:
184
+ orig_h, orig_w = image.shape[:2]
185
+ img, ratio, pad = self._letterbox(image, (self.input_width, self.input_height))
186
+ blob = cv2.dnn.blobFromImage(img, scalefactor=1.0 / 255.0, swapRB=True)
187
+ return blob, ratio, pad, (orig_w, orig_h)
188
+
189
+ @staticmethod
190
+ def _clip_boxes(boxes: np.ndarray, image_size: tuple[int, int]) -> np.ndarray:
191
+ w, h = image_size
192
+ boxes[:, 0] = np.clip(boxes[:, 0], 0, w - 1)
193
+ boxes[:, 1] = np.clip(boxes[:, 1], 0, h - 1)
194
+ boxes[:, 2] = np.clip(boxes[:, 2], 0, w - 1)
195
+ boxes[:, 3] = np.clip(boxes[:, 3], 0, h - 1)
196
+ return boxes
197
+
198
+ @staticmethod
199
+ def _xywh_to_xyxy(boxes: np.ndarray) -> np.ndarray:
200
+ out = np.empty_like(boxes)
201
+ out[:, 0] = boxes[:, 0] - boxes[:, 2] / 2.0
202
+ out[:, 1] = boxes[:, 1] - boxes[:, 3] / 2.0
203
+ out[:, 2] = boxes[:, 0] + boxes[:, 2] / 2.0
204
+ out[:, 3] = boxes[:, 1] + boxes[:, 3] / 2.0
205
+ return out
206
+
207
+ @staticmethod
208
+ def _hard_nms(
209
+ boxes: np.ndarray, scores: np.ndarray, iou_thresh: float
210
+ ) -> np.ndarray:
211
+ n = len(boxes)
212
+ if n == 0:
213
+ return np.array([], dtype=np.intp)
214
+ order = np.argsort(-scores)
215
+ keep: list[int] = []
216
+ while len(order) > 0:
217
+ i = int(order[0])
218
+ keep.append(i)
219
+ if len(order) == 1:
220
+ break
221
+ rest = order[1:]
222
+ xx1 = np.maximum(boxes[i, 0], boxes[rest, 0])
223
+ yy1 = np.maximum(boxes[i, 1], boxes[rest, 1])
224
+ xx2 = np.minimum(boxes[i, 2], boxes[rest, 2])
225
+ yy2 = np.minimum(boxes[i, 3], boxes[rest, 3])
226
+ inter = np.maximum(0.0, xx2 - xx1) * np.maximum(0.0, yy2 - yy1)
227
+ a_i = max(0.0, boxes[i, 2] - boxes[i, 0]) * max(
228
+ 0.0, boxes[i, 3] - boxes[i, 1]
229
+ )
230
+ a_r = np.maximum(0.0, boxes[rest, 2] - boxes[rest, 0]) * np.maximum(
231
+ 0.0, boxes[rest, 3] - boxes[rest, 1]
232
+ )
233
+ iou = inter / (a_i + a_r - inter + 1e-7)
234
+ order = rest[iou <= iou_thresh]
235
+ return np.array(keep, dtype=np.intp)
236
+
237
+ def _per_class_hard_nms(
238
+ self,
239
+ boxes: np.ndarray,
240
+ scores: np.ndarray,
241
+ cls_ids: np.ndarray,
242
+ iou_thresh: float,
243
+ ) -> np.ndarray:
244
+ if len(boxes) == 0:
245
+ return np.array([], dtype=np.intp)
246
+ all_keep: list[int] = []
247
+ for c in np.unique(cls_ids):
248
+ mask = cls_ids == c
249
+ indices = np.where(mask)[0]
250
+ keep = self._hard_nms(boxes[mask], scores[mask], iou_thresh)
251
+ all_keep.extend(indices[keep].tolist())
252
+ all_keep.sort()
253
+ return np.array(all_keep, dtype=np.intp)
254
+
255
+ def _conf_filter_mask(
256
+ self, scores: np.ndarray, cls_ids: np.ndarray
257
+ ) -> np.ndarray:
258
+ if len(scores) == 0:
259
+ return np.zeros(0, dtype=bool)
260
+ thr = self._conf_thres_array[cls_ids]
261
+ keep = scores >= thr
262
+ for c in np.unique(cls_ids):
263
+ b = float(self._bonus_array[c])
264
+ if b <= 0.0:
265
+ continue
266
+ cm = cls_ids == c
267
+ if keep[cm].any():
268
+ continue
269
+ idx = np.where(cm)[0]
270
+ top = int(idx[int(np.argmax(scores[idx]))])
271
+ if scores[top] >= self._conf_thres_array[c] - b:
272
+ keep[top] = True
273
+ return keep
274
+
275
+ def _filter_sane_boxes(
276
+ self,
277
+ boxes: np.ndarray,
278
+ scores: np.ndarray,
279
+ cls_ids: np.ndarray,
280
+ orig_size: tuple[int, int],
281
+ ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
282
+ if len(boxes) == 0:
283
+ return boxes, scores, cls_ids
284
+ orig_w, orig_h = orig_size
285
+ image_area = float(orig_w * orig_h)
286
+ keep = []
287
+ for i, box in enumerate(boxes):
288
+ x1, y1, x2, y2 = box.tolist()
289
+ bw = x2 - x1
290
+ bh = y2 - y1
291
+ if bw <= 0 or bh <= 0:
292
+ continue
293
+ if bw < self.min_side or bh < self.min_side:
294
+ continue
295
+ area = bw * bh
296
+ if area < self.min_box_area:
297
+ continue
298
+ if area > 0.95 * image_area:
299
+ continue
300
+ ar = max(bw / max(bh, 1e-6), bh / max(bw, 1e-6))
301
+ if ar > self.max_aspect_ratio:
302
+ continue
303
+ keep.append(i)
304
+ if not keep:
305
+ return (
306
+ np.empty((0, 4), dtype=np.float32),
307
+ np.empty((0,), dtype=np.float32),
308
+ np.empty((0,), dtype=np.int32),
309
+ )
310
+ k = np.array(keep, dtype=np.intp)
311
+ return boxes[k], scores[k], cls_ids[k]
312
+
313
+ def _nms_and_cap(
314
+ self,
315
+ boxes: np.ndarray,
316
+ scores: np.ndarray,
317
+ cls_ids: np.ndarray,
318
+ ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
319
+ if len(boxes) > 1:
320
+ keep = self._per_class_hard_nms(boxes, scores, cls_ids, self.iou_thres)
321
+ boxes, scores, cls_ids = boxes[keep], scores[keep], cls_ids[keep]
322
+ if len(scores) > self.max_det:
323
+ top = np.argsort(-scores)[: self.max_det]
324
+ boxes, scores, cls_ids = boxes[top], scores[top], cls_ids[top]
325
+ return boxes, scores, cls_ids
326
+
327
+ @staticmethod
328
+ def _build_results(
329
+ boxes: np.ndarray, scores: np.ndarray, cls_ids: np.ndarray
330
+ ) -> list[BoundingBox]:
331
+ results: list[BoundingBox] = []
332
+ for box, conf, cls_id in zip(boxes, scores, cls_ids):
333
+ x1, y1, x2, y2 = box.tolist()
334
+ if x2 <= x1 or y2 <= y1:
335
+ continue
336
+ results.append(
337
+ BoundingBox(
338
+ x1=int(math.floor(x1)),
339
+ y1=int(math.floor(y1)),
340
+ x2=int(math.ceil(x2)),
341
+ y2=int(math.ceil(y2)),
342
+ cls_id=int(cls_id),
343
+ conf=float(conf),
344
+ )
345
+ )
346
+ return results
347
+
348
+ def _decode_final_dets(
349
+ self,
350
+ preds: np.ndarray,
351
+ ratio: float,
352
+ pad: tuple[float, float],
353
+ orig_size: tuple[int, int],
354
+ ) -> list[BoundingBox]:
355
+ if preds.ndim == 3 and preds.shape[0] == 1:
356
+ preds = preds[0]
357
+ if preds.ndim != 2 or preds.shape[1] < 6:
358
+ raise ValueError(f"Unexpected ONNX final-det output shape: {preds.shape}")
359
+
360
+ boxes = preds[:, :4].astype(np.float32)
361
+ scores = preds[:, 4].astype(np.float32)
362
+ cls_ids = self.cls_remap[preds[:, 5].astype(np.int32)]
363
+
364
+ keep = self._conf_filter_mask(scores, cls_ids)
365
+ boxes, scores, cls_ids = boxes[keep], scores[keep], cls_ids[keep]
366
+ if len(boxes) == 0:
367
+ return []
368
+
369
+ pad_w, pad_h = pad
370
+ boxes[:, [0, 2]] -= pad_w
371
+ boxes[:, [1, 3]] -= pad_h
372
+ boxes /= ratio
373
+ boxes = self._clip_boxes(boxes, orig_size)
374
+
375
+ boxes, scores, cls_ids = self._filter_sane_boxes(
376
+ boxes, scores, cls_ids, orig_size
377
+ )
378
+ if len(boxes) == 0:
379
+ return []
380
+
381
+ boxes, scores, cls_ids = self._nms_and_cap(boxes, scores, cls_ids)
382
+ return self._build_results(boxes, scores, cls_ids)
383
+
384
+ def _decode_raw_yolo(
385
+ self,
386
+ preds: np.ndarray,
387
+ ratio: float,
388
+ pad: tuple[float, float],
389
+ orig_size: tuple[int, int],
390
+ ) -> list[BoundingBox]:
391
+ if preds.ndim != 3 or preds.shape[0] != 1:
392
+ raise ValueError(f"Unexpected raw ONNX output shape: {preds.shape}")
393
+ preds = preds[0]
394
+ if preds.shape[0] <= 16 and preds.shape[1] > preds.shape[0]:
395
+ preds = preds.T
396
+ if preds.ndim != 2 or preds.shape[1] < 5:
397
+ raise ValueError(f"Unexpected raw output shape: {preds.shape}")
398
+
399
+ boxes_xywh = preds[:, :4].astype(np.float32)
400
+ cls_part = preds[:, 4:].astype(np.float32)
401
+ if cls_part.shape[1] == 1:
402
+ scores = cls_part[:, 0]
403
+ cls_ids = np.zeros(len(scores), dtype=np.int32)
404
+ else:
405
+ cls_ids = np.argmax(cls_part, axis=1).astype(np.int32)
406
+ scores = cls_part[np.arange(len(cls_part)), cls_ids]
407
+ cls_ids = self.cls_remap[cls_ids]
408
+
409
+ keep = self._conf_filter_mask(scores, cls_ids)
410
+ boxes_xywh, scores, cls_ids = (
411
+ boxes_xywh[keep],
412
+ scores[keep],
413
+ cls_ids[keep],
414
+ )
415
+ if len(boxes_xywh) == 0:
416
+ return []
417
+ boxes = self._xywh_to_xyxy(boxes_xywh)
418
+
419
+ pad_w, pad_h = pad
420
+ boxes[:, [0, 2]] -= pad_w
421
+ boxes[:, [1, 3]] -= pad_h
422
+ boxes /= ratio
423
+ boxes = self._clip_boxes(boxes, orig_size)
424
+
425
+ boxes, scores, cls_ids = self._filter_sane_boxes(
426
+ boxes, scores, cls_ids, orig_size
427
+ )
428
+ if len(boxes) == 0:
429
+ return []
430
+
431
+ boxes, scores, cls_ids = self._nms_and_cap(boxes, scores, cls_ids)
432
+ return self._build_results(boxes, scores, cls_ids)
433
+
434
+ def _postprocess(
435
+ self,
436
+ output: np.ndarray,
437
+ ratio: float,
438
+ pad: tuple[float, float],
439
+ orig_size: tuple[int, int],
440
+ ) -> list[BoundingBox]:
441
+ if output.ndim == 2 and output.shape[1] >= 6:
442
+ return self._decode_final_dets(output, ratio, pad, orig_size)
443
+ if output.ndim == 3 and output.shape[0] == 1 and output.shape[2] == 6:
444
+ return self._decode_final_dets(output, ratio, pad, orig_size)
445
+ return self._decode_raw_yolo(output, ratio, pad, orig_size)
446
+
447
+ def _predict_single(self, image: np.ndarray) -> list[BoundingBox]:
448
+ if image is None:
449
+ raise ValueError("Input image is None")
450
+ if not isinstance(image, np.ndarray):
451
+ raise TypeError(f"Input is not numpy array: {type(image)}")
452
+ if image.ndim != 3:
453
+ raise ValueError(f"Expected HWC image, got shape={image.shape}")
454
+ if image.shape[0] <= 0 or image.shape[1] <= 0:
455
+ raise ValueError(f"Invalid image shape={image.shape}")
456
+ if image.shape[2] != 3:
457
+ raise ValueError(f"Expected 3 channels, got shape={image.shape}")
458
+ if image.dtype != np.uint8:
459
+ image = image.astype(np.uint8)
460
+
461
+ input_tensor, ratio, pad, orig_size = self._preprocess(image)
462
+ expected = (1, 3, self.input_height, self.input_width)
463
+ if input_tensor.shape != expected:
464
+ raise ValueError(
465
+ f"Bad input tensor shape={input_tensor.shape}, expected={expected}"
466
+ )
467
+
468
+ outputs = self.session.run(
469
+ self.output_names, {self.input_name: input_tensor}
470
+ )
471
+ return self._postprocess(outputs[0], ratio, pad, orig_size)
472
+
473
+ def predict_batch(
474
+ self,
475
+ batch_images: list[ndarray],
476
+ offset: int,
477
+ n_keypoints: int,
478
+ ) -> list[TVFrameResult]:
479
+ results: list[TVFrameResult] = []
480
+ for frame_number_in_batch, image in enumerate(batch_images):
481
+ try:
482
+ boxes = self._predict_single(image)
483
+ except Exception as e:
484
+ print(
485
+ f"⚠️ Inference failed for frame "
486
+ f"{offset + frame_number_in_batch}: {e}"
487
+ )
488
+ boxes = []
489
+ results.append(
490
+ TVFrameResult(
491
+ frame_id=offset + frame_number_in_batch,
492
+ boxes=boxes,
493
+ keypoints=[(0, 0) for _ in range(max(0, int(n_keypoints)))],
494
+ )
495
+ )
496
+ return results
weights.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05114ab243e77753872ad6d4b5c40f40f1831250327728c63183eefbe35bcbae
3
+ size 10604842