models icon indicating copy to clipboard operation
models copied to clipboard

Corrupt JPEG data: 245 extraneous bytes before marker 0xd9

Open RobinBaumann opened this issue 9 years ago • 46 comments

System information

  • What is the top-level directory of the model you are using: tensorflow/models
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 x64
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 1.2.1
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version: 8.0 / 5.1
  • GPU model and memory: GeForce GTX 1060 6GB
  • Exact command to reproduce: python object_detection\eval.py --logtostderr --checkpoint_dir=C:\Users\TVS\tensorflow\models\out\ --eval_dir=C:\Users\TVS\tensorflow\models\eval\ --pipeline_config_path=C:\Users\TVS\tensorflow\models\object_detection\samples\configs\faster_rcnn_resnet101_pets.config

Describe the problem

When training the Oxford-IIIT Pet Dataset from Scratch (without any finetune checkpoint from COCO set), I get the following error message while running the eval.py script:

Corrupt JPEG data: 245 extraneous bytes before marker 0xd9

I have build the TFRecord files with the script provided in the object detection api, but get the same for an PASCAL VOC like own dataset. I saw some guys having similar problems related to libjpeg, could it be that this error is related to libjpeg?

I am sure that my TFRecords are valid, because I can reconstruct valid Image and Annotation data from it.

Since I did not write any own code I suspect this to be a Bug.

RobinBaumann avatar Aug 11 '17 11:08 RobinBaumann

/CC @tombstone

reedwm avatar Aug 14 '17 19:08 reedwm

I got this error too, I also tested all the images and they were good. Something fishy in the jpeg encoder/decoder ?

Mistobaan avatar Aug 15 '17 21:08 Mistobaan

I got exactly the same the error on Ubuntu 14.04. Have you solved it? @RobinBaumann @Mistobaan

lancejchen avatar Sep 28 '17 08:09 lancejchen

im guessing you all used the generate_tf_record_pet python script to create the record files? if so, i believe this error is caused by setting image/format on 'image/format': dataset_util.bytes_feature

originally it is hardcoded to set to JPEG, however I also had PNGs, so it failed when running on cloud, i switch this dynamically determine which image format. `byte_flag = 'jpeg'

if '.png' in os.path.basename(img_path): byte_flag = 'png'`

seahawks8 avatar Oct 01 '17 05:10 seahawks8

I received this message when I used a Logitech 270, but this doesn't happen with others web cams neither default web cam.

robemorin avatar Oct 09 '17 16:10 robemorin

Make sure when you extract the images from the camera you set the image/format correctly in tf record

seahawks8 avatar Oct 09 '17 17:10 seahawks8

In the pet data set, there is no png files, but only jpeg files. It seems there is still no valid solution from the discussion so far. Any one has any working solutions?

ybsave avatar Oct 30 '17 18:10 ybsave

@ybsave the solution would be to dynamically check the image/format, instead of having `byte_flag = 'jpeg' always set to JPEG

seahawks8 avatar Oct 30 '17 18:10 seahawks8

but if we are referring to only the pet dataset, than no issues. people only experience issues when trying to use with other datasets.

seahawks8 avatar Oct 30 '17 18:10 seahawks8

@ybsave are you having the issue using only the pet data set and their annotations? or did you add/modify any additional annotations or images?

seahawks8 avatar Oct 30 '17 18:10 seahawks8

I have exactly the same issue when working on the pet data set. I have not work on other data sets yet. I use the official demo codes for tfrecord generation, training, and testing. No change at any parts.

It shows: "Corrupt JPEG data: 245 extraneous bytes before marker 0xd9"

After a while, it shows:"RuntimeWarning: invalid value encountered in true_divide num_images_correctly_detected_per_class / num_gt_imgs_per_class)"

ybsave avatar Oct 30 '17 18:10 ybsave

I had the same error with the pet dataset, but it is now working. I first went through the images folder and found that the following files had the .jpg extension but were actually .png files:

egyptian_mau_14, 139, 145, 156, 167, 177, 186, 191; abyssinian_5, 34.

I still had the error after deleting these files and .xml data. After running "jpeginfo" in the images folder I found that chihuahua_121 and beagle_116 were also corrupted, even though they displayed correctly. I deleted these files as well and then rebuilt the tfrecords as explained in the tutorial. The corrupt jpeg error does not display now and everything seems to be working.

ghost avatar Nov 18 '17 07:11 ghost

Removed the above files @gpeier mentioned. Still getting:

Corrupt JPEG data: 240 extraneous bytes before marker 0xd9

tansut avatar Nov 18 '17 10:11 tansut

I also removed the .xmls and the entries in list.txt, test.txt, and trainval.txt. I am very to new to tensorboard so I really can't tell if those were necessary steps. Also, consider installing jpeginfo and running it in the images folder and then checking to see if you missed any corrupt jpegs.

ghost avatar Nov 18 '17 21:11 ghost

I would recommend setting a “try and except” statement on the specific line or whatever means to narrow down what file is causing that issue. Could be caused by JPG instead of JPEG or PNG. How did you acquire the images you are trying to train. Many people who download images from google via some script, always end up with corrupted or bad images with wrong extensions

seahawks8 avatar Nov 18 '17 22:11 seahawks8

Images are from the oxford/pets website as described in the tutorial. I suspect that either some files in the archive were already corrupted or were corrupted during download. Definitely not a fast download considering I only got 500kb/s on a 1000mb/s google fiber connection.

ghost avatar Nov 18 '17 23:11 ghost

I confirmed that there is no download problem, too. It seems that the problem is the pet data set's own problem.

ybsave avatar Nov 20 '17 16:11 ybsave

I got this error when running eval.py on pet_val.record generated by create_pet_tf_record.py

2017-12-07 15:07:10.069475: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-12-07 15:07:10.069513: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-12-07 15:07:10.069523: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-12-07 15:07:10.069531: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. INFO:tensorflow:Restoring parameters from /Users/visethsean/Downloads/models-master/research/object_detection/models/model/train/model.ckpt-0 INFO:tensorflow:Restoring parameters from /Users/visethsean/Downloads/models-master/research/object_detection/models/model/train/model.ckpt-0 Corrupt JPEG data: 240 extraneous bytes before marker 0xd9

Is there anyone already solved the problem?

visethchapman avatar Dec 07 '17 23:12 visethchapman

I am able to reproduce this problem. Can't figure out and waiting for answer.

rzhai avatar Feb 06 '18 15:02 rzhai

during train, I noticed "Corrupt JPEG data: premature end of data segment" in middle of training steps

rzhai avatar Feb 08 '18 18:02 rzhai