-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Allow TIFF (and more) image formats in load_yolo_annotations
#1554
Comments
load_yolo_annotations
load_yolo_annotations
Hi @patel-zeel 👋 Thanks for giving a very specific example. That's invaluable to us. Generally - sounds good! What we need to be careful about is silent failures. For example, Next, formats like TIFF may have image layers. We probably want the merged image in those cases. I don't know the peculiaritues of other models. Generally, If you're aware of what's restricting us from having more image formats, I'm happy for us to limit those restrictions. |
Hi @LinasKo,
I see. Is there any reason we are sticking to supervision/supervision/dataset/formats/yolo.py Lines 170 to 173 in 1860fdb
That's true. We may also have to from PIL import Image
# Create and save a multi-image TIFF
img1 = Image.new('RGB', (111, 222), color='red') # 100x100
img2 = Image.new('RGB', (333, 444), color='green') # 200x150
img3 = Image.new('RGB', (555, 666), color='blue') # 300x100
img1.save('/tmp/multi_image.tif', save_all=True, append_images=[img2, img3])
# Read the multi-image TIFF
img = Image.open('/tmp/multi_image.tif')
print(img.size)
# Output: (111, 222) Also, if an image is corrupt, the current code will generate the following error which is uninformative. ---> h, w, _ = image.shape
AttributeError: 'NoneType' object has no attribute 'shape' Overall, if we can replace |
Supervision uses transparent images very infrequently, e.g. when loading images for the I've tested it - calling an object detection model in ultralytics on an image with transparency raises a runtime error.
Agreed. After most imreads, we should check if the image is None and raise a That's my line of thinking - hopefully it clears things up a little. |
I did a small benchmarking around this in this colab.
Okay, in that case, shall we
Do the following changes seem reasonable to you? If we go with
In any case:
|
Interesting details about the shape check. Thanks for carrying out the speed analysis! I'm happy for us to change the shape check to use PIL in yolo dataset case, as long as we leave a short comment explaining why Pil and not cv2 is used there. In most other places, I'd stick to cv2 for consistency, even if it's slower.
"Yes" to everything, but I'd steer us towards raising errors rather than using |
Marking this issue as eligible for Hacktoberfest. |
@LinasKo, feel free to unassign me to open this for the community. I'm in a bit of deadline mode and I'd love to see more people contributing to this repo. |
@patel-zeel thank you for the research and comments you made so far. I am un-assigning from you |
@onuralpszr, no, that's too hasty of a decision. This issue starts from simple foundations but contains a lot of detail, discussions. It can be solved in different ways and at different depths. It is not specific enough for the general community. I want it to stay Patel's domain as he's proven to have a thoughtful approach and handle both the ambiguity & edge cases. @patel-zeel, I'll leave this assigned to you - take as much time as you need! If you don't find a good occasion to solve it by November, I'll be happy to take over 😉 |
Search before asking
Description
load_yolo_annotations
only allowspng,
jpg
, andjpeg
file formats.load_yolo_annotations
is internally called bysv.DetectionDataset.from_yolo
functionality.supervision/supervision/dataset/formats/yolo.py
Line 156 in 1860fdb
load_yolo_annotations
usescv2.imread
to read the image files. OpenCV seems to support many of the Ultralytics-supported formats.supervision/supervision/dataset/formats/yolo.py
Line 170 in 1860fdb
Proposals
Use case
png,
jpg
, andjpeg
will be able to use this extension.Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: