facebookresearch / facebookresearch/detectron2

Add ability to disable EXIF orientations.

Open
#5,366 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
34.7k
Forks
7.9k
PR merge metrics
No merged PRs in 30d

Description

## 🚀 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
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:

```python
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.