@@ -74,23 +74,24 @@ def eval(
74
74
batches : dict = {}
75
75
for image in images_with_ids :
76
76
size = image .image .size
77
+ exif_data = image .image .getexif ()
78
+ orientation = exif_data .get (274 , None )
79
+ # Swap dimensions if the orientation implies a 90° rotation
80
+ if orientation in [5 , 6 , 7 , 8 ]:
81
+ size = (size [1 ], size [0 ])
77
82
batches .setdefault (size , [])
78
83
batches [size ].append (image )
79
84
80
85
if batch_size != 0 :
81
86
self .batch_size = self .batch_size
82
87
while self .batch_size > 0 :
83
88
try :
84
- predictions_in_baches = [
85
- zip (
86
- [image .id for image in imagesInBatch ],
87
- self .pipeline (
88
- [image .image for image in imagesInBatch ],
89
- batch_size = self .batch_size ,
90
- ),
91
- )
92
- for imagesInBatch in batches .values ()
93
- ]
89
+ predictions_in_baches = []
90
+ for imagesInBatch in batches .values ():
91
+ image_ids = [image .id for image in imagesInBatch ]
92
+ image_data = [image .image for image in imagesInBatch ]
93
+ pipeline_output = self .pipeline (image_data , batch_size = self .batch_size )
94
+ predictions_in_baches .append (zip (image_ids , pipeline_output ))
94
95
95
96
predictions_by_image_id = {
96
97
image_id : predictions
0 commit comments