瀏覽代碼

Fix `ROOT` as relative path (#5129)

* use os.path.relpath instead of relative_to

* use os.path.relpath instead of relative_to

* Remove os.path from val.py

* Remove os.path from train.py

* Update detect.py import to os

* Update export.py import to os

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
modifyDataloader
Malte Lorbach GitHub 3 年之前
父節點
當前提交
153873e9e4
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 4 個文件被更改,包括 6 次插入4 次删除
  1. +2
    -1
      detect.py
  2. +2
    -1
      export.py
  3. +1
    -1
      train.py
  4. +1
    -1
      val.py

+ 2
- 1
detect.py 查看文件

@@ -7,6 +7,7 @@ Usage:
"""

import argparse
import os
import sys
from pathlib import Path

@@ -19,7 +20,7 @@ FILE = Path(__file__).resolve()
ROOT = FILE.parents[0] # YOLOv5 root directory
if str(ROOT) not in sys.path:
sys.path.append(str(ROOT)) # add ROOT to PATH
ROOT = ROOT.relative_to(Path.cwd()) # relative
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative

from models.experimental import attempt_load
from utils.datasets import LoadImages, LoadStreams

+ 2
- 1
export.py 查看文件

@@ -21,6 +21,7 @@ TensorFlow.js:
"""

import argparse
import os
import subprocess
import sys
import time
@@ -34,7 +35,7 @@ FILE = Path(__file__).resolve()
ROOT = FILE.parents[0] # YOLOv5 root directory
if str(ROOT) not in sys.path:
sys.path.append(str(ROOT)) # add ROOT to PATH
ROOT = ROOT.relative_to(Path.cwd()) # relative
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative

from models.common import Conv
from models.experimental import attempt_load

+ 1
- 1
train.py 查看文件

@@ -30,7 +30,7 @@ FILE = Path(__file__).resolve()
ROOT = FILE.parents[0] # YOLOv5 root directory
if str(ROOT) not in sys.path:
sys.path.append(str(ROOT)) # add ROOT to PATH
ROOT = ROOT.relative_to(Path.cwd()) # relative
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative

import val # for end-of-epoch mAP
from models.experimental import attempt_load

+ 1
- 1
val.py 查看文件

@@ -21,7 +21,7 @@ FILE = Path(__file__).resolve()
ROOT = FILE.parents[0] # YOLOv5 root directory
if str(ROOT) not in sys.path:
sys.path.append(str(ROOT)) # add ROOT to PATH
ROOT = ROOT.relative_to(Path.cwd()) # relative
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative

from models.experimental import attempt_load
from utils.datasets import create_dataloader

Loading…
取消
儲存