─░├žeri─če ge├ž

Referans i├žin ultralytics/hub/__init__.py

Not

Bu dosya https://github.com/ultralytics/ultralytics/blob/main/ ultralytics/hub/init.py adresinde mevcuttur. Bir sorun tespit ederseniz, l├╝tfen bir ├çekme ─░ste─či ­čŤá´ŞĆ ile katk─▒da bulunarak d├╝zeltmeye yard─▒mc─▒ olun. Te┼čekk├╝rler ­čÖĆ!



ultralytics.hub.login(api_key=None, save=True)

Sa─članan API anahtar─▒n─▒ kullanarak Ultralytics HUB API'sinde oturum a├ž─▒n.

Oturum saklanmaz; kaydedilen AYARLAR veya HUB_API_KEY kullan─▒larak gerekti─činde yeni bir oturum olu┼čturulur kimli─či ba┼čar─▒yla do─črulan─▒rsa ortam de─či┼čkeni.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
api_key str

Kimlik do─črulama i├žin kullan─▒lacak API anahtar─▒. Sa─članmam─▒┼čsa, SETTINGS veya HUB_API_KEY ortam de─či┼čkeninden al─▒nacakt─▒r.

None
save bool

Kimlik do─črulama ba┼čar─▒l─▒ olursa API anahtar─▒n─▒n AYARLAR'a kaydedilip kaydedilmeyece─či.

True

─░ade:

Tip A├ž─▒klama
bool

Kimlik do─črulama ba┼čar─▒l─▒ysa True, aksi takdirde False.

Kaynak kodu ultralytics/hub/__init__.py
def login(api_key: str = None, save=True) -> bool:
    """
    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.

    Args:
        api_key (str, optional): API key to use for authentication.
            If not provided, it will be retrieved from SETTINGS or HUB_API_KEY environment variable.
        save (bool, optional): Whether to save the API key to SETTINGS if authentication is successful.

    Returns:
        (bool): True if authentication is successful, False otherwise.
    """
    checks.check_requirements("hub-sdk>=0.0.6")
    from hub_sdk import HUBClient

    api_key_url = f"{HUB_WEB_ROOT}/settings?tab=api+keys"  # set the redirect URL
    saved_key = SETTINGS.get("api_key")
    active_key = api_key or saved_key
    credentials = {"api_key": active_key} if active_key and active_key != "" else None  # set credentials

    client = HUBClient(credentials)  # initialize HUBClient

    if client.authenticated:
        # Successfully authenticated with HUB

        if save and client.api_key != saved_key:
            SETTINGS.update({"api_key": client.api_key})  # update settings with valid API key

        # Set message based on whether key was provided or retrieved from settings
        log_message = (
            "New authentication successful Ôťů" if client.api_key == api_key or not credentials else "Authenticated Ôťů"
        )
        LOGGER.info(f"{PREFIX}{log_message}")

        return True
    else:
        # Failed to authenticate with HUB
        LOGGER.info(f"{PREFIX}Get API key from {api_key_url} and then run 'yolo hub login API_KEY'")
        return False



ultralytics.hub.logout()

API anahtar─▒n─▒ ayarlar dosyas─▒ndan kald─▒rarak Ultralytics HUB oturumunu kapat─▒n. Tekrar giri┼č yapmak i├žin 'yolo hub login' kullan─▒n.

├ľrnek
from ultralytics import hub

hub.logout()
Kaynak kodu ultralytics/hub/__init__.py
def logout():
    """
    Log out of Ultralytics HUB by removing the API key from the settings file. To log in again, use 'yolo hub login'.

    Example:
        ```python
        from ultralytics import hub

        hub.logout()
        ```
    """
    SETTINGS["api_key"] = ""
    SETTINGS.save()
    LOGGER.info(f"{PREFIX}logged out Ôťů. To log in again, use 'yolo hub login'.")



ultralytics.hub.reset_model(model_id='')

E─čitilmi┼č bir modeli e─čitilmemi┼č bir duruma s─▒f─▒rlay─▒n.

Kaynak kodu ultralytics/hub/__init__.py
def reset_model(model_id=""):
    """Reset a trained model to an untrained state."""
    r = requests.post(f"{HUB_API_ROOT}/model-reset", json={"modelId": model_id}, headers={"x-api-key": Auth().api_key})
    if r.status_code == 200:
        LOGGER.info(f"{PREFIX}Model reset successfully")
        return
    LOGGER.warning(f"{PREFIX}Model reset failure {r.status_code} {r.reason}")



ultralytics.hub.export_fmts_hub()

HUB destekli d─▒┼ča aktarma bi├žimlerinin bir listesini d├Ând├╝r├╝r.

Kaynak kodu ultralytics/hub/__init__.py
def export_fmts_hub():
    """Returns a list of HUB-supported export formats."""
    from ultralytics.engine.exporter import export_formats

    return list(export_formats()["Argument"][1:]) + ["ultralytics_tflite", "ultralytics_coreml"]



ultralytics.hub.export_model(model_id='', format='torchscript')

Bir modeli t├╝m formatlara d─▒┼ča aktar─▒n.

Kaynak kodu ultralytics/hub/__init__.py
def export_model(model_id="", format="torchscript"):
    """Export a model to all formats."""
    assert format in export_fmts_hub(), f"Unsupported export format '{format}', valid formats are {export_fmts_hub()}"
    r = requests.post(
        f"{HUB_API_ROOT}/v1/models/{model_id}/export", json={"format": format}, headers={"x-api-key": Auth().api_key}
    )
    assert r.status_code == 200, f"{PREFIX}{format} export failure {r.status_code} {r.reason}"
    LOGGER.info(f"{PREFIX}{format} export started Ôťů")



ultralytics.hub.get_export(model_id='', format='torchscript')

─░ndirme URL'si ile d─▒┼ča aktar─▒lm─▒┼č bir model s├Âzl├╝─č├╝ al─▒n.

Kaynak kodu ultralytics/hub/__init__.py
def get_export(model_id="", format="torchscript"):
    """Get an exported model dictionary with download URL."""
    assert format in export_fmts_hub(), f"Unsupported export format '{format}', valid formats are {export_fmts_hub()}"
    r = requests.post(
        f"{HUB_API_ROOT}/get-export",
        json={"apiKey": Auth().api_key, "modelId": model_id, "format": format},
        headers={"x-api-key": Auth().api_key},
    )
    assert r.status_code == 200, f"{PREFIX}{format} get_export failure {r.status_code} {r.reason}"
    return r.json()



ultralytics.hub.check_dataset(path, task)

Y├╝klemeden ├Ânce HUB veri k├╝mesi Zip dosyas─▒n─▒ hata kontrol├╝ i├žin i┼člev. Y├╝klenmeden ├Ânce bir veri k├╝mesini hatalara kar┼č─▒ kontrol eder HUB'a. Kullan─▒m ├Ârnekleri a┼ča─č─▒da verilmi┼čtir.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
path str

data.zip dosyas─▒n─▒n yolu (data.yaml dosyas─▒ data.zip dosyas─▒n─▒n i├žinde olacak ┼čekilde).

gerekli
task str

Veri k├╝mesi g├Ârevi. Se├ženekler 'detect', 'segment', 'pose', 'classify', 'obb' ┼čeklindedir.

gerekli
├ľrnek

*.zip dosyalar─▒n─▒ https://github.com/ultralytics/hub/tree/main/example_datasets adresinden indirin ├Ârn. coco8.zip i├žin https://github.com/ultralytics/hub/raw/main/example_datasets/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

Kaynak kodu ultralytics/hub/__init__.py
def check_dataset(path: str, task: str) -> None:
    """
    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.

    Args:
        path (str): Path to data.zip (with data.yaml inside data.zip).
        task (str): Dataset task. Options are 'detect', 'segment', 'pose', 'classify', 'obb'.

    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.
        ```python
        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
        ```
    """
    HUBDatasetStats(path=path, task=task).get_json()
    LOGGER.info(f"Checks completed correctly Ôťů. Upload this dataset to {HUB_WEB_ROOT}/datasets/.")





Created 2023-11-12, Updated 2024-06-02
Authors: glenn-jocher (5), Burhan-Q (1)