File tree 1 file changed +5
-3
lines changed
torchvision/prototype/transforms 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -80,14 +80,16 @@ def _check_input(
80
80
if value is None :
81
81
return None
82
82
83
- if isinstance (value , float ):
83
+ if isinstance (value , ( int , float ) ):
84
84
if value < 0 :
85
85
raise ValueError (f"If { name } is a single number, it must be non negative." )
86
86
value = [center - value , center + value ]
87
87
if clip_first_on_zero :
88
88
value [0 ] = max (value [0 ], 0.0 )
89
- elif not (isinstance (value , collections .abc .Sequence ) and len (value ) == 2 ):
90
- raise TypeError (f"{ name } should be a single number or a sequence with length 2." )
89
+ elif isinstance (value , collections .abc .Sequence ) and len (value ) == 2 :
90
+ value = [float (v ) for v in value ]
91
+ else :
92
+ raise TypeError (f"{ name } ={ value } should be a single number or a sequence with length 2." )
91
93
92
94
if not bound [0 ] <= value [0 ] <= value [1 ] <= bound [1 ]:
93
95
raise ValueError (f"{ name } values should be between { bound } , but got { value } ." )
You can’t perform that action at this time.
0 commit comments