Here, I use opencv imread
read the all the image without any problem while it raise out Corrupt Data: xxx extraeous bytes before marker 0xd9 when training with neural networks. How could I get out these corrupt data(just select out, do not need repair or any other operations).
Asked
Active
Viewed 1,582 times
1

Red
- 26,798
- 7
- 36
- 58

Jianzhong He
- 11
- 3
-
seems relevant: https://stackoverflow.com/q/1401527/5008845 – Miki May 06 '21 at 12:36
1 Answers
1
Since you only want to filter out the corrupt files, you can use a try
- except
block:
for file in files:
try:
img = cv2.imread(file)
except:
pass

Tech Expert Wizard
- 365
- 1
- 6
- 21

Red
- 26,798
- 7
- 36
- 58
-
Thanks. I means it are normal when using the way you suggested, but it gives the information 'Corrupt JPEG data: premature end of data segment' when in the training process. – Jianzhong He May 06 '21 at 12:45
-
@JianzhongHe Perhaps it's a warning? If so you can make it not appear following the answers here: https://stackoverflow.com/q/14463277/13552470 – Red May 06 '21 at 13:06
-
Yes,it is indeed a warning. Now I resolved it by this anwser https://stackoverflow.com/a/26238635/12371459. – Jianzhong He May 07 '21 at 01:59