Commit
•
e19f87e
1
Parent(s):
26bfd44
Sidestep `os.path.relpath()` Windows bug (#7158)
Browse files* Sidestep os.path.relpath() Windows bug
os.path.relpath() seems to have a major bug on Windows due to Windows horrible path handling. This fix attempts to sidestep the issue.
```
File "C:\Users\mkokg/.cache\torch\hub\ultralytics_yolov5_master\export.py", line 64, in
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
File "C:\Users\mkokg\AppData\Local\Programs\Python\Python310\lib\ntpath.py", line 718, in relpath
raise ValueError("path is on mount %r, start on mount %r" % (
ValueError: path is on mount 'C:', start on mount 'D:'
```
* Update yolo.py
* Update yolo.py
* Update yolo.py
* Update export.py
- export.py +2 -1
- models/yolo.py +4 -1
export.py
CHANGED
@@ -61,7 +61,8 @@ FILE = Path(__file__).resolve()
|
|
61 |
ROOT = FILE.parents[0] # YOLOv5 root directory
|
62 |
if str(ROOT) not in sys.path:
|
63 |
sys.path.append(str(ROOT)) # add ROOT to PATH
|
64 |
-
|
|
|
65 |
|
66 |
from models.common import Conv
|
67 |
from models.experimental import attempt_load
|
|
|
61 |
ROOT = FILE.parents[0] # YOLOv5 root directory
|
62 |
if str(ROOT) not in sys.path:
|
63 |
sys.path.append(str(ROOT)) # add ROOT to PATH
|
64 |
+
if platform.system() != 'Windows':
|
65 |
+
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
|
66 |
|
67 |
from models.common import Conv
|
68 |
from models.experimental import attempt_load
|
models/yolo.py
CHANGED
@@ -7,6 +7,8 @@ Usage:
|
|
7 |
"""
|
8 |
|
9 |
import argparse
|
|
|
|
|
10 |
import sys
|
11 |
from copy import deepcopy
|
12 |
from pathlib import Path
|
@@ -15,7 +17,8 @@ FILE = Path(__file__).resolve()
|
|
15 |
ROOT = FILE.parents[1] # YOLOv5 root directory
|
16 |
if str(ROOT) not in sys.path:
|
17 |
sys.path.append(str(ROOT)) # add ROOT to PATH
|
18 |
-
|
|
|
19 |
|
20 |
from models.common import *
|
21 |
from models.experimental import *
|
|
|
7 |
"""
|
8 |
|
9 |
import argparse
|
10 |
+
import os
|
11 |
+
import platform
|
12 |
import sys
|
13 |
from copy import deepcopy
|
14 |
from pathlib import Path
|
|
|
17 |
ROOT = FILE.parents[1] # YOLOv5 root directory
|
18 |
if str(ROOT) not in sys.path:
|
19 |
sys.path.append(str(ROOT)) # add ROOT to PATH
|
20 |
+
if platform.system() != 'Windows':
|
21 |
+
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
|
22 |
|
23 |
from models.common import *
|
24 |
from models.experimental import *
|