Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error opening file, a bytes-like object is required,not 'NoneType' #1336

Open
tty0013 opened this issue Oct 10, 2023 · 0 comments
Open

Error opening file, a bytes-like object is required,not 'NoneType' #1336

tty0013 opened this issue Oct 10, 2023 · 0 comments
Labels
bug issue

Comments

@tty0013
Copy link

tty0013 commented Oct 10, 2023

Provide environment information

/home/tty0016/software/miniconda3/bin/python
Python 3.10.12
labelme 5.2.1

What OS are you using?

Ubuntu 20.04.4

Describe the Bug

The error occurs when I tried to open previous dataset with labelme:

Error opening file,
a bytes-like object is required,not 'NoneType'

I notice that the following code of labelme links the parent directory path of the json file and the imagePath in the json file to get the relative path from the json file to the image, and load the image:

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)

Because datasets are actually often moved in many scenarios, imagePath in json files is out of date most of the time. I think this is the cause of the above error. Under the current image loading strategy, if you split the dataset, you will no longer be able to open it normally with labelme.

In another data annotation tool, labelImg, you can open a dataset whose directory structure has changed, as long as you open the image directory and label directory in ui, can this be achieved in labelme?

Expected Behavior

By specifying the path to the image and the path to the json label file in the ui interface or on the command line, open a dataset whose directory structure is already different from that of the annotation to view the annotation.

To Reproduce

This error occurs when you try to use labelme to open any dataset whose directory structure has changed.

@tty0013 tty0013 added the bug issue label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue
Projects
None yet
Development

No branches or pull requests

1 participant