ultralytics 8.0.187 deprecate ultralytics.yolo usage (#5084)

Co-authored-by: Francisco Javier Gañán <95186237+javierganan99@users.noreply.github.com>
This commit is contained in:
Glenn Jocher 2023-09-26 02:25:35 +02:00 committed by GitHub
parent eb976f5ad2
commit f2ed207571
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 33 additions and 118 deletions

View file

@ -1,7 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
import contextlib
import re
import shutil
import sys
from pathlib import Path
@ -291,19 +290,20 @@ def handle_yolo_settings(args: List[str]) -> None:
def parse_key_value_pair(pair):
"""Parse one 'key=value' pair and return key and value."""
re.sub(r' *= *', '=', pair) # remove spaces around equals sign
k, v = pair.split('=', 1) # split on first '=' sign
k, v = k.strip(), v.strip() # remove spaces
assert v, f"missing '{k}' value"
return k, smart_value(v)
def smart_value(v):
"""Convert a string to an underlying type such as int, float, bool, etc."""
if v.lower() == 'none':
v_lower = v.lower()
if v_lower == 'none':
return None
elif v.lower() == 'true':
elif v_lower == 'true':
return True
elif v.lower() == 'false':
elif v_lower == 'false':
return False
else:
with contextlib.suppress(Exception):