wkentaro / labelme

Image Polygonal Annotation with Python (polygon, rectangle, circle, line, point and image-level flag annotation).
https://labelme.io
Other
13.2k stars 3.37k forks source link

[BUG] labelme does not read jpg images #675

Closed offchan42 closed 4 years ago

offchan42 commented 4 years ago

Describe the bug In version 4.2.9, it still reads the jpg images. But after I upgraded to >=4.3, it stops reading the jpg images. You can see clearly this issue by trying to open an image and in the list of image types, you won't find the jpg in there.

To Reproduce Steps to reproduce the behavior:

  1. Install labelme 4.3 using pip install labelme==4.3 or any latest version
  2. Try to open the image with Open button.
  3. You will find out that you won't see jpg images.

Expected behavior The jpg images must be seen.

Screenshots This is an example of version 4.2.9 (which have jpg type in the list) image

This is version 4.5.1 (does not have jpg in the list) image

Desktop (please complete the following information):

Additional context Maybe this is an intended feature because it cannot be a mistake that some guys decided to remove jpg and other extensions from the list. But then why do this? It causes a backward compatibility issue.

azibit commented 4 years ago

I am experiencing the same exact issue. My boss has labeled some images and wants me to label the rest. Now I cannot open the files as they are jpg. I guess I must downgrade to get this to work for now

CodePothunter commented 4 years ago

Experiencing the same problem ...

sakibk commented 4 years ago

Experiencing the same problem on mac, it does not want to load .jpg or .heic

wkentaro commented 4 years ago

Can you guys give me the output of below command?

ipython

In [1]: from qtpy import QtGui

In [2]: QtGui.QImageReader.supportedImageFormats()
Out[2]:
[PyQt5.QtCore.QByteArray(b'bmp'),
 PyQt5.QtCore.QByteArray(b'cur'),
 PyQt5.QtCore.QByteArray(b'gif'),
 PyQt5.QtCore.QByteArray(b'heic'),
 PyQt5.QtCore.QByteArray(b'heif'),
 PyQt5.QtCore.QByteArray(b'icns'),
 PyQt5.QtCore.QByteArray(b'ico'),
 PyQt5.QtCore.QByteArray(b'jp2'),
 PyQt5.QtCore.QByteArray(b'jpeg'),
 PyQt5.QtCore.QByteArray(b'jpg'),
 PyQt5.QtCore.QByteArray(b'pbm'),
 PyQt5.QtCore.QByteArray(b'pgm'),
 PyQt5.QtCore.QByteArray(b'png'),
 PyQt5.QtCore.QByteArray(b'ppm'),
 PyQt5.QtCore.QByteArray(b'svg'),
 PyQt5.QtCore.QByteArray(b'svgz'),
 PyQt5.QtCore.QByteArray(b'tga'),
 PyQt5.QtCore.QByteArray(b'tif'),
 PyQt5.QtCore.QByteArray(b'tiff'),
 PyQt5.QtCore.QByteArray(b'wbmp'),
 PyQt5.QtCore.QByteArray(b'webp'),
 PyQt5.QtCore.QByteArray(b'xbm'),
 PyQt5.QtCore.QByteArray(b'xpm')]

on my mac, it gives jpeg as well.

offchan42 commented 4 years ago

@wkentaro image Here it is. Though the labelme version is 4.2.9

sakibk commented 4 years ago

image Here it goes, labelme -V 4.5.0

[ERROR ] label_file:load_image_file:39 - Failed opening image file: /Users/sakibkurtic/Desktop/Horizontal_Traffic_Sign_Train_Data/0420.jpg

This is detailed error I got.

wkentaro commented 4 years ago

@wkentaro image Here it is. Though the labelme version is 4.2.9

So this issue is probably related to your PyQt5 version or something not labelme version. Please check the PyQt5 version to see when jpeg will be listed.

wkentaro commented 4 years ago

image Here it goes, labelme -V 4.5.0

[ERROR ] label_file:load_image_file:39 - Failed opening image file: /Users/sakibkurtic/Desktop/Horizontal_Traffic_Sign_Train_Data/0420.jpg

This is detailed error I got.

There's jpeg, but still you can't open it?

sakibk commented 4 years ago

image Here it goes, labelme -V 4.5.0 [ERROR ] label_file:load_image_file:39 - Failed opening image file: /Users/sakibkurtic/Desktop/Horizontal_Traffic_Sign_Train_Data/0420.jpg This is detailed error I got.

There's jpeg, but still you can't open it?

image Here is the image folder with images. I am able to load images with labelme version 3.5, but any later does not work.

wkentaro commented 4 years ago

@sakibk "does not work" means there's no jpeg listed in the OpenFile dialog? as in here? https://github.com/wkentaro/labelme/issues/675#issue-630578377

wkentaro commented 4 years ago

Here it goes, labelme -V 4.5.0 [ERROR ] label_file:load_image_file:39 - Failed opening image file: /Users/sakibkurtic/Desktop/Horizontal_Traffic_Sign_Train_Data/0420.jpg

If you're talking about this, this seems a different issue, so can you open another issue?

offchan42 commented 4 years ago

@wkentaro image Here it is. Though the labelme version is 4.2.9

So this issue is probably related to your PyQt5 version or something not labelme version. Please check the PyQt5 version to see when jpeg will be listed.

Following is the version of qtpy when labelme is 4.2.9 image I also tried to install labelme 4.5.3, I still see the same qtpy version: 1.9.0

I have also reproduced this problem in another person's PC. So this problem is related to the labelme version.

Note that I don't see jpg in the list from Qtpy but I see jpg in the list of file extension in labelme 4.2.9. So the list of extensions that you saw from qtpy above does not match the list from labelme. I'm suspecting that you are probably not using qtpy in labelme 4.2.9 then later you use it. That's a clue from me. If the list from Qtpy should match with the list from labelme, then we have found the bug.

wkentaro commented 4 years ago

Can you check the version of PyQt5 instead of qtpy? qtpy is just a wrapper.

wkentaro commented 4 years ago

I'm suspecting that you are probably not using qtpy in labelme 4.2.9 then later you use it. That's a clue from me. If the list from Qtpy should match with the list from labelme, then we have found the bug.

Actually, both 4.2.9 and 4.5.3 use qtpy. And the logic in app.openFile was not changed. https://github.com/wkentaro/labelme/blob/0ad853b729ac619692f52d147890a7d51c817b72/labelme/app.py#L1656-L1677 Can you try 4.2.10 as well to see when it happens? Or something below to find where the error happens

git clone https://github.com/wkentaro/labelme
cd labelme
git checkout v4.2.10
pip install -e .
labelme examples/semantic_segmentation  # check if jpeg is read
git checkout HEAD~1  # previous version
labelme examples/semantic_segmentation  # check if jpeg is read
git checkout HEAD~1  # previous version
labelme examples/semantic_segmentation  # check if jpeg is read
...
offchan42 commented 4 years ago

Can you check the version of PyQt5 instead of qtpy? qtpy is just a wrapper.

Here it is:

>>> from PyQt5.Qt import PYQT_VERSION_STR
>>> PYQT_VERSION_STR
'5.9.2'

I am not sure if that's the right way to check the version. I just found it from a thread in Quora.

Anyway, the PyQt5 version is the same when I uninstall labelme 4.2.9 and install 4.5.3

offchan42 commented 4 years ago

image Here's the extension list from 4.2.10. it looks fine

wkentaro commented 4 years ago

Anyway, the PyQt5 version is the same when I uninstall labelme 4.2.9 and install 4.5.3

I see. What is the output of QImageReader.supportedImageFormats() in 4.2.10?

offchan42 commented 4 years ago

Anyway, the PyQt5 version is the same when I uninstall labelme 4.2.9 and install 4.5.3

I see. What is the output of QImageReader.supportedImageFormats() in 4.2.10?

Exact same as 4.2.9 image

wkentaro commented 4 years ago

So there's no jpeg .. strange. I'm not sure why jpeg could be listed in openFile with it.

offchan42 commented 4 years ago

Can you check the difference between 4.3.0 and 4.2.10? Because that's where the problem happens. 4.3.0 does not have jpg.

offchan42 commented 4 years ago

Here is some more info:

wkentaro commented 4 years ago

Can you check the difference between 4.3.0 and 4.2.10? Because that's where the problem happens. 4.3.0 does not have jpg.

I almost know which code change made this happen, but I'm not sure why this could happen. Anyway, can you check this PR? #697

offchan42 commented 4 years ago

Can you check the difference between 4.3.0 and 4.2.10? Because that's where the problem happens. 4.3.0 does not have jpg.

I almost know which code change made this happen, but I'm not sure why this could happen. Anyway, can you check this PR? #697

Yep. That PR shows all the long extension list. It seems to work. I have also checked the previous commit of that PR. It doesn't show the jpg. So it's confirmed 100% that commit is the relevant code.

nanase-123 commented 1 week ago

In labelme V5.5.0,i meet the same question which does not have jpg in the openlist.please help me to analyze the reason.