Commit
•
d808855
1
Parent(s):
bb79e13
Assert non-premature end of JPEG images (#3638)
Browse files* premature end of JPEG images
* PEP8 reformat
Co-authored-by: Glenn Jocher <[email protected]>
- utils/datasets.py +4 -0
utils/datasets.py
CHANGED
@@ -1057,6 +1057,10 @@ def verify_image_label(args):
|
|
1057 |
shape = exif_size(im) # image size
|
1058 |
assert (shape[0] > 9) & (shape[1] > 9), f'image size {shape} <10 pixels'
|
1059 |
assert im.format.lower() in img_formats, f'invalid image format {im.format}'
|
|
|
|
|
|
|
|
|
1060 |
|
1061 |
# verify labels
|
1062 |
segments = [] # instance segments
|
|
|
1057 |
shape = exif_size(im) # image size
|
1058 |
assert (shape[0] > 9) & (shape[1] > 9), f'image size {shape} <10 pixels'
|
1059 |
assert im.format.lower() in img_formats, f'invalid image format {im.format}'
|
1060 |
+
if im.format.lower() in ('jpg', 'jpeg'):
|
1061 |
+
with open(im_file, 'rb') as f:
|
1062 |
+
f.seek(-2, 2)
|
1063 |
+
assert f.read() == b'\xff\xd9', 'corrupted JPEG'
|
1064 |
|
1065 |
# verify labels
|
1066 |
segments = [] # instance segments
|