1

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).

Red
  • 26,798
  • 7
  • 36
  • 58

1 Answers1

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