# cutils **Repository Path**: aisworderholder/cutils ## Basic Information - **Project Name**: cutils - **Description**: convenient tools - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-03-23 - **Last Updated**: 2023-10-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: coco, split-coco ## README # convenient_utils ## Install convenient_utils 1. Create environment ```shell conda create -n cutils python=3.6 -y conda activate cutils ``` 2. Setup ```shell pip install "git+https://gitee.com/aisworderholder/cutils.git" ``` ## Usage 1. combine several coco files into one coco file ```python from cutils.coco import CombineCOCO CombineCOCO( label_mapping=[ dict( xy='smoke', dog1='dog', ), dict( xiyan='smoke', puppy='dog', ), ], add_prefix=[ 'train1', 'train2', ], cocofiles=[ 'instances_train1.json', 'instances_train2.json', ] ).export('instances_train1_train2.json') ``` 2. Label Converter 2.1 VOCConverter ```python from cutils.converter import VOCConverter out = VOCConverter( image_dir=r'C:\Users\86150\Desktop\ttt', xml_dir=r'C:\Users\86150\Desktop\ttt', ) # transfer to yolo out.to_yolo( 1, 'classes.txt', './tmp_images/images', file_txt='train.txt' ) # transfer to coco out.save(out.to_coco(1, ), 'train.json') ``` 2.2 LabelmeConverter ```python ``` 3. Format 3.1 print table ```python from cutils.utils.format import Table table = Table(group_names=['ClassName', 'AP50'], group_nums=2,) table.put_item(['CAT', 0.71234]) # you can color it in console by: table.put_item(['CAT', 0.71234], console_color='RED') table.put_item(['DOG', 0.6189]) table.put_item(['WOLF', 1]) table.print_table() # +-------------+--------+-------------+--------+ # | ClassName_0 | AP50_0 | ClassName_1 | AP50_1 | # +-------------+--------+-------------+--------+ # | CAT | 0.7123 | DOG | 0.6189 | # | WOLF | 1 | | | # +-------------+--------+-------------+--------+ ```