ultralytics 8.0.48 Edge TPU fix and Metrics updates (#1171)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: majid nasiri <majnasai@gmail.com>
This commit is contained in:
parent
a58f766f94
commit
74e4c94806
23 changed files with 426 additions and 245 deletions
|
|
@ -3,11 +3,11 @@
|
|||
import requests
|
||||
|
||||
from ultralytics.hub.auth import Auth
|
||||
from ultralytics.hub.session import HubTrainingSession
|
||||
from ultralytics.hub.utils import split_key
|
||||
from ultralytics.hub.session import HUBTrainingSession
|
||||
from ultralytics.hub.utils import PREFIX, split_key
|
||||
from ultralytics.yolo.engine.exporter import EXPORT_FORMATS_LIST
|
||||
from ultralytics.yolo.engine.model import YOLO
|
||||
from ultralytics.yolo.utils import LOGGER, PREFIX, emojis
|
||||
from ultralytics.yolo.utils import LOGGER, emojis
|
||||
|
||||
# Define all export formats
|
||||
EXPORT_FORMATS_HUB = EXPORT_FORMATS_LIST + ['ultralytics_tflite', 'ultralytics_coreml']
|
||||
|
|
@ -18,23 +18,19 @@ def start(key=''):
|
|||
Start training models with Ultralytics HUB. Usage: from ultralytics.hub import start; start('API_KEY')
|
||||
"""
|
||||
auth = Auth(key)
|
||||
try:
|
||||
if not auth.get_state():
|
||||
model_id = request_api_key(auth)
|
||||
else:
|
||||
_, model_id = split_key(key)
|
||||
if not auth.get_state():
|
||||
model_id = request_api_key(auth)
|
||||
else:
|
||||
_, model_id = split_key(key)
|
||||
|
||||
if not model_id:
|
||||
raise ConnectionError(emojis('Connecting with global API key is not currently supported. ❌'))
|
||||
if not model_id:
|
||||
raise ConnectionError(emojis('Connecting with global API key is not currently supported. ❌'))
|
||||
|
||||
session = HubTrainingSession(model_id=model_id, auth=auth)
|
||||
session.check_disk_space()
|
||||
session = HUBTrainingSession(model_id=model_id, auth=auth)
|
||||
session.check_disk_space()
|
||||
|
||||
model = YOLO(session.input_file)
|
||||
session.register_callbacks(model)
|
||||
model.train(**session.train_args)
|
||||
except Exception as e:
|
||||
LOGGER.warning(f'{PREFIX}{e}')
|
||||
model = YOLO(model=session.model_file, session=session)
|
||||
model.train(**session.train_args)
|
||||
|
||||
|
||||
def request_api_key(auth, max_attempts=3):
|
||||
|
|
@ -62,9 +58,9 @@ def reset_model(key=''):
|
|||
r = requests.post('https://api.ultralytics.com/model-reset', json={'apiKey': api_key, 'modelId': model_id})
|
||||
|
||||
if r.status_code == 200:
|
||||
LOGGER.info(f'{PREFIX}model reset successfully')
|
||||
LOGGER.info(f'{PREFIX}Model reset successfully')
|
||||
return
|
||||
LOGGER.warning(f'{PREFIX}model reset failure {r.status_code} {r.reason}')
|
||||
LOGGER.warning(f'{PREFIX}Model reset failure {r.status_code} {r.reason}')
|
||||
|
||||
|
||||
def export_model(key='', format='torchscript'):
|
||||
|
|
@ -76,7 +72,7 @@ def export_model(key='', format='torchscript'):
|
|||
'apiKey': api_key,
|
||||
'modelId': model_id,
|
||||
'format': format})
|
||||
assert (r.status_code == 200), f'{PREFIX}{format} export failure {r.status_code} {r.reason}'
|
||||
assert r.status_code == 200, f'{PREFIX}{format} export failure {r.status_code} {r.reason}'
|
||||
LOGGER.info(f'{PREFIX}{format} export started ✅')
|
||||
|
||||
|
||||
|
|
@ -89,7 +85,7 @@ def get_export(key='', format='torchscript'):
|
|||
'apiKey': api_key,
|
||||
'modelId': model_id,
|
||||
'format': format})
|
||||
assert (r.status_code == 200), f'{PREFIX}{format} get_export failure {r.status_code} {r.reason}'
|
||||
assert r.status_code == 200, f'{PREFIX}{format} get_export failure {r.status_code} {r.reason}'
|
||||
return r.json()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue