File size: 503 Bytes
79914f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os
import sys

build_paths = dict([(os.path.normpath(x[0]), os.path.normpath(x[1])) for x in [
    ("icon.ico", "icon.ico"),
    ("ai-models/2024-11-00/best.pt", "models/best.pt"),
]])

# Function to get the correct path to bundled resources
def resource_path(relative_path: str) -> str:
    relative_path = os.path.normpath(relative_path)
    if hasattr(sys, '_MEIPASS'):
        # Running in a PyInstaller bundle
        return build_paths[relative_path]
    else:
        return relative_path