Skip to content

Commit 8779ace

Browse files
pderrengerglenn-jocherUltralyticsAssistant
authored
Fix clean image scan docstring (#50)
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
1 parent d7eb469 commit 8779ace

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

utils/clean_images.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,35 @@
1212
from tqdm import tqdm
1313

1414

15-
def scan(files, max_wh=1920, remove=False, multi_thread=True, tojpg=False, quality=95, workers=8):
15+
def scan(
16+
files,
17+
max_wh=1920,
18+
remove=False,
19+
multi_thread=True,
20+
tojpg=False,
21+
quality=95,
22+
workers=8,
23+
):
1624
"""Scans and processes images by resizing, converting to jpg, and removing duplicates or corrupt files.
1725
1826
Args:
1927
files: list of image files
2028
max_wh: maximum image wh (larger images will be reduced in size)
2129
remove: delete corrupted/duplicate images
30+
multi_thread: process images in parallel
2231
tojpg: replace current image with jpg for smaller size / faster loading
2332
quality: PIL JPG saving quality (0-100)
33+
workers: number of worker threads when multi_thread is enabled
2434
"""
25-
img_formats = [".bmp", ".jpg", ".jpeg", ".png", ".tif", ".tiff", ".dng"] # valid image formats from YOLOv5
35+
img_formats = [
36+
".bmp",
37+
".jpg",
38+
".jpeg",
39+
".png",
40+
".tif",
41+
".tiff",
42+
".dng",
43+
] # valid image formats from YOLOv5
2644

2745
def scan_one_file(f):
2846
try:
@@ -124,5 +142,12 @@ def scan_one_file(f):
124142
files = sorted(glob.iglob(str(dir / "**/*.*"), recursive=True))
125143
assert len(files), f"No files found in {dir}"
126144
print(f"Cleaning {len(files)} images in {dir} ...")
127-
scan(files, max_wh=opt.maxwh, remove=opt.remove, tojpg=opt.tojpg, quality=opt.quality, workers=opt.workers)
145+
scan(
146+
files,
147+
max_wh=opt.maxwh,
148+
remove=opt.remove,
149+
tojpg=opt.tojpg,
150+
quality=opt.quality,
151+
workers=opt.workers,
152+
)
128153
# zip -r data.zip data

0 commit comments

Comments
 (0)