Update relative `ROOT` logic (#4955)
Browse files* Update relative `ROOT` logic
* python 3.9 Path().is_relative_to() removal
- models/tf.py +1 -0
- models/yolo.py +3 -1
models/tf.py
CHANGED
@@ -20,6 +20,7 @@ FILE = Path(__file__).resolve()
|
|
20 |
ROOT = FILE.parents[1] # YOLOv5 root directory
|
21 |
if str(ROOT) not in sys.path:
|
22 |
sys.path.append(str(ROOT)) # add ROOT to PATH
|
|
|
23 |
|
24 |
import numpy as np
|
25 |
import tensorflow as tf
|
|
|
20 |
ROOT = FILE.parents[1] # YOLOv5 root directory
|
21 |
if str(ROOT) not in sys.path:
|
22 |
sys.path.append(str(ROOT)) # add ROOT to PATH
|
23 |
+
ROOT = ROOT.relative_to(Path.cwd()) # relative
|
24 |
|
25 |
import numpy as np
|
26 |
import tensorflow as tf
|
models/yolo.py
CHANGED
@@ -15,11 +15,12 @@ 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 |
from models.common import *
|
20 |
from models.experimental import *
|
21 |
from utils.autoanchor import check_anchor_order
|
22 |
-
from utils.general import check_yaml, make_divisible, set_logging
|
23 |
from utils.plots import feature_visualization
|
24 |
from utils.torch_utils import copy_attr, fuse_conv_and_bn, initialize_weights, model_info, scale_img, \
|
25 |
select_device, time_sync
|
@@ -281,6 +282,7 @@ if __name__ == '__main__':
|
|
281 |
parser.add_argument('--profile', action='store_true', help='profile model speed')
|
282 |
opt = parser.parse_args()
|
283 |
opt.cfg = check_yaml(opt.cfg) # check YAML
|
|
|
284 |
set_logging()
|
285 |
device = select_device(opt.device)
|
286 |
|
|
|
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 |
+
ROOT = ROOT.relative_to(Path.cwd()) # relative
|
19 |
|
20 |
from models.common import *
|
21 |
from models.experimental import *
|
22 |
from utils.autoanchor import check_anchor_order
|
23 |
+
from utils.general import check_yaml, make_divisible, print_args, set_logging
|
24 |
from utils.plots import feature_visualization
|
25 |
from utils.torch_utils import copy_attr, fuse_conv_and_bn, initialize_weights, model_info, scale_img, \
|
26 |
select_device, time_sync
|
|
|
282 |
parser.add_argument('--profile', action='store_true', help='profile model speed')
|
283 |
opt = parser.parse_args()
|
284 |
opt.cfg = check_yaml(opt.cfg) # check YAML
|
285 |
+
print_args(FILE.stem, opt)
|
286 |
set_logging()
|
287 |
device = select_device(opt.device)
|
288 |
|