ultralytics 8.1.34 Inference API robust imgsz checks (#9274)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-03-25 02:00:38 +01:00 committed by GitHub
parent dcb953bc41
commit 5be2ffbd13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 12 deletions

View file

@ -142,6 +142,8 @@ def check_imgsz(imgsz, stride=32, min_dim=1, max_dim=2, floor=0):
imgsz = [imgsz]
elif isinstance(imgsz, (list, tuple)):
imgsz = list(imgsz)
elif isinstance(imgsz, str): # i.e. '640' or '[640,640]'
imgsz = [int(imgsz)] if imgsz.isnumeric() else eval(imgsz)
else:
raise TypeError(
f"'imgsz={imgsz}' is of invalid type {type(imgsz).__name__}. "