Skip to content

Commit 44d979d

Browse files
committed
fix: pin numpy<2.0.0 for CoreML export compatibility
numpy 2.x breaks coremltools PyTorch→MIL converter with: 'only 0-dimensional arrays can be converted to Python scalars' - Pin numpy>=1.24.0,<2.0.0 in requirements.txt and requirements_mps.txt - Add runtime numpy version guard in env_config.py export_model() that detects numpy 2.x and gracefully skips CoreML export - Track homesafe-bench package-lock.json
1 parent f316143 commit 44d979d

File tree

5 files changed

+67
-2
lines changed

5 files changed

+67
-2
lines changed

skills/analysis/homesafe-bench/package-lock.json

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

skills/detection/yolo-detection-2026/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# Install: pip install -r requirements.txt
33

44
ultralytics>=8.3.0 # YOLOv11/v10/v8 inference
5-
numpy>=1.24.0
5+
numpy>=1.24.0,<2.0.0
66
opencv-python-headless>=4.8.0
77
Pillow>=10.0.0

skills/detection/yolo-detection-2026/requirements_mps.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ torch>=2.4.0
44
torchvision>=0.19.0
55
ultralytics>=8.3.0
66
coremltools>=8.0
7-
numpy>=1.24.0
7+
numpy>=1.24.0,<2.0.0
88
opencv-python-headless>=4.8.0
99
Pillow>=10.0.0
1010

skills/detection/yolo-detection-2026/scripts/env_config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,20 @@ def export_model(self, model, model_name: str) -> Optional[Path]:
338338
_log(f"Cached model found: {optimized_path}")
339339
return optimized_path
340340

341+
# Guard: numpy 2.x breaks coremltools PyTorch→MIL converter
342+
# (TypeError: only 0-dimensional arrays can be converted to Python scalars)
343+
if spec.export_format == "coreml":
344+
try:
345+
import numpy as np
346+
np_major = int(np.__version__.split('.')[0])
347+
if np_major >= 2:
348+
_log(f"numpy {np.__version__} detected — CoreML export "
349+
f"requires numpy<2.0.0 (coremltools incompatibility)")
350+
_log("Fix: pip install 'numpy>=1.24,<2.0'")
351+
return None
352+
except Exception:
353+
pass # If numpy check fails, try export anyway
354+
341355
try:
342356
_log(f"Exporting {model_name}.pt → {spec.export_format} "
343357
f"(one-time, may take 30-120s)...")

skills/lib/env_config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,20 @@ def export_model(self, model, model_name: str) -> Optional[Path]:
338338
_log(f"Cached model found: {optimized_path}")
339339
return optimized_path
340340

341+
# Guard: numpy 2.x breaks coremltools PyTorch→MIL converter
342+
# (TypeError: only 0-dimensional arrays can be converted to Python scalars)
343+
if spec.export_format == "coreml":
344+
try:
345+
import numpy as np
346+
np_major = int(np.__version__.split('.')[0])
347+
if np_major >= 2:
348+
_log(f"numpy {np.__version__} detected — CoreML export "
349+
f"requires numpy<2.0.0 (coremltools incompatibility)")
350+
_log("Fix: pip install 'numpy>=1.24,<2.0'")
351+
return None
352+
except Exception:
353+
pass # If numpy check fails, try export anyway
354+
341355
try:
342356
_log(f"Exporting {model_name}.pt → {spec.export_format} "
343357
f"(one-time, may take 30-120s)...")

0 commit comments

Comments
 (0)