weiliu89 / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
4.77k stars 1.68k forks source link

Raw image encoder error: Empty JPEG image (DNL not supported) #625

Open albertyou2 opened 7 years ago

albertyou2 commented 7 years ago

Operating system: ubuntu 16.04 Compiler: gcc 5.4.1 CUDA version (if applicable):8.0 CUDNN version (if applicable):5.1 BLAS:openblas opencv:3.1.0

When I training for several iters.This error occurred,log is list as blow :

OpenCV Error: Unknown error code -10 (Raw image encoder error: Empty JPEG image (DNL not supported)) in throwOnEror, file /tmp/binarydeb/ros-kinetic-opencv3-3.1.0/modules/imgcodecs/src/grfmt_base.cpp, line 139 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/binarydeb/ros-kinetic-opencv3-3.1.0/modules/imgcodecs/src/grfmt_base.cpp:139: error: (-10) Raw image encoder error: Empty JPEG image (DNL not supported) in function throwOnEror

Aborted at 1496213994 (unix time) try "date -d @1496213994" if you are using GNU date PC: @ 0x7f56ecb78428 gsignal SIGABRT (@0x3e800007a64) received by PID 31332 (TID 0x7f56c0e0e700) from PID 31332; stack trace: @ 0x7f56ecb784b0 (unknown) @ 0x7f56ecb78428 gsignal @ 0x7f56ecb7a02a abort @ 0x7f56ed1b45cd __gnu_cxx::verbose_terminate_handler() @ 0x7f56ed1b2376 (unknown) @ 0x7f56ed1b23c1 std::terminate() @ 0x7f56ed1b25d9 cxa_throw @ 0x7f56dcfa0b82 cv::error() @ 0x7f56dcfa0d13 cv::error() @ 0x7f56df4c10cb (unknown) @ 0x7f56df4be961 cv::imencode() @ 0x7f56eeab7a91 caffe::EncodeCVMatToDatum() @ 0x7f56ee8eb3dc caffe::DataTransformer<>::CropImage() @ 0x7f56ee8ed431 caffe::DataTransformer<>::CropImage() @ 0x7f56eea4b795 caffe::AnnotatedDataLayer<>::load_batch() @ 0x7f56ee967b7b caffe::BasePrefetchingDataLayer<>::InternalThreadEntry() @ 0x7f56ee85a1f5 caffe::InternalThread::entry() @ 0x7f56ec92e5d5 (unknown) @ 0x7f56ec1e76ba start_thread @ 0x7f56ecc4982d clone @ 0x0 (unknown) Aborted (core dumped)

And I write a script checked the all the training images by using Pillow, there is no broken image . I build opencv 3 from source so that I uncomment this line before make caffe_ssd: OPENCV_VERSION := 3

Should this error cause by the opencv setting of mine?

wangzhenhua2015 commented 7 years ago

The same issue happened. @weiliu89
I checked all the jpg with cv2. The rows and cols are both ok. And there are no zero size files. Below is the ENV: centos 7.2, gcc 4.8.5, cuda 7.5 opencv 2.4.5 OpenCV Error: Unknown error code -10 (Raw image encoder error: Empty JPEG image (DNL not supported)) in throwOnEror, file /builddir/build/BUILD/opencv-2.4.5/modules/highgui/src/grfmt_base.cpp, line 131 terminate called after throwing an instance of 'cv::Exception' what(): /builddir/build/BUILD/opencv-2.4.5/modules/highgui/src/grfmt_base.cpp:131: error: (-10) Raw image encoder error: Empty JPEG image (DNL not supported) in function throwOnEror

Aborted at 1499002738 (unix time) try "date -d @1499002738" if you are using GNU date PC: @ 0x7f0166d9e5f7 GI_raise SIGABRT (@0x5990) received by PID 22928 (TID 0x7f0151423700) from PID 22928; stack trace: @ 0x7f0167139100 (unknown) @ 0x7f0166d9e5f7 __GI_raise @ 0x7f0166d9fce8 GI_abort @ 0x7f01678be9d5 (unknown) @ 0x7f01678bc946 (unknown) @ 0x7f01678bc973 (unknown) @ 0x7f01678bcb93 (unknown) @ 0x7f01687105b3 (unknown) @ 0x7f0168432dd6 (unknown) @ 0x7f016841df57 (unknown) @ 0x7f016fcf95af caffe::EncodeCVMatToDatum() @ 0x7f016fd49019 caffe::DataTransformer<>::CropImage() @ 0x7f016fd4ad2d caffe::DataTransformer<>::CropImage() @ 0x7f016fb903a5 caffe::AnnotatedDataLayer<>::load_batch() @ 0x7f016fba5069 caffe::BasePrefetchingDataLayer<>::InternalThreadEntry() @ 0x7f016fd4bc70 caffe::InternalThread::entry() @ 0x7f0167d7824a (unknown) @ 0x7f0167131dc5 start_thread @ 0x7f0166e5f21d __clone

wangzhenhua2015 commented 7 years ago

Clean the trainval data and filter out the very tiny images(like the width or height is less than 5 pixels) is the key.

I inserted some logs and get below logs. The root cause is my source image size is too small. In function CropImage of data_transformer.cpp, it generate a zero size cropped image.

Below is the log info:

I0703 14:28:54.056056 29006 data_transformer.cpp:826] CropImage(), img is empty: 0 I0703 14:28:54.056143 29006 data_transformer.cpp:828] img.height , width: 2, 1 I0703 14:28:54.056149 29006 data_transformer.cpp:829] (w_off, h_off, width, height): 0, 0, 0,1

Insert below codes after row 361 in src/caffe/data_transformer.cpp:

    // the source image is too small to crop 
    if (crop_img.empty()) {
      cv_img.copyTo(crop_img);
    }