`ultralytics 8.0.68` HUB zipfile without suffix fix (#1877)

Co-authored-by: Damiano Ferrari <34270884+ferraridamiano@users.noreply.github.com>
single_channel
Glenn Jocher 2 years ago committed by GitHub
parent 2725545090
commit d3f097314f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,13 +62,13 @@ Train a YOLOv8-pose model on the COCO128-pose dataset.
```bash ```bash
# Build a new model from YAML and start training from scratch # Build a new model from YAML and start training from scratch
yolo detect train data=coco128-pose.yaml model=yolov8n-pose.yaml epochs=100 imgsz=640 yolo pose train data=coco128-pose.yaml model=yolov8n-pose.yaml epochs=100 imgsz=640
# Start training from a pretrained *.pt model # Start training from a pretrained *.pt model
yolo detect train data=coco128-pose.yaml model=yolov8n-pose.pt epochs=100 imgsz=640 yolo pose train data=coco128-pose.yaml model=yolov8n-pose.pt epochs=100 imgsz=640
# Build a new model from YAML, transfer pretrained weights to it and start training # Build a new model from YAML, transfer pretrained weights to it and start training
yolo detect train data=coco128-pose.yaml model=yolov8n-pose.yaml pretrained=yolov8n-pose.pt epochs=100 imgsz=640 yolo pose train data=coco128-pose.yaml model=yolov8n-pose.yaml pretrained=yolov8n-pose.pt epochs=100 imgsz=640
``` ```
## Val ## Val

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, GPL-3.0 license # Ultralytics YOLO 🚀, GPL-3.0 license
__version__ = '8.0.67' __version__ = '8.0.68'
from ultralytics.hub import start from ultralytics.hub import start
from ultralytics.yolo.engine.model import YOLO from ultralytics.yolo.engine.model import YOLO

@ -11,7 +11,7 @@ API_KEY_URL = 'https://hub.ultralytics.com/settings?tab=api+keys'
class Auth: class Auth:
id_token = api_key = model_key = False id_token = api_key = model_key = False
def __init__(self, api_key=''): def __init__(self, api_key='', verbose=True):
""" """
Initialize the Auth class with an optional API key. Initialize the Auth class with an optional API key.
@ -29,6 +29,7 @@ class Auth:
# If the provided API key matches the API key in the SETTINGS # If the provided API key matches the API key in the SETTINGS
if self.api_key == SETTINGS.get('api_key'): if self.api_key == SETTINGS.get('api_key'):
# Log that the user is already logged in # Log that the user is already logged in
if verbose:
LOGGER.info(f'{PREFIX}Authenticated ✅') LOGGER.info(f'{PREFIX}Authenticated ✅')
return return
else: else:
@ -46,8 +47,9 @@ class Auth:
if success: if success:
set_settings({'api_key': self.api_key}) set_settings({'api_key': self.api_key})
# Log that the new login was successful # Log that the new login was successful
if verbose:
LOGGER.info(f'{PREFIX}New authentication successful ✅') LOGGER.info(f'{PREFIX}New authentication successful ✅')
else: elif verbose:
LOGGER.info(f'{PREFIX}Retrieve API key from {API_KEY_URL}') LOGGER.info(f'{PREFIX}Retrieve API key from {API_KEY_URL}')
def request_api_key(self, max_attempts=3): def request_api_key(self, max_attempts=3):

@ -58,7 +58,7 @@ class HUBTrainingSession:
raise ValueError(f'Invalid HUBTrainingSession input: {url}') raise ValueError(f'Invalid HUBTrainingSession input: {url}')
# Authorize # Authorize
auth = Auth(key) auth = Auth(key, verbose=False)
self.agent_id = None # identifies which instance is communicating with server self.agent_id = None # identifies which instance is communicating with server
self.model_id = model_id self.model_id = model_id
self.model_url = f'https://hub.ultralytics.com/models/{model_id}' self.model_url = f'https://hub.ultralytics.com/models/{model_id}'

@ -126,10 +126,10 @@ def safe_download(url,
raise ConnectionError(emojis(f'❌ Download failure for {url}. Retry limit reached.')) from e raise ConnectionError(emojis(f'❌ Download failure for {url}. Retry limit reached.')) from e
LOGGER.warning(f'⚠️ Download failure, retrying {i + 1}/{retry} {url}...') LOGGER.warning(f'⚠️ Download failure, retrying {i + 1}/{retry} {url}...')
if unzip and f.exists() and f.suffix in ('.zip', '.tar', '.gz'): if unzip and f.exists() and f.suffix in ('', '.zip', '.tar', '.gz'):
unzip_dir = dir or f.parent # unzip to dir if provided else unzip in place unzip_dir = dir or f.parent # unzip to dir if provided else unzip in place
LOGGER.info(f'Unzipping {f} to {unzip_dir}...') LOGGER.info(f'Unzipping {f} to {unzip_dir}...')
if f.suffix == '.zip': if is_zipfile(f):
unzip_dir = unzip_file(file=f, path=unzip_dir) # unzip unzip_dir = unzip_file(file=f, path=unzip_dir) # unzip
elif f.suffix == '.tar': elif f.suffix == '.tar':
subprocess.run(['tar', 'xf', f, '--directory', unzip_dir], check=True) # unzip subprocess.run(['tar', 'xf', f, '--directory', unzip_dir], check=True) # unzip

Loading…
Cancel
Save