File size: 1,062 Bytes
c6abe34
 
 
 
 
 
 
 
 
 
 
 
45dcdd6
 
 
 
 
 
 
 
 
 
 
 
 
 
c6abe34
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from app.config import get_settings
import os

settings = get_settings()

# Same logic as pipeline.py
_BACKEND_ROOT = os.path.dirname(os.path.abspath(__file__))

def _resolve_model_path(path: str) -> str:
    """Safely resolve model path relative to backend root."""
    if os.path.isabs(path):
        return path
    
    # Anchor to the backend root (directory containing this script)
    candidate = os.path.abspath(os.path.join(_BACKEND_ROOT, path))
    
    if os.path.exists(candidate):
        return candidate

    # Robust fallback for 'DON'T TOUCH' mangled environments
    if "OKIDI-DONT TOUCH" in candidate:
        healed = candidate.replace("OKIDI-DONT TOUCH", "OKIDI-DON'T TOUCH")
        if os.path.exists(healed):
            return healed
            
    return candidate

res_rim = _resolve_model_path(settings.swish_ball_rim_model)
res_pose = _resolve_model_path(settings.swish_pose_model)

print(f"RES_RIM: {res_rim}")
print(f"Exists: {os.path.exists(res_rim)}")
print(f"RES_POSE: {res_pose}")
print(f"Exists: {os.path.exists(res_pose)}")