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

Allow TIFF (and more) image formats in load_yolo_annotations #1554

Open
2 tasks done
patel-zeel opened this issue Sep 28, 2024 · 1 comment
Open
2 tasks done

Allow TIFF (and more) image formats in load_yolo_annotations #1554

patel-zeel opened this issue Sep 28, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@patel-zeel
Copy link
Contributor

patel-zeel commented Sep 28, 2024

Search before asking

  • I have searched the Supervision issues and found no similar feature requests.

Description

  • Currently, load_yolo_annotations only allows png, jpg, and jpeg file formats. load_yolo_annotations is internally called by sv.DetectionDataset.from_yolo functionality.

directory=images_directory_path, extensions=["jpg", "jpeg", "png"]

  • Ultralytics supports a wide variety of image formats. Copied the following table from their website.
Image Suffix Example Predict Command Reference
.bmp yolo predict source=image.bmp Microsoft BMP File Format
.dng yolo predict source=image.dng Adobe DNG
.jpeg yolo predict source=image.jpeg JPEG
.jpg yolo predict source=image.jpg JPEG
.mpo yolo predict source=image.mpo Multi Picture Object
.png yolo predict source=image.png Portable Network Graphics
.tif yolo predict source=image.tif Tag Image File Format
.tiff yolo predict source=image.tiff Tag Image File Format
.webp yolo predict source=image.webp WebP
.pfm yolo predict source=image.pfm Portable FloatMap
  • Use of TIFF files is common in satellite imagery such as Sentinel-2. One may prefer to preserve the TIFF format over convert it to PNG/JPG because TIFF allows the storage of georeferencing information.
  • I see that the load_yolo_annotations uses cv2.imread to read the image files. OpenCV seems to support many of the Ultralytics-supported formats.

image = cv2.imread(image_path)

Proposals

  • P1: We can expand the hardcoded list of allowed formats.
  • P2: We may choose not to restrict the image format and let it fail later.

Use case

  • Everyone who'd like to use formats other than png, jpg, and jpeg will be able to use this extension.

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@patel-zeel patel-zeel added the enhancement New feature or request label Sep 28, 2024
@patel-zeel patel-zeel changed the title Allow TIFF (and more) formats for images in load_yolo_annotations Allow TIFF (and more) image formats in load_yolo_annotations Sep 28, 2024
@LinasKo
Copy link
Collaborator

LinasKo commented Sep 28, 2024

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, cv2.imread does not raise an error when an image is not loaded - it simply returns None. Reading videos was similarly problematic, as it wouldn't tell of a missing codex. I bet the current code doesn't handle it all that well.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants