Skip to content

Commit

Permalink
Update verify_image_label() (#3635)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored Jun 16, 2021
1 parent 65f81bf commit 6c0e1d9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,20 +1046,20 @@ def autosplit(path='../coco128', weights=(0.9, 0.1, 0.0), annotated_only=False):
f.write(str(img) + '\n') # add image to txt file


def verify_image_label(params):
def verify_image_label(args):
# Verify one image-label pair
im_file, lb_file, prefix = params
im_file, lb_file, prefix = args
nm, nf, ne, nc = 0, 0, 0, 0 # number missing, found, empty, corrupt
try:
# verify images
im = Image.open(im_file)
im.verify() # PIL verify
shape = exif_size(im) # image size
segments = [] # instance segments
assert (shape[0] > 9) & (shape[1] > 9), f'image size {shape} <10 pixels'
assert im.format.lower() in img_formats, f'invalid image format {im.format}'

# verify labels
segments = [] # instance segments
if os.path.isfile(lb_file):
nf = 1 # label found
with open(lb_file, 'r') as f:
Expand All @@ -1084,7 +1084,7 @@ def verify_image_label(params):
except Exception as e:
nc = 1
logging.info(f'{prefix}WARNING: Ignoring corrupted image and/or label {im_file}: {e}')
return [None] * 4 + [nm, nf, ne, nc]
return [None, None, None, None, nm, nf, ne, nc]


def dataset_stats(path='coco128.yaml', autodownload=False, verbose=False):
Expand Down

0 comments on commit 6c0e1d9

Please sign in to comment.