From 153873e9e4f42a10bab9e3f2467344b857bc05a2 Mon Sep 17 00:00:00 2001 From: Malte Lorbach <49158835+maltelorbach@users.noreply.github.com> Date: Mon, 11 Oct 2021 18:47:24 +0200 Subject: [PATCH] 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 --- detect.py | 3 ++- export.py | 3 ++- train.py | 2 +- val.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/detect.py b/detect.py index 75ec3ec..346860e 100644 --- a/detect.py +++ b/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 diff --git a/export.py b/export.py index 74aca4b..2aca0f3 100644 --- a/export.py +++ b/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 diff --git a/train.py b/train.py index e8034a6..29ae43e 100644 --- a/train.py +++ b/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 diff --git a/val.py b/val.py index 2cd8eba..2fc5473 100644 --- a/val.py +++ b/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