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

Running labelme2coco.py on Rectangle Annotations Sometimes Results in a ValueError in PIL: "y1 must be greater than or equal to y0" #1437

Open
baku1101 opened this issue May 9, 2024 · 0 comments
Labels
bug issue

Comments

@baku1101
Copy link

baku1101 commented May 9, 2024

Provide environment information

❯ which python; python --version; python -m pip list | grep labelme
/home/watanabe/work/YOLOX/pyenv/bin/python
Python 3.12.3
labelme                   5.4.1
labelme2coco              0.2.6

What OS are you using?

Arch Linux on WSL2

Describe the Bug

I've partially identified the cause and have been able to proceed with the execution. However, I'd like to inquire about more detailed investigations and better solutions. Below is the error message I encountered during execution:

❯ ./labelme2coco.py val val4coco --labels class.txt 
Creating dataset: val4coco
Generating dataset from: val/PXL_20211110_054923449.json
Traceback (most recent call last):
  File "/home/watanabe/work/YOLOX/datasets/labelme/examples/instance_segmentation/./labelme2coco.py", line 203, in <module>
    main()
  File "/home/watanabe/work/YOLOX/datasets/labelme/examples/instance_segmentation/./labelme2coco.py", line 121, in main
    mask = labelme.utils.shape_to_mask(img.shape[:2], points, shape_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/watanabe/work/YOLOX/pyenv/lib/python3.12/site-packages/labelme/utils/shape.py", line 30, in shape_to_mask
    draw.rectangle(xy, outline=1, fill=1)
  File "/home/watanabe/work/YOLOX/pyenv/lib/python3.12/site-packages/PIL/ImageDraw.py", line 316, in rectangle
    self.draw.draw_rectangle(xy, fill, 1)
ValueError: y1 must be greater than or equal to y0

It appears that this issue is caused by the addition of assertions in a recent version update of Pillow. In my environment, Pillow version 10.3.0 did not work, but downgrading to version 9.1 resolved the issue and the behavior was as expected.

❯ pip install pillow 
Requirement already satisfied: pillow in /home/watanabe/work/YOLOX/pyenv/lib/python3.12/site-packages (10.3.0)
pip install pillow==9.1 

Expected Behavior

No response

To Reproduce

No response

@baku1101 baku1101 added the bug issue label May 9, 2024
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