File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,10 @@ def _is_pil_image(img: Any) -> bool:
23
23
@torch .jit .unused
24
24
def get_dimensions (img : Any ) -> List [int ]:
25
25
if _is_pil_image (img ):
26
- channels = len (img .getbands ())
26
+ if hasattr (img , "getbands" ):
27
+ channels = len (img .getbands ())
28
+ else :
29
+ channels = img .channels
27
30
width , height = img .size
28
31
return [channels , height , width ]
29
32
raise TypeError (f"Unexpected type { type (img )} " )
@@ -39,7 +42,10 @@ def get_image_size(img: Any) -> List[int]:
39
42
@torch .jit .unused
40
43
def get_image_num_channels (img : Any ) -> int :
41
44
if _is_pil_image (img ):
42
- return len (img .getbands ())
45
+ if hasattr (img , "getbands" ):
46
+ return len (img .getbands ())
47
+ else :
48
+ return img .channels
43
49
raise TypeError (f"Unexpected type { type (img )} " )
44
50
45
51
You can’t perform that action at this time.
0 commit comments