─░├žeri─če ge├ž

Referans i├žin hub_sdk/modules/models.py

Not

Bu dosya https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/modules/models .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 ­čÖĆ!



hub_sdk.modules.models.Models

├ťsler: CRUDClient

CRUD i┼člemleri arac─▒l─▒─č─▒yla Modellerle etkile┼čim i├žin bir istemciyi temsil eden bir s─▒n─▒f. Bu s─▒n─▒f CRUDClient'─▒ geni┼čletir s─▒n─▒f─▒n─▒ olu┼čturur ve Modeller ile ├žal─▒┼čmak i├žin ├Âzel y├Ântemler sa─člar.

Nitelikler:

─░sim Tip A├ž─▒klama
base_endpoint str

API i├žin temel u├ž nokta URL'si, "models" olarak ayarlanm─▒┼čt─▒r.

hub_client ModelUpload

Model y├╝klemeleriyle etkile┼čim i├žin kullan─▒lan bir ModelUpload ├Ârne─či.

id (str, None)

Varsa, modelin benzersiz tan─▒mlay─▒c─▒s─▒.

data dict

Model verilerini depolamak i├žin bir s├Âzl├╝k.

metrics

Al─▒nd─▒ktan sonra mevcutsa, model ├Âl├ž├╝mlerini depolamak i├žin yer tutucu.

Not

'id' ├Âzniteli─či ba┼člatma s─▒ras─▒nda ayarlan─▒r ve bir modeli benzersiz bir ┼čekilde tan─▒mlamak i├žin kullan─▒labilir. 'data' ├Âzniteli─či, API'den al─▒nan model verilerini saklamak i├žin kullan─▒l─▒r.

Kaynak kodu hub_sdk/modules/models.py
class Models(CRUDClient):
    """
    A class representing a client for interacting with Models through CRUD operations. This class extends the CRUDClient
    class and provides specific methods for working with Models.

    Attributes:
        base_endpoint (str): The base endpoint URL for the API, set to "models".
        hub_client (ModelUpload): An instance of ModelUpload used for interacting with model uploads.
        id (str, None): The unique identifier of the model, if available.
        data (dict): A dictionary to store model data.
        metrics: Placeholder for storing model metrics, if available after retrieval.

    Note:
        The 'id' attribute is set during initialization and can be used to uniquely identify a model.
        The 'data' attribute is used to store model data fetched from the API.
    """

    def __init__(self, model_id: Optional[str] = None, headers: Optional[Dict[str, Any]] = None):
        """
        Initialize a Models instance.

        Args:
            model_id (str, optional): The unique identifier of the model.
            headers (dict, optional): Headers to be included in API requests.
        """
        self.base_endpoint = "models"
        super().__init__(self.base_endpoint, "model", headers)
        self.hub_client = ModelUpload(headers)
        self.id = model_id
        self.data = {}
        self.metrics = None
        if model_id:
            self.get_data()

    @staticmethod
    def _reconstruct_data(data: dict) -> dict:
        """
        Reconstruct format of model data supported by ultralytics.

        Args:
            data: dict
        Returns:
            (dict): Reconstructed data format
        """
        if not data:
            return data

        data["config"] = {
            "batchSize": data.pop("batch_size", None),
            "epochs": data.pop("epochs", None),
            "imageSize": data.pop("imgsz", None),
            "patience": data.pop("patience", None),
            "device": data.pop("device", None),
            "cache": data.pop("cache", None),
        }

        return data

    def get_data(self) -> None:
        """
        Retrieves data for the current model instance.

        If a valid model ID has been set, it sends a request to fetch the model data and stores it in the instance.
        If no model ID has been set, it logs an error message.

        Returns:
            (None): The method does not return a value.
        """
        if not self.id:
            self.logger.error("No model id has been set. Update the model id or create a model.")
            return

        try:
            response = super().read(self.id)

            if response is None:
                self.logger.error(f"Received no response from the server for model ID: {self.id}")
                return

            # Check if the response has a .json() method (it should if it's a response object)
            if not hasattr(response, "json"):
                self.logger.error(f"Invalid response object received for model ID: {self.id}")
                return

            resp_data = response.json()
            if resp_data is None:
                self.logger.error(f"No data received in the response for model ID: {self.id}")
                return

            data = resp_data.get("data", {})
            self.data = self._reconstruct_data(data)
            self.logger.debug(f"Model data retrieved for ID: {self.id}")

        except Exception as e:
            self.logger.error(f"An error occurred while retrieving data for model ID: {self.id}, {str(e)}")

    def create_model(self, model_data: dict) -> None:
        """
        Creates a new model with the provided data and sets the model ID for the current instance.

        Args:
            model_data (dict): A dictionary containing the data for creating the model.

        Returns:
            (None): The method does not return a value.
        """
        try:
            response = super().create(model_data)

            if response is None:
                self.logger.error("Received no response from the server while creating the model.")
                return

            # Ensuring the response object has the .json() method
            if not hasattr(response, "json"):
                self.logger.error("Invalid response object received while creating the model.")
                return

            resp_data = response.json()
            if resp_data is None:
                self.logger.error("No data received in the response while creating the model.")
                return

            self.id = resp_data.get("data", {}).get("id")

            # Check if the ID was successfully retrieved
            if not self.id:
                self.logger.error("Model ID not found in the response data.")
                return

            self.get_data()

        except Exception as e:
            self.logger.error(f"An error occurred while creating the model: {str(e)}")

    def is_resumable(self) -> bool:
        """
        Check if the model training can be resumed.

        Returns:
            (bool): True if resumable, False otherwise.
        """
        return self.data.get("has_last_weights", False)

    def has_best_weights(self) -> bool:
        """
        Check if the model has best weights saved.

        Returns:
            (bool): True if best weights available, False otherwise.
        """
        return self.data.get("has_best_weights", False)

    def is_pretrained(self) -> bool:
        """
        Check if the model is pretrained.

        Returns:
            (bool): True if pretrained, False otherwise.
        """
        return self.data.get("is_pretrained", False)

    def is_trained(self) -> bool:
        """
        Check if the model is trained.

        Returns:
            (bool): True if trained, False otherwise.
        """
        return self.data.get("status") == "trained"

    def is_custom(self) -> bool:
        """
        Check if the model is custom.

        Returns:
            (bool): True if custom, False otherwise.
        """
        return self.data.get("is_custom", False)

    def get_architecture(self) -> Optional[str]:
        """
        Get the architecture name of the model.

        Returns:
            (Optional[str]): The architecture name followed by '.yaml' or None if not available.
        """
        return self.data.get("cfg")

    def get_dataset_url(self) -> Optional[str]:
        """
        Get the dataset URL associated with the model.

        Returns:
            (Optional[str]): The URL of the dataset or None if not available.
        """
        return self.data.get("data")

    def get_weights_url(self, weight: str = "best") -> Optional[str]:
        """
        Get the URL of the model weights.

        Args:
            weight (str, optional): Type of weights to retrieve.

        Returns:
            (Optional[str]): The URL of the specified weights or None if not available.
        """
        if weight == "last":
            return self.data.get("resume")

        return self.data.get("weights")

    def delete(self, hard: bool = False) -> Optional[Response]:
        """
        Delete the model resource represented by this instance.

        Args:
            hard (bool, optional): If True, perform a hard (permanent) delete.

        Note:
            The 'hard' parameter determines whether to perform a soft delete (default) or a hard delete.
            In a soft delete, the model might be marked as deleted but retained in the system.
            In a hard delete, the model is permanently removed from the system.

        Returns:
            (Optional[Response]): Response object from the delete request, or None if delete fails.
        """
        return super().delete(self.id, hard)

    def update(self, data: dict) -> Optional[Response]:
        """
        Update the model resource represented by this instance.

        Args:
            data (dict): The updated data for the model resource.

        Returns:
            (Optional[Response]): Response object from the update request, or None if update fails.
        """
        return super().update(self.id, data)

    def get_metrics(self) -> Optional[List[Dict[str, Any]]]:
        """
        Get metrics to of model.

        Returns:
            (list(dict), optional): The list of metrics objects, or None if it fails.
        """
        if self.metrics:
            return self.metrics

        endpoint = f"{HUB_API_ROOT}/v1/{self.base_endpoint}/{self.id}/metrics"
        try:
            results = self.get(endpoint)
            self.metrics = results.json().get("data")
            return self.metrics
        except Exception as e:
            self.logger.error(f"Model Metrics not found: {e}")

    def upload_model(
        self,
        epoch: int,
        weights: str,
        is_best: bool = False,
        map: float = 0.0,
        final: bool = False,
    ) -> Optional[Response]:
        """
        Upload a model checkpoint to Ultralytics HUB.

        Args:
            epoch (int): The current training epoch.
            weights (str): Path to the model weights file.
            is_best (bool): Indicates if the current model is the best one so far.
            map (float): Mean average precision of the model.
            final (bool): Indicates if the model is the final model after training.

        Returns:
            (Optional[Response]): Response object from the upload request, or None if upload fails.
        """
        return self.hub_client.upload_model(self.id, epoch, weights, is_best=is_best, map=map, final=final)

    def upload_metrics(self, metrics: dict) -> Optional[Response]:
        """
        Upload model metrics to Ultralytics HUB.

        Args:
            metrics (dict):

        Returns:
            (Optional[Response]): Response object from the upload metrics request, or None if it fails.
        """
        return self.hub_client.upload_metrics(self.id, metrics)  # response

    def start_heartbeat(self, interval: int = 60):
        """
        Starts sending heartbeat signals to a remote hub server.

        This method initiates the sending of heartbeat signals to a hub server
        in order to indicate the continued availability and health of the client.

        Args:
            interval (int): The time interval, in seconds, between consecutive heartbeats.

        Returns:
            (None): The method does not return a value.

        Note:
            Heartbeats are essential for maintaining a connection with the hub server
            and ensuring that the client remains active and responsive.
        """
        self.hub_client._register_signal_handlers()
        self.hub_client._start_heartbeats(self.id, interval)

    def stop_heartbeat(self) -> None:
        """
        Stops sending heartbeat signals to a remote hub server.

        This method terminates the sending of heartbeat signals to the hub server,
        effectively signaling that the client is no longer available or active.

        Returns:
            (None): The method does not return a value.

        Note:
            Stopping heartbeats should be done carefully, as it may result in the hub server
            considering the client as disconnected or unavailable.
        """
        self.hub_client._stop_heartbeats()

    def export(self, format: str) -> Optional[Response]:
        """
        Export to Ultralytics HUB.

        Args: format (str): Export format here. Here are supported export [formats](
        https://docs.ultralytics.com/modes/export/#export-formats)

        Returns:
            (Optional[Response]): Response object from the export request, or None if export fails.
        """
        return self.hub_client.export(self.id, format)  # response

    def predict(self, image: str, config: Dict[str, Any]) -> Optional[Response]:
        """
        Predict to Ultralytics HUB.

        Args:
            image (str): The path to the image file.
            config (dict): A configuration for the prediction (JSON).

        Returns:
            (Optional[Response]): Response object from the predict request, or None if upload fails.
        """
        return self.hub_client.predict(self.id, image, config)  # response

__init__(model_id=None, headers=None)

Bir Models ├Ârne─čini ba┼člat─▒n.

Parametreler:

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

Modelin benzersiz tan─▒mlay─▒c─▒s─▒.

None
headers dict

API isteklerine dahil edilecek ba┼čl─▒klar.

None
Kaynak kodu hub_sdk/modules/models.py
def __init__(self, model_id: Optional[str] = None, headers: Optional[Dict[str, Any]] = None):
    """
    Initialize a Models instance.

    Args:
        model_id (str, optional): The unique identifier of the model.
        headers (dict, optional): Headers to be included in API requests.
    """
    self.base_endpoint = "models"
    super().__init__(self.base_endpoint, "model", headers)
    self.hub_client = ModelUpload(headers)
    self.id = model_id
    self.data = {}
    self.metrics = None
    if model_id:
        self.get_data()

create_model(model_data)

Sa─članan verilerle yeni bir model olu┼čturur ve ge├žerli ├Ârnek i├žin model kimli─čini ayarlar.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
model_data dict

Modeli olu┼čturmak i├žin verileri i├žeren bir s├Âzl├╝k.

gerekli

─░ade:

Tip A├ž─▒klama
None

Y├Ântem bir de─čer d├Ând├╝rmez.

Kaynak kodu hub_sdk/modules/models.py
def create_model(self, model_data: dict) -> None:
    """
    Creates a new model with the provided data and sets the model ID for the current instance.

    Args:
        model_data (dict): A dictionary containing the data for creating the model.

    Returns:
        (None): The method does not return a value.
    """
    try:
        response = super().create(model_data)

        if response is None:
            self.logger.error("Received no response from the server while creating the model.")
            return

        # Ensuring the response object has the .json() method
        if not hasattr(response, "json"):
            self.logger.error("Invalid response object received while creating the model.")
            return

        resp_data = response.json()
        if resp_data is None:
            self.logger.error("No data received in the response while creating the model.")
            return

        self.id = resp_data.get("data", {}).get("id")

        # Check if the ID was successfully retrieved
        if not self.id:
            self.logger.error("Model ID not found in the response data.")
            return

        self.get_data()

    except Exception as e:
        self.logger.error(f"An error occurred while creating the model: {str(e)}")

delete(hard=False)

Bu ├Ârnek taraf─▒ndan temsil edilen model kayna─č─▒n─▒ siler.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
hard bool

Do─čru ise, sert (kal─▒c─▒) bir silme i┼člemi ger├žekle┼čtirin.

False
Not

'hard' parametresi yumu┼čak silme mi (varsay─▒lan) yoksa sert silme mi yap─▒laca─č─▒n─▒ belirler. Yumu┼čak silme i┼čleminde, model silinmi┼č olarak i┼čaretlenebilir ancak sistemde tutulabilir. Sert silme i┼čleminde model sistemden kal─▒c─▒ olarak kald─▒r─▒l─▒r.

─░ade:

Tip A├ž─▒klama
Optional[Response]

Silme iste─činden gelen yan─▒t nesnesi veya silme ba┼čar─▒s─▒z olursa Yok.

Kaynak kodu hub_sdk/modules/models.py
def delete(self, hard: bool = False) -> Optional[Response]:
    """
    Delete the model resource represented by this instance.

    Args:
        hard (bool, optional): If True, perform a hard (permanent) delete.

    Note:
        The 'hard' parameter determines whether to perform a soft delete (default) or a hard delete.
        In a soft delete, the model might be marked as deleted but retained in the system.
        In a hard delete, the model is permanently removed from the system.

    Returns:
        (Optional[Response]): Response object from the delete request, or None if delete fails.
    """
    return super().delete(self.id, hard)

export(format)

Ultralytics HUB adresine aktar─▒n.

Args: format (str): D─▒┼ča aktarma bi├žimi burada. Desteklenen d─▒┼ča aktarma bi├žimleri ┼čunlard─▒r

─░ade:

Tip A├ž─▒klama
Optional[Response]

D─▒┼ča aktarma iste─činden gelen yan─▒t nesnesi veya d─▒┼ča aktarma ba┼čar─▒s─▒z olursa Yok.

Kaynak kodu hub_sdk/modules/models.py
def export(self, format: str) -> Optional[Response]:
    """
    Export to Ultralytics HUB.

    Args: format (str): Export format here. Here are supported export [formats](
    https://docs.ultralytics.com/modes/export/#export-formats)

    Returns:
        (Optional[Response]): Response object from the export request, or None if export fails.
    """
    return self.hub_client.export(self.id, format)  # response

get_architecture()

Modelin mimari ad─▒n─▒ al─▒n.

─░ade:

Tip A├ž─▒klama
Optional[str]

Mimari ad─▒ ve ard─▒ndan '.yaml' veya mevcut de─čilse Yok.

Kaynak kodu hub_sdk/modules/models.py
def get_architecture(self) -> Optional[str]:
    """
    Get the architecture name of the model.

    Returns:
        (Optional[str]): The architecture name followed by '.yaml' or None if not available.
    """
    return self.data.get("cfg")

get_data()

Ge├žerli model ├Ârne─či i├žin verileri al─▒r.

Ge├žerli bir model kimli─či ayarlanm─▒┼čsa, model verilerini almak i├žin bir istek g├Ânderir ve bunlar─▒ ├Ârnekte depolar. Hi├žbir model kimli─či ayarlanmam─▒┼čsa, bir hata mesaj─▒ g├╝nl├╝─če kaydeder.

─░ade:

Tip A├ž─▒klama
None

Y├Ântem bir de─čer d├Ând├╝rmez.

Kaynak kodu hub_sdk/modules/models.py
def get_data(self) -> None:
    """
    Retrieves data for the current model instance.

    If a valid model ID has been set, it sends a request to fetch the model data and stores it in the instance.
    If no model ID has been set, it logs an error message.

    Returns:
        (None): The method does not return a value.
    """
    if not self.id:
        self.logger.error("No model id has been set. Update the model id or create a model.")
        return

    try:
        response = super().read(self.id)

        if response is None:
            self.logger.error(f"Received no response from the server for model ID: {self.id}")
            return

        # Check if the response has a .json() method (it should if it's a response object)
        if not hasattr(response, "json"):
            self.logger.error(f"Invalid response object received for model ID: {self.id}")
            return

        resp_data = response.json()
        if resp_data is None:
            self.logger.error(f"No data received in the response for model ID: {self.id}")
            return

        data = resp_data.get("data", {})
        self.data = self._reconstruct_data(data)
        self.logger.debug(f"Model data retrieved for ID: {self.id}")

    except Exception as e:
        self.logger.error(f"An error occurred while retrieving data for model ID: {self.id}, {str(e)}")

get_dataset_url()

Model ile ili┼čkili veri k├╝mesi URL'sini al─▒n.

─░ade:

Tip A├ž─▒klama
Optional[str]

Veri k├╝mesinin URL'si veya mevcut de─čilse Yok.

Kaynak kodu hub_sdk/modules/models.py
def get_dataset_url(self) -> Optional[str]:
    """
    Get the dataset URL associated with the model.

    Returns:
        (Optional[str]): The URL of the dataset or None if not available.
    """
    return self.data.get("data")

get_metrics()

Modelin metriklerini al─▒n.

─░ade:

Tip A├ž─▒klama
(list(dict), optional)

Metrik nesnelerinin listesi veya ba┼čar─▒s─▒z olursa Yok.

Kaynak kodu hub_sdk/modules/models.py
def get_metrics(self) -> Optional[List[Dict[str, Any]]]:
    """
    Get metrics to of model.

    Returns:
        (list(dict), optional): The list of metrics objects, or None if it fails.
    """
    if self.metrics:
        return self.metrics

    endpoint = f"{HUB_API_ROOT}/v1/{self.base_endpoint}/{self.id}/metrics"
    try:
        results = self.get(endpoint)
        self.metrics = results.json().get("data")
        return self.metrics
    except Exception as e:
        self.logger.error(f"Model Metrics not found: {e}")

get_weights_url(weight='best')

Model a─č─▒rl─▒klar─▒n─▒n URL'sini al─▒n.

Parametreler:

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

Al─▒nacak a─č─▒rl─▒klar─▒n t├╝r├╝.

'best'

─░ade:

Tip A├ž─▒klama
Optional[str]

Belirtilen a─č─▒rl─▒klar─▒n URL'si veya mevcut de─čilse Yok.

Kaynak kodu hub_sdk/modules/models.py
def get_weights_url(self, weight: str = "best") -> Optional[str]:
    """
    Get the URL of the model weights.

    Args:
        weight (str, optional): Type of weights to retrieve.

    Returns:
        (Optional[str]): The URL of the specified weights or None if not available.
    """
    if weight == "last":
        return self.data.get("resume")

    return self.data.get("weights")

has_best_weights()

Modelin en iyi a─č─▒rl─▒klar─▒ kaydedip kaydetmedi─čini kontrol edin.

─░ade:

Tip A├ž─▒klama
bool

En iyi a─č─▒rl─▒klar mevcutsa True, aksi takdirde False.

Kaynak kodu hub_sdk/modules/models.py
def has_best_weights(self) -> bool:
    """
    Check if the model has best weights saved.

    Returns:
        (bool): True if best weights available, False otherwise.
    """
    return self.data.get("has_best_weights", False)

is_custom()

Modelin ├Âzel olup olmad─▒─č─▒n─▒ kontrol edin.

─░ade:

Tip A├ž─▒klama
bool

├ľzel ise True, de─čilse False.

Kaynak kodu hub_sdk/modules/models.py
def is_custom(self) -> bool:
    """
    Check if the model is custom.

    Returns:
        (bool): True if custom, False otherwise.
    """
    return self.data.get("is_custom", False)

is_pretrained()

Modelin ├Ân e─čitimli olup olmad─▒─č─▒n─▒ kontrol edin.

─░ade:

Tip A├ž─▒klama
bool

├ľnceden e─čitilmi┼čse True, aksi takdirde False.

Kaynak kodu hub_sdk/modules/models.py
def is_pretrained(self) -> bool:
    """
    Check if the model is pretrained.

    Returns:
        (bool): True if pretrained, False otherwise.
    """
    return self.data.get("is_pretrained", False)

is_resumable()

Model e─čitimine devam edilip edilemeyece─čini kontrol edin.

─░ade:

Tip A├ž─▒klama
bool

Devam ettirilebilirse True, aksi takdirde False.

Kaynak kodu hub_sdk/modules/models.py
def is_resumable(self) -> bool:
    """
    Check if the model training can be resumed.

    Returns:
        (bool): True if resumable, False otherwise.
    """
    return self.data.get("has_last_weights", False)

is_trained()

Modelin e─čitilip e─čitilmedi─čini kontrol edin.

─░ade:

Tip A├ž─▒klama
bool

E─čitildiyse True, aksi takdirde False.

Kaynak kodu hub_sdk/modules/models.py
def is_trained(self) -> bool:
    """
    Check if the model is trained.

    Returns:
        (bool): True if trained, False otherwise.
    """
    return self.data.get("status") == "trained"

predict(image, config)

Ultralytics HUB'a tahmin edin.

Parametreler:

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

G├Âr├╝nt├╝ dosyas─▒n─▒n yolu.

gerekli
config dict

Tahmin i├žin bir yap─▒land─▒rma (JSON).

gerekli

─░ade:

Tip A├ž─▒klama
Optional[Response]

Tahmin iste─činden gelen yan─▒t nesnesi veya y├╝kleme ba┼čar─▒s─▒z olursa Yok.

Kaynak kodu hub_sdk/modules/models.py
def predict(self, image: str, config: Dict[str, Any]) -> Optional[Response]:
    """
    Predict to Ultralytics HUB.

    Args:
        image (str): The path to the image file.
        config (dict): A configuration for the prediction (JSON).

    Returns:
        (Optional[Response]): Response object from the predict request, or None if upload fails.
    """
    return self.hub_client.predict(self.id, image, config)  # response

start_heartbeat(interval=60)

Uzak hub sunucusuna kalp at─▒┼č─▒ sinyalleri g├Ândermeye ba┼člar.

Bu y├Ântem bir hub sunucusuna kalp at─▒┼č─▒ sinyallerinin g├Ânderilmesini ba┼člat─▒r M├╝┼čterinin sa─čl─▒k durumunun devam etti─čini g├Âstermek i├žin.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
interval int

Ard─▒┼č─▒k kalp at─▒┼člar─▒ aras─▒ndaki saniye cinsinden zaman aral─▒─č─▒.

60

─░ade:

Tip A├ž─▒klama
None

Y├Ântem bir de─čer d├Ând├╝rmez.

Not

Kalp at─▒┼člar─▒ hub sunucusu ile ba─člant─▒y─▒ s├╝rd├╝rmek i├žin gereklidir ve m├╝┼čterinin aktif ve duyarl─▒ kalmas─▒n─▒ sa─člamak.

Kaynak kodu hub_sdk/modules/models.py
def start_heartbeat(self, interval: int = 60):
    """
    Starts sending heartbeat signals to a remote hub server.

    This method initiates the sending of heartbeat signals to a hub server
    in order to indicate the continued availability and health of the client.

    Args:
        interval (int): The time interval, in seconds, between consecutive heartbeats.

    Returns:
        (None): The method does not return a value.

    Note:
        Heartbeats are essential for maintaining a connection with the hub server
        and ensuring that the client remains active and responsive.
    """
    self.hub_client._register_signal_handlers()
    self.hub_client._start_heartbeats(self.id, interval)

stop_heartbeat()

Uzak hub sunucusuna kalp at─▒┼č─▒ sinyalleri g├Ândermeyi durdurur.

Bu y├Ântem, hub sunucusuna kalp at─▒┼č─▒ sinyallerinin g├Ânderilmesini sonland─▒r─▒r, istemcinin art─▒k kullan─▒labilir veya etkin olmad─▒─č─▒n─▒ etkin bir ┼čekilde bildirir.

─░ade:

Tip A├ž─▒klama
None

Y├Ântem bir de─čer d├Ând├╝rmez.

Not

Kalp at─▒┼člar─▒n─▒ durdurmak, hub sunucusuna neden olabilece─činden dikkatli bir ┼čekilde yap─▒lmal─▒d─▒r istemciyi ba─člant─▒s─▒ kesilmi┼č veya kullan─▒lamaz olarak de─čerlendirir.

Kaynak kodu hub_sdk/modules/models.py
def stop_heartbeat(self) -> None:
    """
    Stops sending heartbeat signals to a remote hub server.

    This method terminates the sending of heartbeat signals to the hub server,
    effectively signaling that the client is no longer available or active.

    Returns:
        (None): The method does not return a value.

    Note:
        Stopping heartbeats should be done carefully, as it may result in the hub server
        considering the client as disconnected or unavailable.
    """
    self.hub_client._stop_heartbeats()

update(data)

Bu ├Ârnek taraf─▒ndan temsil edilen model kayna─č─▒n─▒ g├╝ncelleyin.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
data dict

Model kayna─č─▒ i├žin g├╝ncellenmi┼č veriler.

gerekli

─░ade:

Tip A├ž─▒klama
Optional[Response]

G├╝ncelleme iste─činden gelen yan─▒t nesnesi veya g├╝ncelleme ba┼čar─▒s─▒z olursa Yok.

Kaynak kodu hub_sdk/modules/models.py
def update(self, data: dict) -> Optional[Response]:
    """
    Update the model resource represented by this instance.

    Args:
        data (dict): The updated data for the model resource.

    Returns:
        (Optional[Response]): Response object from the update request, or None if update fails.
    """
    return super().update(self.id, data)

upload_metrics(metrics)

Model metriklerini Ultralytics HUB'a y├╝kleyin.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
metrics dict
gerekli

─░ade:

Tip A├ž─▒klama
Optional[Response]

Y├╝kleme ├Âl├ž├╝mleri iste─činden gelen yan─▒t nesnesi veya ba┼čar─▒s─▒z olursa Yok.

Kaynak kodu hub_sdk/modules/models.py
def upload_metrics(self, metrics: dict) -> Optional[Response]:
    """
    Upload model metrics to Ultralytics HUB.

    Args:
        metrics (dict):

    Returns:
        (Optional[Response]): Response object from the upload metrics request, or None if it fails.
    """
    return self.hub_client.upload_metrics(self.id, metrics)  # response

upload_model(epoch, weights, is_best=False, map=0.0, final=False)

Ultralytics HUB adresine bir model kontrol noktas─▒ y├╝kleyin.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
epoch int

Ge├žerli e─čitim d├Ânemi.

gerekli
weights str

Model a─č─▒rl─▒klar─▒ dosyas─▒n─▒n yolu.

gerekli
is_best bool

Mevcut modelin ┼čimdiye kadarki en iyi model olup olmad─▒─č─▒n─▒ belirtir.

False
map float

Modelin ortalama ortalama hassasiyeti.

0.0
final bool

Modelin e─čitimden sonraki son model olup olmad─▒─č─▒n─▒ belirtir.

False

─░ade:

Tip A├ž─▒klama
Optional[Response]

Kar┼č─▒ya y├╝kleme iste─činden gelen yan─▒t nesnesi veya kar┼č─▒ya y├╝kleme ba┼čar─▒s─▒z olursa Yok.

Kaynak kodu hub_sdk/modules/models.py
def upload_model(
    self,
    epoch: int,
    weights: str,
    is_best: bool = False,
    map: float = 0.0,
    final: bool = False,
) -> Optional[Response]:
    """
    Upload a model checkpoint to Ultralytics HUB.

    Args:
        epoch (int): The current training epoch.
        weights (str): Path to the model weights file.
        is_best (bool): Indicates if the current model is the best one so far.
        map (float): Mean average precision of the model.
        final (bool): Indicates if the model is the final model after training.

    Returns:
        (Optional[Response]): Response object from the upload request, or None if upload fails.
    """
    return self.hub_client.upload_model(self.id, epoch, weights, is_best=is_best, map=map, final=final)



hub_sdk.modules.models.ModelList

├ťsler: PaginatedList

Kaynak kodu hub_sdk/modules/models.py
class ModelList(PaginatedList):
    def __init__(self, page_size=None, public=None, headers=None):
        """
        Initialize a ModelList instance.

        Args:
            page_size (int, optional): The number of items to request per page.
            public (bool, optional): Whether the items should be publicly accessible.
            headers (dict, optional): Headers to be included in API requests.
        """
        base_endpoint = "models"
        super().__init__(base_endpoint, "model", page_size, public, headers)

__init__(page_size=None, public=None, headers=None)

Bir ModelList ├Ârne─čini ba┼člat─▒n.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
page_size int

Sayfa ba┼č─▒na talep edilecek ├Â─če say─▒s─▒.

None
public bool

├ľ─čelerin kamu eri┼čimine a├ž─▒k olup olmamas─▒.

None
headers dict

API isteklerine dahil edilecek ba┼čl─▒klar.

None
Kaynak kodu hub_sdk/modules/models.py
def __init__(self, page_size=None, public=None, headers=None):
    """
    Initialize a ModelList instance.

    Args:
        page_size (int, optional): The number of items to request per page.
        public (bool, optional): Whether the items should be publicly accessible.
        headers (dict, optional): Headers to be included in API requests.
    """
    base_endpoint = "models"
    super().__init__(base_endpoint, "model", page_size, public, headers)