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

Update detect.py #629

Merged
merged 2 commits into from
Aug 5, 2020
Merged

Update detect.py #629

merged 2 commits into from
Aug 5, 2020

Conversation

hopesala
Copy link
Contributor

@hopesala hopesala commented Aug 5, 2020

update print info for relative path and absolute
otherwise the info below is misleading

Results saved to /workspace//output_path1

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improved file path display in detection results

📊 Key Changes

  • Changed the way the output path is printed to the console after saving detection results.

🎯 Purpose & Impact

  • 🛠️ Purpose: This change simplifies the code for displaying the saved file path and potentially fixes any cross-platform path display issues by using the Path object from Python's pathlib.
  • 🚀 Impact: Users will see a cleaner and more consistent output path in their console, regardless of the operating system they are using. This enhances the user experience by making the results easier to locate and access.

Update print info for relative path and absolute
otherwise the info below is misleading

Results saved to /workspace//output_path
@glenn-jocher
Copy link
Member

@hopesala hi, thanks for the PR. Are you seeking a more absolute path? What OS are you on? Perhaps something like this would be more concise:

    if save_txt or save_img:
        print('Results saved to %s' % Path(out).absolute())  # os-agnostic
        if platform == 'darwin' and not opt.update:  # MacOS
            os.system('open ' + save_path)

@hopesala
Copy link
Contributor Author

hopesala commented Aug 5, 2020

Thanks for replying.
My OS is MacOS, I run the detect.py and if the output path is passed in as "/output_path", it will generate the result in the root path /output_path rather in the workspace/output_path

@hopesala
Copy link
Contributor Author

hopesala commented Aug 5, 2020

print('Results saved to %s' % Path(out).absolute()) # os-agnostic
this is much concise than mine!

@glenn-jocher
Copy link
Member

@hopesala oh, but this line simply prints a path for the user to see on screen. The actual file each image is saved to is save_path. Maybe I'm not understanding though, can you supply a command to reproduce what you are seeing?

@hopesala
Copy link
Contributor Author

hopesala commented Aug 5, 2020

the command is something like
python3 detect.py --source '/input_path' --weights /workspace/last.pt --save-txt --output '/output_path'

@glenn-jocher
Copy link
Member

Oh I see, you are talking about specifying a custom output folder. We should probably simply pass opt.output through an os agnostic absolute path checker like above then right after the argparser.

@glenn-jocher
Copy link
Member

@hopesala ok, I think I'll update the line to make it OS agnostic, this way it should display correctly in all 3 OS's. In regards to abs vs local, I did not find an easy fix that works across all 3 OS's. I think on MacOS you may always need to start a path with a period rather than a slash:

python detect.py --output ./local_dir

@glenn-jocher glenn-jocher merged commit d0d3dd1 into ultralytics:master Aug 5, 2020
@hopesala
Copy link
Contributor Author

hopesala commented Aug 6, 2020

OK,got it, and thank you very much!

@hopesala hopesala deleted the patch-1 branch August 6, 2020 01:01
burglarhobbit pushed a commit to burglarhobbit/yolov5 that referenced this pull request Jan 1, 2021
* Update detect.py

Update print info for relative path and absolute
otherwise the info below is misleading

Results saved to /workspace//output_path

* Update detect.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
KMint1819 pushed a commit to KMint1819/yolov5 that referenced this pull request May 12, 2021
* Update detect.py

Update print info for relative path and absolute
otherwise the info below is misleading

Results saved to /workspace//output_path

* Update detect.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
* Update detect.py

Update print info for relative path and absolute
otherwise the info below is misleading

Results saved to /workspace//output_path

* Update detect.py

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.

2 participants