ultralytics 8.0.161 fix Classify dataset scanning bug (#4515)

This commit is contained in:
Glenn Jocher 2023-08-23 14:19:07 +02:00 committed by GitHub
parent 3c40e7a9fc
commit 67eeb0468d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 18 deletions

View file

@ -39,16 +39,17 @@ def is_url(url, check=True):
return False
def delete_dsstore(path):
def delete_dsstore(path, files_to_delete=('.DS_Store', '__MACOSX')):
"""
Deletes all ".DS_store" files under a specified directory.
Args:
path (str, optional): The directory path where the ".DS_store" files should be deleted.
files_to_delete (tuple): The files to be deleted.
Example:
```python
from ultralytics.data.utils import delete_dsstore
from ultralytics.utils.downloads import delete_dsstore
delete_dsstore('path/to/dir')
```
@ -58,10 +59,11 @@ def delete_dsstore(path):
are hidden system files and can cause issues when transferring files between different operating systems.
"""
# Delete Apple .DS_store files
files = list(Path(path).rglob('.DS_store'))
LOGGER.info(f'Deleting *.DS_store files: {files}')
for f in files:
f.unlink()
for file in files_to_delete:
matches = list(Path(path).rglob(file))
LOGGER.info(f'Deleting {file} files: {matches}')
for f in matches:
f.unlink()
def zip_directory(directory, compress=True, exclude=('.DS_Store', '__MACOSX'), progress=True):