-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running from outside yolov5 folder fails since PR #4954 #5065
Comments
👋 Hello @maltelorbach, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at [email protected]. RequirementsPython>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started: $ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
To offer a solution: falling back to os.path.relpath seems to do what is desired. But correct me if I'm missing something. ROOT = ROOT.relative_to(Path.cwd()) we can do ROOT = Path(os.path.relpath(ROOT, Path.cwd())) Only drawback is:
Not sure if that's a case that needs to be covered. In my example above, this would be the output: >>> from pathlib import Path
>>> import os.path
>>> ROOT = Path("/home/user/yolov5")
>>> other = Path("/home/user/other")
>>> ROOT.relative_to(other) # fails
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/malte/.pyenv/versions/3.8.12/lib/python3.8/pathlib.py", line 908, in relative_to
raise ValueError("{!r} does not start with {!r}"
ValueError: '/home/user/yolov5' does not start with '/home/user/other'
>>> os.path.relpath(ROOT, other) # works
'../yolov5' |
@maltelorbach thanks for the bug report! Your fix looks good, can you submit a PR please? |
Of course, see: #5129 |
@maltelorbach great, thank you! |
🐛 Bug
Running any yolov5-script from outside the yolov5 folder fails. This is a regression due to #4954 (which seems ironic because the PR should have make an arbitrary
cwd
possible but instead made it impossible ;) )The attempt to determine a
ROOT
path relative to thecwd
fails if thatcwd
is not a sub-path ofROOT
.To Reproduce
Output:
Expected behavior
The training to start.
Additional context
This worked before #4954
The same PR resulted in these issues: #4973 and #4970 where custom model could not be loaded from torch hub. That issue has been fixed, but not the above mentioned.
The text was updated successfully, but these errors were encountered: