From 7d929f923b041f3660f23485348f8b6d35652c9f Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 11 Sep 2021 22:46:33 +0200 Subject: [PATCH] Replace `path.absolute()` with `path.resolve()` (#4763) --- detect.py | 2 +- export.py | 2 +- hubconf.py | 2 +- models/yolo.py | 2 +- train.py | 2 +- utils/__init__.py | 2 +- utils/datasets.py | 2 +- utils/general.py | 2 +- utils/loggers/wandb/sweep.py | 2 +- utils/loggers/wandb/wandb_utils.py | 2 +- val.py | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/detect.py b/detect.py index 5cb131220e89..b6597c1662f9 100644 --- a/detect.py +++ b/detect.py @@ -15,7 +15,7 @@ import torch import torch.backends.cudnn as cudnn -FILE = Path(__file__).absolute() +FILE = Path(__file__).resolve() sys.path.append(FILE.parents[0].as_posix()) # add yolov5/ to path from models.experimental import attempt_load diff --git a/export.py b/export.py index b9b32b55ac7f..935bdb40bc9b 100644 --- a/export.py +++ b/export.py @@ -15,7 +15,7 @@ import torch.nn as nn from torch.utils.mobile_optimizer import optimize_for_mobile -FILE = Path(__file__).absolute() +FILE = Path(__file__).resolve() sys.path.append(FILE.parents[0].as_posix()) # add yolov5/ to path from models.common import Conv diff --git a/hubconf.py b/hubconf.py index 799c83ec8400..9c5fa63809d1 100644 --- a/hubconf.py +++ b/hubconf.py @@ -33,7 +33,7 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo from utils.downloads import attempt_download from utils.torch_utils import select_device - file = Path(__file__).absolute() + file = Path(__file__).resolve() check_requirements(requirements=file.parent / 'requirements.txt', exclude=('tensorboard', 'thop', 'opencv-python')) set_logging(verbose=verbose) diff --git a/models/yolo.py b/models/yolo.py index 25118a92bb2d..9eddf4a08e49 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -11,7 +11,7 @@ from copy import deepcopy from pathlib import Path -FILE = Path(__file__).absolute() +FILE = Path(__file__).resolve() sys.path.append(FILE.parents[1].as_posix()) # add yolov5/ to path from models.common import * diff --git a/train.py b/train.py index e5410eeeba9f..d243a9cb010f 100644 --- a/train.py +++ b/train.py @@ -26,7 +26,7 @@ from torch.optim import Adam, SGD, lr_scheduler from tqdm import tqdm -FILE = Path(__file__).absolute() +FILE = Path(__file__).resolve() sys.path.append(FILE.parents[0].as_posix()) # add yolov5/ to path import val # for end-of-epoch mAP diff --git a/utils/__init__.py b/utils/__init__.py index 4a61057e8083..74260ad1e5b4 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -4,7 +4,7 @@ # import torch # from PIL import ImageFont # -# FILE = Path(__file__).absolute() +# FILE = Path(__file__).resolve() # ROOT = FILE.parents[1] # yolov5/ dir # if str(ROOT) not in sys.path: # sys.path.append(str(ROOT)) # add ROOT to PATH diff --git a/utils/datasets.py b/utils/datasets.py index 0c6b9b5e2893..cb6ad29e4652 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -156,7 +156,7 @@ def __iter__(self): class LoadImages: # for inference def __init__(self, path, img_size=640, stride=32, auto=True): - p = str(Path(path).absolute()) # os-agnostic absolute path + p = str(Path(path).resolve()) # os-agnostic absolute path if '*' in p: files = sorted(glob.glob(p, recursive=True)) # glob elif os.path.isdir(p): diff --git a/utils/general.py b/utils/general.py index 229b7a7db168..5c3d8d117dc3 100755 --- a/utils/general.py +++ b/utils/general.py @@ -147,7 +147,7 @@ def is_colab(): def is_pip(): # Is file in a pip package? - return 'site-packages' in Path(__file__).absolute().parts + return 'site-packages' in Path(__file__).resolve().parts def is_ascii(s=''): diff --git a/utils/loggers/wandb/sweep.py b/utils/loggers/wandb/sweep.py index 0ca704dd28dd..4d5df5c8e00a 100644 --- a/utils/loggers/wandb/sweep.py +++ b/utils/loggers/wandb/sweep.py @@ -3,7 +3,7 @@ import wandb -FILE = Path(__file__).absolute() +FILE = Path(__file__).resolve() sys.path.append(FILE.parents[3].as_posix()) # add utils/ to path from train import train, parse_opt diff --git a/utils/loggers/wandb/wandb_utils.py b/utils/loggers/wandb/wandb_utils.py index 5d495c70517b..504a518f75ea 100644 --- a/utils/loggers/wandb/wandb_utils.py +++ b/utils/loggers/wandb/wandb_utils.py @@ -9,7 +9,7 @@ import yaml from tqdm import tqdm -FILE = Path(__file__).absolute() +FILE = Path(__file__).resolve() sys.path.append(FILE.parents[3].as_posix()) # add yolov5/ to path from utils.datasets import LoadImagesAndLabels diff --git a/val.py b/val.py index c8f503351ad9..00eb92bb096a 100644 --- a/val.py +++ b/val.py @@ -17,7 +17,7 @@ import torch from tqdm import tqdm -FILE = Path(__file__).absolute() +FILE = Path(__file__).resolve() sys.path.append(FILE.parents[0].as_posix()) # add yolov5/ to path from models.experimental import attempt_load