Skip to content
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

Fix ROOT as relative path #5129

Merged

Conversation

maltelorbach
Copy link
Contributor

@maltelorbach maltelorbach commented Oct 11, 2021

Make it possible again to run yolo code from outside the yolo root directory.

Closes #5065

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Improvement in path handling across YOLOv5 scripts.

πŸ“Š Key Changes

  • Added the os module import for enhanced path operations.
  • Modified the way the ROOT directory is determined to be relative to the current working directory by using os.path.relpath instead of the previously used Path.relative_to.

🎯 Purpose & Impact

  • Consistency: This change ensures a consistent and robust way of identifying relative paths across different environments and operating systems. 🧭
  • Portability: By using os.path.relpath, there is an increased likelihood of cross-platform compatibility, preventing potential path-related issues when running on different systems. πŸ’»πŸŒ
  • Code Reliability: These changes aim to minimize the risks of path errors that users might face when setting up YOLOv5, leading to a smoother user experience. πŸ‘Œ

This update is mainly behind-the-scenes and should be seamless to users, but it will contribute to making the software more stable and dependable.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘‹ Hello @maltelorbach, thank you for submitting a πŸš€ PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • βœ… Verify your PR is up-to-date with origin/master. If your PR is behind origin/master an automatic GitHub actions rebase may be attempted by including the /rebase command in a comment body, or by running the following code, replacing 'feature' with the name of your local branch:
git remote add upstream https://github.com/ultralytics/yolov5.git
git fetch upstream
git checkout feature  # <----- replace 'feature' with local branch name
git merge upstream/master
git push -u origin -f
  • βœ… Verify all Continuous Integration (CI) checks are passing.
  • βœ… Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." -Bruce Lee

@glenn-jocher glenn-jocher changed the title Fix/root as relative path Fix ROOT as relative path Oct 11, 2021
@glenn-jocher
Copy link
Member

@maltelorbach thanks for the PR! I'm curious if there's any benefit to import os.path instead of import os?

@glenn-jocher glenn-jocher merged commit 153873e into ultralytics:master Oct 11, 2021
@glenn-jocher
Copy link
Member

@maltelorbach PR is merged. Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐

@maltelorbach
Copy link
Contributor Author

@maltelorbach thanks for the PR! I'm curious if there's any benefit to import os.path instead of import os?

Ah, no, not really. It's my tendency to make imports as explicit as possible. But simply import os is just as good imo.

BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
* 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 <glenn.jocher@ultralytics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running from outside yolov5 folder fails since PR #4954
2 participants