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

Add ability to disable EXIF orientations. #5366

Open
Erotemic opened this issue Sep 21, 2024 · 1 comment
Open

Add ability to disable EXIF orientations. #5366

Erotemic opened this issue Sep 21, 2024 · 1 comment
Labels
enhancement Improvements or good new features

Comments

@Erotemic
Copy link

Erotemic commented Sep 21, 2024

🚀 Feature

I would like to be able to specify a config option that disables EXIF orientation corrections.

Motivation & Examples

I have a coco-style dataset where all annotations are stored with respect to the encoded image size on disk. In other words the annotations ignore the EXIF information. I could attempt to modify my dataset to correct for this, but then it will break with all of my tools which will not apply any EXIF transforms. It would be much easier to interoperate with detectron2.

I've been able to work around this on my end by just adding the patch:

diff --git a/detectron2/data/detection_utils.py b/detectron2/data/detection_utils.py
index 8d6173e..4b7bc19 100644
--- a/detectron2/data/detection_utils.py
+++ b/detectron2/data/detection_utils.py
@@ -135,6 +135,7 @@ def _apply_exif_orientation(image):
     Returns:
         (PIL.Image): the PIL image with exif orientation applied, if applicable
     """
+    return image
     if not hasattr(image, "getexif"):
         return image

which simply skips the exif correction. It would be nice if I could just do something like:

cfg = get_cfg()
cfg.merge_from_file(repo_path / 'configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml')
cfg.DATASETS.TRAIN = ('train_imgs5747_1e73d54f',)
cfg.DATASETS.TEST = ()
cfg.DATASETS.IGNORE_EXIF = True

and use detectron2 without modification of the code or dataset.

I could make this PR, but I would like input from maintainers before I do.

@Erotemic Erotemic added the enhancement Improvements or good new features label Sep 21, 2024
@Erotemic
Copy link
Author

Note on my end, I need to think about how to support EXIF data for the case where the user does want to respect it by default. I've opened an issue for that here: https://gitlab.kitware.com/computer-vision/kwcoco/-/issues/15 but it would be nice if detectron2 could also provide the ability to work with both the case where the underlying coco-style dataset registers the images in a way that ignores exif or accounts for exif, and I think the patch would be rather small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements or good new features
Projects
None yet
Development

No branches or pull requests

1 participant