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 increment_path() with multiple-suffix filenames #5518

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Nov 5, 2021

Fix for #5503

python detect.py --visualize --source path/to/file.suffix1.jpg

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhancing path creation process in Ultralytics' YOLOv5 codebase.

📊 Key Changes

  • Simplified the file/directory creation logic within the increment_path function.
  • Removed unnecessary code that checked for the existence of a directory before creating it.

🎯 Purpose & Impact

  • Eliminates redundant checks, streamline code readability and maintainability. 🧹
  • Provides more robust directory creation with less code, potentially reducing bugs. 🐞➡️🛡️
  • Users can expect a more efficient path incrementation function, indirectly affecting file saving operations. ⏩

Fix for #5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```
@glenn-jocher glenn-jocher self-assigned this Nov 5, 2021
@glenn-jocher glenn-jocher changed the title Fix increment_path() with periods Fix increment_path() with multiple-suffix filename Nov 5, 2021
@glenn-jocher glenn-jocher changed the title Fix increment_path() with multiple-suffix filename Fix increment_path() with multiple-suffix filenames Nov 5, 2021
@glenn-jocher glenn-jocher merged commit 17b5f5b into master Nov 5, 2021
@glenn-jocher glenn-jocher deleted the fix/visualize branch November 5, 2021 10:16
@SpongeBab
Copy link
Contributor

@glenn-jocher It is same as before.

image

Maybe this is the result you want.
But I think we should get, skip the decimal.
desk2-1000-yolov5p2-bs2-16-iou0.65-HardSwish-640
desk2-1000-yolov5p2-bs2-16-iou0.65-HardSwish-6402
desk2-1000-yolov5p2-bs2-16-iou0.65-HardSwish-6403

@glenn-jocher
Copy link
Member Author

@SpongeBab yes it looks like we need an additional fix then with an is_dir() check to control the increment behavior better between files and dirs (it's treating your dirs as files currently).

TODO: Better file vs dir incrementing in incremement_path()

@glenn-jocher glenn-jocher added the TODO High priority items label Nov 5, 2021
@glenn-jocher
Copy link
Member Author

glenn-jocher commented Nov 5, 2021

@SpongeBab #5523 is now merged and should improve incrementing behavior now to correctly handle files vs directories. Please git pull and see if this resolves your directory naming issue please.

print(increment_path('runs'))
print(increment_path('export.py'))
print(increment_path('abc.def.dir'))
print(increment_path('abc.def.file'))

# Returns
# runs2
# export2.py
# abc.def.dir2
# abc.def2.file

@glenn-jocher glenn-jocher removed the TODO High priority items label Nov 5, 2021
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
Fix for ultralytics#5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```
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