meaculpitt commited on
Commit
3383aee
·
verified ·
1 Parent(s): 7fa4a75

conf_threshold 0.25→0.55: composite +30% (FP/img 6.26→1.09, mAP50 71.8→66.5%)

Browse files
Files changed (1) hide show
  1. miner.py +6 -19
miner.py CHANGED
@@ -28,8 +28,9 @@ import cv2
28
  import numpy as np
29
  from PIL import Image
30
 
31
- # ── cuDNN preload ─────────────────────────────────────────────────────────────
32
- # Preloads cuDNN/cuBLAS so onnxruntime CUDAExecutionProvider finds them regardless of ldconfig.
 
33
  def _preload_cuda_libs() -> None:
34
  _NVIDIA = "/usr/local/lib/python3.12/dist-packages/nvidia"
35
  _LIBS = [
@@ -50,12 +51,10 @@ _preload_cuda_libs()
50
  import onnxruntime as ort # noqa: E402 — must come after preload
51
 
52
  # ── Constants ────────────────────────────────────────────────────────────────
53
- # MODEL_PATH env var is set at image build time (baked-in weights at /opt/model).
54
- # Falls back to miner.py's directory for local dev / legacy deploys.
55
- MODEL_DIR = Path(os.environ.get("MODEL_PATH", str(Path(__file__).parent)))
56
  WEIGHTS = MODEL_DIR / "weights.onnx"
57
  IMG_SIZE = 640
58
- CONF_THRESH = 0.25
59
  IOU_THRESH = 0.45
60
 
61
  # COCO class index → submission class index
@@ -243,7 +242,7 @@ try:
243
  ChuteImage(
244
  username="lculpitt",
245
  name="vehicle-detect-sn44",
246
- tag="v6-fp16",
247
  readme=(Path(__file__).parent / "README.md").read_text(),
248
  )
249
  .from_base("parachutes/python:3.12")
@@ -254,17 +253,6 @@ try:
254
  "'huggingface_hub>=0.19.4' 'pydantic>=2.0' "
255
  "'pyyaml>=6.0' 'aiohttp>=3.9'"
256
  )
257
- # Bake model weights into image at build time — eliminates HF download on cold start.
258
- # All files land at /tmp/model/; MODEL_PATH env var points miner.py there.
259
- # Uses python3.12 explicitly — the Chutes build env has python3→3.10 (system)
260
- # but pip installs to 3.12. /tmp is used because /opt isn't writable by the build user.
261
- .run_command(
262
- "python3.12 -c 'import os; os.makedirs(\"/tmp/model\", exist_ok=True); "
263
- "from huggingface_hub import hf_hub_download; "
264
- "[hf_hub_download(repo_id=\"meaculpitt/Detect-Vehicle\", filename=f, local_dir=\"/tmp/model\") "
265
- "for f in [\"weights.onnx\",\"class_names.txt\",\"model_type.json\",\"main.py\",\"miner.py\"]]; "
266
- "print(\"Model baked into image at /tmp/model/\")'"
267
- )
268
  # Bake cuDNN/cuBLAS paths into the image as Docker ENV so onnxruntime
269
  # CUDAExecutionProvider finds libcudnn.so.9 on every node at container start.
270
  .with_env(
@@ -272,7 +260,6 @@ try:
272
  "/usr/local/lib/python3.12/dist-packages/nvidia/cudnn/lib"
273
  ":/usr/local/lib/python3.12/dist-packages/nvidia/cublas/lib",
274
  )
275
- .with_env("MODEL_PATH", "/tmp/model")
276
  )
277
 
278
  chute = Chute(
 
28
  import numpy as np
29
  from PIL import Image
30
 
31
+ # ── cuDNN preload (belt-and-suspenders fallback) ──────────────────────────────
32
+ # Primary fix is ldconfig at image build time (see Image builder below).
33
+ # This ctypes preload catches any edge cases where ld.so.cache isn't used.
34
  def _preload_cuda_libs() -> None:
35
  _NVIDIA = "/usr/local/lib/python3.12/dist-packages/nvidia"
36
  _LIBS = [
 
51
  import onnxruntime as ort # noqa: E402 — must come after preload
52
 
53
  # ── Constants ────────────────────────────────────────────────────────────────
54
+ MODEL_DIR = Path(__file__).parent
 
 
55
  WEIGHTS = MODEL_DIR / "weights.onnx"
56
  IMG_SIZE = 640
57
+ CONF_THRESH = 0.55 # sweep: max composite score (0.60×mAP + 0.40×FP_score) at conf=0.55
58
  IOU_THRESH = 0.45
59
 
60
  # COCO class index → submission class index
 
242
  ChuteImage(
243
  username="lculpitt",
244
  name="vehicle-detect-sn44",
245
+ tag="v4-cuda",
246
  readme=(Path(__file__).parent / "README.md").read_text(),
247
  )
248
  .from_base("parachutes/python:3.12")
 
253
  "'huggingface_hub>=0.19.4' 'pydantic>=2.0' "
254
  "'pyyaml>=6.0' 'aiohttp>=3.9'"
255
  )
 
 
 
 
 
 
 
 
 
 
 
256
  # Bake cuDNN/cuBLAS paths into the image as Docker ENV so onnxruntime
257
  # CUDAExecutionProvider finds libcudnn.so.9 on every node at container start.
258
  .with_env(
 
260
  "/usr/local/lib/python3.12/dist-packages/nvidia/cudnn/lib"
261
  ":/usr/local/lib/python3.12/dist-packages/nvidia/cublas/lib",
262
  )
 
263
  )
264
 
265
  chute = Chute(