§
    ­¸j�
  ã                  óž   — d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZ ddlmZ dd
„Zddd„Zedk    r e e¦   «         ¦  «        ‚dS )zÊCommand-line packing of COCO splits into WebDataset shards.

Run ``python -m rfdetr.cli.webdataset --help`` for arguments. Reusable packing and index handling live in
:mod:`rfdetr.datasets.webdataset`.
é    )ÚannotationsN)ÚSequence)ÚPath)ÚDEFAULT_MAX_SHARD_BYTESÚ
index_name)Úpack_coco_to_shardsÚreturnúargparse.ArgumentParserc                 óp  — t          j        dd¬¦  «        } |                      ddd¬¦  «         |                      ddd	¬¦  «         |                      d
dd¬¦  «         |                      ddd¬¦  «         |                      dt          t          dz  d¬¦  «         |                      dddd¬¦  «         | S )z7Return the argument parser for the packing entry point.zpython -m rfdetr.cli.webdatasetzPPack a COCO-format split into WebDataset tar shards for sequential-I/O training.)ÚprogÚdescriptionz--image-dirTz*Directory holding the split's image files.)ÚrequiredÚhelpz--annotationsz/COCO-format JSON annotation file for the split.z--output-dirz-Directory to write shards and the index into.z--splitÚtrainz/Split name used for shard and index file names.)Údefaultr   z--max-shard-mbi   zApproximate shard size in MB.)Útyper   r   z--category-ids)ÚremapÚrawr   zU'remap' assigns contiguous 0-based labels; 'raw' keeps the source category_id values.)Úchoicesr   r   )ÚargparseÚArgumentParserÚadd_argumentÚfloatr   )Úparsers    úe/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/rfdetr/cli/webdataset.pyÚ_build_arg_parserr      sñ   € åÔ$Ø.Øfðñ ô €Fð ×Ò˜°Ð;gÐÑhÔhÐhØ
×Ò˜°$Ð=nÐÑoÔoÐoØ
×Ò˜°Ð<kÐÑlÔlÐlØ
×Ò˜	¨7Ð9jÐÑkÔkÐkØ
×ÒØÝÝ'¨;Ñ7Ø,ð	 ñ ô ð ð ×ÒØØ ØØdð	 ñ ô ð ð €Mó    ÚargvúSequence[str] | NoneÚintc                ó¤  — t          ¦   «                              | ¦  «        }t          |j        |j        |j        |j        t          |j        dz  dz  ¦  «        |j	        ¬¦  «        }t          |j        › dt          |j        ¦  «        › dt          j        t!          |j        ¦  «        ¦  «        › dt#          |j        ¦  «        › d�¦  «         dS )z°Pack one COCO split into shards from the command line.

    Args:
        argv: Argument list, or ``None`` to read ``sys.argv``.

    Returns:
        Process exit status.
    i   )ÚsplitÚmax_shard_bytesÚcategory_idsz samples -> z shard(s) in z (ú)r   )r   Ú
parse_argsr   Ú	image_dirr   Ú
output_dirr"   r    Úmax_shard_mbr$   ÚprintÚnum_samplesÚlenÚshardsÚosÚfspathr   r   )r   ÚargsÚindexs      r   Úmainr2   0   së   € õ ÑÔ×)Ò)¨$Ñ/Ô/€DÝØŒØÔØŒØŒjÝ˜DÔ-°Ñ4°tÑ;Ñ<Ô<ØÔ&ðñ ô €Eõ 
ØÔð 	Jð 	J­#¨e¬lÑ*;Ô*;ð 	Jð 	JÝŒ9•T˜$œ/Ñ*Ô*Ñ+Ô+ð	Jð 	JÝ/9¸%¼+Ñ/FÔ/Fð	Jð 	Jð 	Jñô ð ð ˆ1r   Ú__main__)r	   r
   )N)r   r   r	   r    )Ú__doc__Ú
__future__r   r   r.   Úcollections.abcr   Úpathlibr   Ú rfdetr.datasets.webdataset.indexr   r   Úrfdetr.datasets.webdataset.packr   r   r2   Ú__name__Ú
SystemExit© r   r   ú<module>r=      sÛ   ððð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð à PÐ PÐ PÐ PÐ PÐ PÐ PÐ PØ ?Ð ?Ð ?Ð ?Ð ?Ð ?ðð ð ð ð2ð ð ð ð ð2 ˆzÒÐØ
ˆ*�T�T‘V”VÑ
Ô
Ðð Ðr   