wangkuiyi / gotorch

A Go idiomatic binding to the C++ core of PyTorch
MIT License
305 stars 35 forks source link

GoCV decoder skipped some JPEG image in imageloader #348

Closed Yancey1989 closed 3 years ago

Yancey1989 commented 3 years ago

Add one line code in imageloader.go, I found some JPEG images can not be decoded:

--- a/vision/imageloader/imageloader.go
+++ b/vision/imageloader/imageloader.go
@@ -115,6 +115,7 @@ func (p *ImageLoader) read() {
                        break
                }
                if m.Empty() {
+                       log.Printf("skip file: %s\n", hdr.Name)
                        continue
                }
                if p.colorSpace == RGB {
2020/09/21 20:07:18 skip file: ./train/n04523525/n04523525_186.JPEG
2020/09/21 20:07:19 skip file: ./train/n03877845/n03877845_9128.JPEG
2020/09/21 20:07:19 skip file: ./train/n03196217/n03196217_5255.JPEG
2020/09/21 20:07:19 skip file: ./train/n10148035/n10148035_24837.JPEG
2020/09/21 20:07:19 skip file: ./train/n09468604/n09468604_9453.JPEG
2020/09/21 20:07:19 skip file: ./train/n01843383/n01843383_4061.JPEG
2020/09/21 20:07:19 skip file: ./train/n03388549/n03388549_10331.JPEG
2020/09/21 20:07:19 skip file: ./train/n03721384/n03721384_8410.JPEG
QiJune commented 3 years ago

I meet the same issue. Following is a link: https://answers.opencv.org/question/57726/imread-succeeds-to-read-image-but-imdecode-cannot-decode-the-buffer/

QiJune commented 3 years ago

Fixed by #349