From e2bd565f127d05a1e8b5ee30ff5a9eb6751ddd46 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 27 Sep 2021 17:57:29 -0700 Subject: [PATCH 1/2] Update relative `ROOT` logic --- detect.py | 2 +- export.py | 2 +- models/tf.py | 1 + models/yolo.py | 4 +++- train.py | 2 +- val.py | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/detect.py b/detect.py index 75ec3ecc5ff3..4b6ca8eebb48 100644 --- a/detect.py +++ b/detect.py @@ -19,7 +19,7 @@ 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 = ROOT.relative_to(Path.cwd()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative from models.experimental import attempt_load from utils.datasets import LoadImages, LoadStreams diff --git a/export.py b/export.py index 74aca4b6c30a..d400dcede3d7 100644 --- a/export.py +++ b/export.py @@ -34,7 +34,7 @@ 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 = ROOT.relative_to(Path.cwd()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative from models.common import Conv from models.experimental import attempt_load diff --git a/models/tf.py b/models/tf.py index b7d99359c863..dc7b3efee98e 100644 --- a/models/tf.py +++ b/models/tf.py @@ -20,6 +20,7 @@ ROOT = FILE.parents[1] # 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()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative import numpy as np import tensorflow as tf diff --git a/models/yolo.py b/models/yolo.py index a7590c57816c..6045a4a481e2 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -15,11 +15,12 @@ ROOT = FILE.parents[1] # 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()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative from models.common import * from models.experimental import * from utils.autoanchor import check_anchor_order -from utils.general import check_yaml, make_divisible, set_logging +from utils.general import check_yaml, make_divisible, print_args, set_logging from utils.plots import feature_visualization from utils.torch_utils import copy_attr, fuse_conv_and_bn, initialize_weights, model_info, scale_img, \ select_device, time_sync @@ -281,6 +282,7 @@ def parse_model(d, ch): # model_dict, input_channels(3) parser.add_argument('--profile', action='store_true', help='profile model speed') opt = parser.parse_args() opt.cfg = check_yaml(opt.cfg) # check YAML + print_args(FILE.stem, opt) set_logging() device = select_device(opt.device) diff --git a/train.py b/train.py index 39fe1a0cb14b..9823d03163ad 100644 --- a/train.py +++ b/train.py @@ -30,7 +30,7 @@ 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 = ROOT.relative_to(Path.cwd()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative import val # for end-of-epoch mAP from models.experimental import attempt_load diff --git a/val.py b/val.py index 4f0b49ae2ca7..858f42242512 100644 --- a/val.py +++ b/val.py @@ -21,7 +21,7 @@ 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 = ROOT.relative_to(Path.cwd()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative from models.experimental import attempt_load from utils.datasets import create_dataloader From 938b39b3308247e5c46abd76c9dd203467404ec9 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 27 Sep 2021 18:08:47 -0700 Subject: [PATCH 2/2] python 3.9 Path().is_relative_to() removal --- detect.py | 2 +- export.py | 2 +- models/tf.py | 2 +- models/yolo.py | 2 +- train.py | 2 +- val.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/detect.py b/detect.py index 4b6ca8eebb48..75ec3ecc5ff3 100644 --- a/detect.py +++ b/detect.py @@ -19,7 +19,7 @@ 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()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative +ROOT = ROOT.relative_to(Path.cwd()) # relative from models.experimental import attempt_load from utils.datasets import LoadImages, LoadStreams diff --git a/export.py b/export.py index d400dcede3d7..74aca4b6c30a 100644 --- a/export.py +++ b/export.py @@ -34,7 +34,7 @@ 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()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative +ROOT = ROOT.relative_to(Path.cwd()) # relative from models.common import Conv from models.experimental import attempt_load diff --git a/models/tf.py b/models/tf.py index dc7b3efee98e..4c082cb8a15e 100644 --- a/models/tf.py +++ b/models/tf.py @@ -20,7 +20,7 @@ ROOT = FILE.parents[1] # 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()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative +ROOT = ROOT.relative_to(Path.cwd()) # relative import numpy as np import tensorflow as tf diff --git a/models/yolo.py b/models/yolo.py index 6045a4a481e2..b4ec1eda8376 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -15,7 +15,7 @@ ROOT = FILE.parents[1] # 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()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative +ROOT = ROOT.relative_to(Path.cwd()) # relative from models.common import * from models.experimental import * diff --git a/train.py b/train.py index 9823d03163ad..39fe1a0cb14b 100644 --- a/train.py +++ b/train.py @@ -30,7 +30,7 @@ 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()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative +ROOT = ROOT.relative_to(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 858f42242512..4f0b49ae2ca7 100644 --- a/val.py +++ b/val.py @@ -21,7 +21,7 @@ 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()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative +ROOT = ROOT.relative_to(Path.cwd()) # relative from models.experimental import attempt_load from utils.datasets import create_dataloader