Reference for ultralytics/hub/__init__.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/__init__.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.hub.login
Log in to the Ultralytics HUB API using the provided API key.
The session is not stored; a new session is created when needed using the saved SETTINGS or the HUB_API_KEY environment variable if successfully authenticated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key
|
str
|
API key to use for authentication. If not provided, it will be retrieved from SETTINGS or HUB_API_KEY environment variable. |
None
|
save
|
bool
|
Whether to save the API key to SETTINGS if authentication is successful. |
True
|
Returns:
Type | Description |
---|---|
bool
|
True if authentication is successful, False otherwise. |
Source code in ultralytics/hub/__init__.py
ultralytics.hub.logout
Log out of Ultralytics HUB by removing the API key from the settings file. To log in again, use 'yolo login'.
Source code in ultralytics/hub/__init__.py
ultralytics.hub.reset_model
Reset a trained model to an untrained state.
Source code in ultralytics/hub/__init__.py
ultralytics.hub.export_fmts_hub
Returns a list of HUB-supported export formats.
ultralytics.hub.export_model
Export a model to all formats.
Source code in ultralytics/hub/__init__.py
ultralytics.hub.get_export
Get an exported model dictionary with download URL.
Source code in ultralytics/hub/__init__.py
ultralytics.hub.check_dataset
Function for error-checking HUB dataset Zip file before upload. It checks a dataset for errors before it is uploaded to the HUB. Usage examples are given below.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to data.zip (with data.yaml inside data.zip). |
required |
task
|
str
|
Dataset task. Options are 'detect', 'segment', 'pose', 'classify', 'obb'. |
required |
Example
Download *.zip files from https://github.com/ultralytics/hub/tree/main/example_datasets i.e. https://github.com/ultralytics/hub/raw/main/example_datasets/coco8.zip for coco8.zip.
from ultralytics.hub import check_dataset
check_dataset("path/to/coco8.zip", task="detect") # detect dataset
check_dataset("path/to/coco8-seg.zip", task="segment") # segment dataset
check_dataset("path/to/coco8-pose.zip", task="pose") # pose dataset
check_dataset("path/to/dota8.zip", task="obb") # OBB dataset
check_dataset("path/to/imagenet10.zip", task="classify") # classification dataset