Skip to content

Commit 97aa57b

Browse files
committed
fix(yolo-win-wsl): translate win paths to wsl /mnt/, install libedgetpu into linux fs
1 parent f5b4fd3 commit 97aa57b

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

skills/detection/yolo-detection-2026-coral-tpu-win-wsl/deploy.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ echo.
7676
echo [4/4] Installing Python requirements and Coral TPU drivers...
7777
wsl -e bash -c "cd '%DIR_PATH%' && source wsl_venv/bin/activate && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.9 && python3.9 -m pip install -r requirements.txt"
7878
wsl -u root -e bash -c "cd '%DIR_PATH%' && wget -qO libedgetpu.deb https://packages.cloud.google.com/apt/pool/coral-edgetpu-stable/libedgetpu1-max_16.0_amd64_0ac21f1924dd4b125d5cfc5f6d0e4a5e.deb && dpkg -x libedgetpu.deb ext && cp ext/usr/lib/x86_64-linux-gnu/libedgetpu.so.1.0 libedgetpu.so.1 && rm -rf ext libedgetpu.deb"
79+
:: Install libedgetpu into the real WSL Linux filesystem so dlopen() works (NTFS /mnt/c/ lacks exec bit)
80+
wsl -u root -e bash -c "cp '%DIR_PATH%/libedgetpu.so.1' /usr/local/lib/libedgetpu.so.1 && ldconfig"
7981

8082
echo.
8183
echo.

skills/detection/yolo-detection-2026-coral-tpu-win-wsl/scripts/detect.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@
2525
os.add_dll_directory(str(_LIB_DIR))
2626
os.environ["PATH"] = str(_LIB_DIR) + os.pathsep + os.environ.get("PATH", "")
2727

28+
29+
def _win_to_wsl_path(path: str) -> str:
30+
"""Translate a Windows-style path (C:\\...) to a WSL /mnt/ path when running in WSL."""
31+
import re
32+
if not path:
33+
return path
34+
# Already a Unix path — leave it alone
35+
if path.startswith('/'):
36+
return path
37+
# Windows drive letter: C:\Users\... → /mnt/c/Users/...
38+
match = re.match(r'^([A-Za-z]):[/\\](.*)', path)
39+
if match:
40+
drive = match.group(1).lower()
41+
rest = match.group(2).replace('\\', '/')
42+
return f'/mnt/{drive}/{rest}'
43+
return path
44+
2845
import numpy as np
2946
from PIL import Image
3047

@@ -56,14 +73,17 @@ def _edgetpu_lib_name():
5673
"""Return the platform-specific libedgetpu shared library name."""
5774
import platform
5875
system = platform.system()
59-
60-
# Priority order for checking local delegate libs
61-
candidates = [
62-
Path(__file__).parent.parent / "libedgetpu.so.1", # WSL root
63-
Path(__file__).parent.parent / "lib" / "libedgetpu.so.1", # OSX/Linux layout
64-
]
65-
76+
6677
if system == "Linux":
78+
# Priority 1: system-installed library (copied here by deploy.bat — works on NTFS-free path)
79+
system_lib = Path("/usr/local/lib/libedgetpu.so.1")
80+
if system_lib.exists():
81+
return str(system_lib)
82+
# Priority 2: bundled alongside the skill (may fail if on /mnt/c NTFS mount)
83+
candidates = [
84+
Path(__file__).parent.parent / "libedgetpu.so.1",
85+
Path(__file__).parent.parent / "lib" / "libedgetpu.so.1",
86+
]
6787
for cand in candidates:
6888
if cand.exists():
6989
return str(cand.resolve())
@@ -411,6 +431,8 @@ def detect_frame(self, frame_path: str) -> Tuple[List[Dict[str, Any]], Dict[str,
411431
t0 = time.perf_counter()
412432

413433
try:
434+
# Translate Windows paths to WSL /mnt/ paths when running inside WSL
435+
frame_path = _win_to_wsl_path(frame_path)
414436
img = Image.open(frame_path).convert("RGB")
415437
except Exception as e:
416438
log(f"ERROR reading frame: {e}")

0 commit comments

Comments
 (0)