Ë
    Fêñi5  ã                  óœ   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
mZ d dlmZmZmZ dZddd	„Zd
„ Zddd„Zd„ Zddd„Zddd„Zdd„Zy)é    )Úannotations)ÚHUBDatasetStats)ÚAuth)ÚHUBTrainingSession)ÚHUB_API_ROOTÚHUB_WEB_ROOTÚPREFIX)ÚLOGGERÚSETTINGSÚchecks)
r   r	   r   Úcheck_datasetÚexport_fmts_hubÚexport_modelÚ
get_exportÚloginÚlogoutÚreset_modelNc                óÌ  — t        j                  d«       ddlm} t        › d�}t        j                  d«      }| xs |}|r	|dk7  rd|ind} ||«      }|j                  re|r0|j                  |k7  r!t        j                  d|j                  i«       |j                  | k(  s|sdnd	}t        j                  t        › |› �«       y
t        j                  t        › d|› d�«       y)a\  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.
    zhub-sdk>=0.0.12r   )Ú	HUBClientz/settings?tab=api+keysÚapi_keyÚ Nu!   New authentication successful âœ…u   Authenticated âœ…TzGet API key from z" and then run 'yolo login API_KEY'F)r   Úcheck_requirementsÚhub_sdkr   r   r   ÚgetÚauthenticatedr   Úupdater
   Úinfor	   )	r   Úsaver   Úapi_key_urlÚ	saved_keyÚ
active_keyÚcredentialsÚclientÚlog_messages	            úZ/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/ultralytics/hub/__init__.pyr   r      sß   € ô ×ÑÐ/Ô0Ý!ä!�NÐ"8Ð9€KÜ—‘˜YÓ'€IØÒ%˜I€JÙ-7¸JÈ"Ò<L�9˜jÑ)ÐRV€Ká�{Ó#€Fà×Òñ �F—N‘N iÒ/Ü�O‰O˜Y¨¯©Ð7Ô8ð 4:·>±>ÀWÒ3LÑT_Ñ/Ðexð 	ô 	�‰”v�h˜{˜mÐ,Ô-àô 	�‰”v�hÐ/°¨}Ð<^Ð_Ô`Øó    c                 óN   — dt         d<   t        j                  t        › d�«       y)zJLog out of Ultralytics HUB by removing the API key from the settings file.r   r   u2   logged out âœ…. To log in again, use 'yolo login'.N)r   r
   r   r	   © r&   r%   r   r   D   s    € à„HˆYÑÜ
‡K�K”6�(ÐLÐMÕNr&   c                ó0  — ddl }|j                  t        › d�d| idt        «       j                  i¬«      }|j
                  dk(  rt        j                  t        › d�«       yt        j                  t        › d	|j
                  › d
|j                  › �«       y)z,Reset a trained model to an untrained state.r   Nz/model-resetÚmodelIdú	x-api-key©ÚjsonÚheaderséÈ   zModel reset successfullyzModel reset failure ú )ÚrequestsÚpostr   r   r   Ústatus_coder
   r   r	   ÚwarningÚreason)Úmodel_idr1   Úrs      r%   r   r   J   s~   € ãà�‰œ˜ lÐ3¸9ÀhÐ:OÐZeÔgkÓgm×guÑguÐYvˆÓw€AØ‡}�}˜ÒÜ�‰”v�hÐ6Ð7Ô8ØÜ
‡N�N”f�XÐ1°!·-±-°ÀÀ!Ç(Á(ÀÐLÕMr&   c                 óF   — ddl m}  g t         | «       d   dd «      ¢d‘d‘S )z.Return a list of HUB-supported export formats.r   ©Úexport_formatsÚArgumenté   NÚultralytics_tfliteÚultralytics_coreml)Úultralytics.engine.exporterr:   Úlistr9   s    r%   r   r   U   s0   € å:à`ŒT‘.Ó" :Ñ.¨q¨rÐ2Ó3Ð`Ð5IÐ`ÐK_Ð`Ð`r&   c                ób  — ddl }|t        «       v sJ d|› dt        «       › �«       ‚|j                  t        › d| › d�d|idt	        «       j
                  i¬	«      }|j                  d
k(  s)J t        › |› d|j                  › d|j                  › �«       ‚t        j                  t        › |› d�«       y)a>  Export a model to a specified format for deployment via the Ultralytics HUB API.

    Args:
        model_id (str): The ID of the model to export. An empty string will use the default model.
        format (str): The format to export the model to. Must be one of the supported formats returned by
            export_fmts_hub().

    Raises:
        AssertionError: If the specified format is not supported or if the export request fails.

    Examples:
        >>> from ultralytics import hub
        >>> hub.export_model(model_id="your_model_id", format="torchscript")
    r   NúUnsupported export format 'ú', valid formats are z/v1/models/z/exportÚformatr+   r,   r/   z export failure r0   u    export started âœ…)r1   r   r2   r   r   r   r3   r	   r5   r
   r   ©r6   rD   r1   r7   s       r%   r   r   \   sÁ   € ó à”_Ó&Ñ&ÐvÐ*EÀfÀXÐMbÔcrÓctÐbuÐ(vÓvÐ&Ø�‰Üˆ.˜ H :¨WÐ5¸XÀvÐ<NÐYdÔfjÓfl×ftÑftÐXuð 	ó 	€Að �=‰=˜CÒÐ^¤F 8¨F¨8Ð3CÀAÇMÁMÀ?ÐRSÐTU×T\ÑT\ÐS]Ð!^Ó^ÐÜ
‡K�K”6�(˜6˜(Ð"5Ð6Õ7r&   c                óf  — ddl }|t        «       v sJ d|› dt        «       › �«       ‚|j                  t        › d�t	        «       j
                  | |dœdt	        «       j
                  i¬«      }|j                  d	k(  s)J t        › |› d
|j                  › d|j                  › �«       ‚|j                  «       S )a  Retrieve an exported model in the specified format from Ultralytics HUB using the model ID.

    Args:
        model_id (str): The ID of the model to retrieve from Ultralytics HUB.
        format (str): The export format to retrieve. Must be one of the supported formats returned by export_fmts_hub().

    Returns:
        (dict): JSON response containing the exported model information.

    Raises:
        AssertionError: If the specified format is not supported or if the API request fails.

    Examples:
        >>> from ultralytics import hub
        >>> result = hub.get_export(model_id="your_model_id", format="torchscript")
    r   NrB   rC   z/get-export)ÚapiKeyr*   rD   r+   r,   r/   z get_export failure r0   )
r1   r   r2   r   r   r   r3   r	   r5   r-   rE   s       r%   r   r   u   s³   € ó" à”_Ó&Ñ&ÐvÐ*EÀfÀXÐMbÔcrÓctÐbuÐ(vÓvÐ&Ø�‰Üˆ.˜Ð$Ü›Ÿ™°8ÀvÑNØœd›fŸn™nÐ-ð 	ó 	€Að
 �=‰=˜CÒÐb¤F 8¨F¨8Ð3GÈÏÉÀÐVWÐXY×X`ÑX`ÐWaÐ!bÓbÐØ�6‰6‹8€Or&   c                ót   — t        | |¬«      j                  «        t        j                  dt        › d�«       y)a�  Check HUB dataset Zip file for errors before upload.

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

    Examples:
        >>> 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

    Notes:
        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.
    ©ÚpathÚtasku7   Checks completed correctly âœ…. Upload this dataset to z/datasets/.N)r   Úget_jsonr
   r   r   rI   s     r%   r   r   ’   s.   € ô& ˜ DÔ)×2Ñ2Ô4Ü
‡K�KÐIÌ,ÈÐWbÐcÕdr&   )NT)r   z
str | Noner   ÚboolÚreturnrM   )r   )r6   Ústr)r   Útorchscript)r6   rO   rD   rO   )rJ   rO   rK   rO   rN   ÚNone)Ú
__future__r   Úultralytics.data.utilsr   Úultralytics.hub.authr   Úultralytics.hub.sessionr   Úultralytics.hub.utilsr   r   r	   Úultralytics.utilsr
   r   r   Ú__all__r   r   r   r   r   r   r   r(   r&   r%   ú<module>rY      sN   ðõ #å 2Ý %Ý 6ß DÑ Dß 6Ñ 6ð€ô(òVOôNòaô8ô2ô:er&   