Skip to content

Commit 06d98bc

Browse files
authored
fix parse_image_size google#1025 from original PR
1 parent affe19b commit 06d98bc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

efficientdet/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Common utils."""
1616
import contextlib
1717
import os
18-
from typing import Text, Tuple, Union
18+
from typing import Text, Tuple, Union, Dict
1919
from absl import logging
2020
import numpy as np
2121
import tensorflow.compat.v1 as tf
@@ -482,11 +482,12 @@ def archive_ckpt(ckpt_eval, ckpt_objective, ckpt_path):
482482
return True
483483

484484

485-
def parse_image_size(image_size: Union[Text, int, Tuple[int, int]]):
485+
def parse_image_size(image_size: Union[Text, int, Tuple[int, int], Dict[int, int]]):
486486
"""Parse the image size and return (height, width).
487487
488488
Args:
489489
image_size: A integer, a tuple (H, W), or a string with HxW format.
490+
or a dict with keys 'height' and 'width' with corresponding int values.
490491
491492
Returns:
492493
A tuple of integer (height, width).
@@ -502,7 +503,10 @@ def parse_image_size(image_size: Union[Text, int, Tuple[int, int]]):
502503

503504
if isinstance(image_size, tuple):
504505
return image_size
505-
506+
507+
if isinstance(image_size, dict):
508+
return (image_size['height'], image_size['width'])
509+
506510
raise ValueError('image_size must be an int, WxH string, or (height, width)'
507511
'tuple. Was %r' % image_size)
508512

0 commit comments

Comments
 (0)