labelme icon indicating copy to clipboard operation
labelme copied to clipboard

[BUG] Error opening file : a bytes-like obeject is required, not 'NoneType'

Open Frank1126lin opened this issue 3 years ago • 14 comments

Describe the bug I got this bug when I want to reload the images and labels in my PC. I labeled all the data yesterday, and splite the images files into 3 directories. And after I want to reopen the images and labels dir, I got this error.

Expected behavior After lading the images dir, load the label file automatically, to see the results.

Screenshots See Below.

Desktop (please complete the following information):

  • OS: Windows 10 pro
  • Labelme Version [e.g. 4.5.6]

Frank1126lin avatar Oct 30 '20 02:10 Frank1126lin

images fold divided like this: images

erro image: error

Frank1126lin avatar Oct 30 '20 02:10 Frank1126lin

I got the same error for the image files I annotated a while ago.I was going to fix something on annotations but I can't open them. I generated new annotations to check the output json file content but the contents of the old and new json files are almost exactly the same except the version number in the beginning of the json file, which I believe it should not affect anything. The rest is the same.

ukucukas avatar Nov 17 '20 07:11 ukucukas

Hi there, I am facing the same issue.

Directories are:

  • dataset/imgs/*.png
  • dataset/labels/*.json

I open the image folder and tell labelme to use the labels folder as output folder. I seems that labelme list images and match associated annotation files properly (boxes are checked in the File List pannel). Maybee the problem is in the "open/read files" part.

flocreate avatar Jan 19 '21 09:01 flocreate

I get the same error, when I want to see the previously labelled image. Any known fixes ?

testingshanu avatar Feb 12 '21 17:02 testingshanu

I can see a '\' character in the filepath. That isn't an allowed character in Windows as far as I understand

kradkahaddi avatar Jun 29 '21 10:06 kradkahaddi

is this still not fixed? I got same error.

yellowjs0304 avatar Jan 28 '22 05:01 yellowjs0304

The imageData is null cause the error, which should not have happened in the first place and easy to fix considering the "File List" panel use shows the image not the json

DableUTeeF avatar Mar 14 '22 05:03 DableUTeeF

Along with the actual image isn't the same as imagePath. Which again shouldn't be any problem since the image is there in the "File List".

DableUTeeF avatar Mar 14 '22 06:03 DableUTeeF

            if data["imageData"] is not None:
                imageData = base64.b64decode(data["imageData"])
                if PY2 and QT4:
                    imageData = utils.img_data_to_png_data(imageData)
            else:
                # relative path from label file to relative path from cwd
                imagePath = osp.join(osp.dirname(filename), data["imagePath"])
                imageData = self.load_image_file(imagePath)

if imageData is null, imagePath must be a path relative to json file..... this is not a good design I think....

tenggyut avatar May 17 '22 02:05 tenggyut

if ImagePath begins with a / (it's an absolute path) then os.path.join will return the original imagePath Fixed with https://github.com/wkentaro/labelme/pull/1035

Note this only solves the problem where:

  • annotations and images are in the same directory and the path to the image is an absolute path.

drjasonharrison avatar Jun 14 '22 00:06 drjasonharrison

I dont think the imagePath in json file is very much important, because the dataset may move around....

tenggyut avatar Jun 14 '22 01:06 tenggyut

Hi, I have the same error after changing path and name of the images and labels, how can I figure it out please ?

Sarouch avatar Jan 10 '23 20:01 Sarouch

Maybe "imagePath" is wrong. I convert bmp image to jpg, and forgot to modify imagePath. Everthing is ok when the "imagePath" is modified to ".jpg".

Yonglin5170 avatar Apr 10 '23 10:04 Yonglin5170