Преглед на файлове

[Docs] coco_tools update some description (#60)

huilin преди 3 години
родител
ревизия
7ff29fc478

+ 1 - 0
README.md

@@ -93,6 +93,7 @@ PaddleRS是遥感科研院所、相关高校共同基于飞桨开发的遥感处
           <li>ResizeByShort</li>
           <li>RandomResizeByShort</li>
           <li>ResizeByLong</li>  
+          <li>RandomFlipOrRotation</li> 
           <li>RandomHorizontalFlip</li>  
           <li>RandomVerticalFlip</li>
           <li>Normalize</li>

+ 22 - 11
docs/data/tools.md

@@ -7,6 +7,7 @@
 - `mask2geojson`:用于对推理得到的png提取geojson。
 - `matcher`:用于在推理前匹配两个时段的影响。
 - `spliter`:用于将大图数据进行分割以作为训练数据。
+- `coco_tools`:用于统计处理coco类标注文件。
 
 后期将根据DL和RS/GIS方面的前后处理需求增加更多的工具。
 
@@ -43,26 +44,23 @@ python mask2shp.py --srcimg_path xxx.tif --mask_path xxx.png [--save_path output
 其中:
 
 - `srcimg_path`:原始图像的路径,需要带有地理信息,以便为生成的shapefile提供crs等信息。
-
 - `mask_path`:推理得到的png格式的标签的路径。
-
 - `save_path`:保存shapefile的路径,默认为`output`。
-
 - `ignore_index`:忽略生成shp的索引,如背景等,默认为255。
 
 ### mask2geojson
 
-  `mask2geojson`的主要功能是将推理得到的png格式的分割结果转换为geojson格式。使用代码如下:
+`mask2geojson`的主要功能是将推理得到的png格式的分割结果转换为geojson格式。使用代码如下:
 
-  ```shell
-  python mask2geojson.py --mask_path xxx.tif --save_path xxx.json [--epsilon 0]
-  ```
+```shell
+python mask2geojson.py --mask_path xxx.tif --save_path xxx.json [--epsilon 0]
+```
 
-  其中:
+其中:
 
-  - `mask_path`:推理得到的png格式的标签的路径。
-  - `save_path`:保存geojson的路径。
-  - `epsilon`:opencv的简化参数,默认为0。
+- `mask_path`:推理得到的png格式的标签的路径。
+- `save_path`:保存geojson的路径。
+- `epsilon`:opencv的简化参数,默认为0。
 
 ### matcher
 
@@ -92,3 +90,16 @@ python spliter.py --image_path xxx.tif [--block_size 512] [--save_folder output]
 - `image_path`:需要切分的图像的路径。
 - `block_size`:切分图像块大小,默认为512。
 - `save_folder`:保存切分后结果的文件夹路径,默认为`output`。
+
+### coco_tools
+
+目前coco_tools共有6个文件,各文件及其功能如下:
+
+* json_InfoShow:    打印json文件中各个字典的基本信息;
+* json_ImgSta:      统计json文件中的图像信息,生成统计表、统计图;
+* json_AnnoSta:     统计json文件中的标注信息,生成统计表、统计图;
+* json_Img2Json:    统计test集图像,生成json文件;
+* json_Split:       json文件拆分,划分为train set、val set
+* json_Merge:       json文件合并,将多个json合并为1个json
+
+详细使用方法与参数见[coco_tools说明](coco_tools_cn.md)

+ 9 - 9
tools/coco_tools/json_AnnoSta.py

@@ -8,15 +8,15 @@
 '''
 @File Description:
 # json文件annotations信息,生成统计结果csv,对象框shape、对象看shape比例、对象框起始位置、对象结束位置、对象结束位置、对象类别、单个图像对象数量的分布
-!python ./json_annotation_sta.py \
-    --json_path=./input/instances_val2017.json \
-    --csv_path=./anno_sta/instances_val2017_annotations.csv \
-    --png_shape_path=./anno_sta/instances_val2017_annotations_shape.png \
-    --png_shapeRate_path=./anno_sta/instances_val2017_annotations_shapeRate.png \
-    --png_pos_path=./anno_sta/instances_val2017_annotations_pos.png \
-    --png_posEnd_path=./anno_sta/instances_val2017_annotations_posEnd.png \
-    --png_cat_path=./anno_sta/instances_val2017_annotations_cat.png \
-    --png_objNum_path=./anno_sta/instances_val2017_annotations_objNum.png \
+python ./coco_tools/json_AnnoSta.py \
+    --json_path=./annotations/instances_val2017.json \
+    --csv_path=./anno_sta/annos.csv \
+    --png_shape_path=./anno_sta/annos_shape.png \
+    --png_shapeRate_path=./anno_sta/annos_shapeRate.png \
+    --png_pos_path=./anno_sta/annos_pos.png \
+    --png_posEnd_path=./anno_sta/annos_posEnd.png \
+    --png_cat_path=./anno_sta/annos_cat.png \
+    --png_objNum_path=./anno_sta/annos_objNum.png \
     --get_relative=True
 '''
 import os

+ 4 - 4
tools/coco_tools/json_Img2Json.py

@@ -8,10 +8,10 @@
 '''
 @File Description:
 # 根据test影像文件夹生成test.json
-!python ./json_getTest.py \
-    --test_image_path=./input/img_test \
-    --json_train_path=./output/instances_val2017.json \
-    --json_test_path=./output/instances_test.json
+python ./coco_tools/json_Img2Json.py \
+    --test_image_path=./test2017 \
+    --json_train_path=./annotations/instances_val2017.json \
+    --json_test_path=./test.json
 '''
 import os, cv2
 import json

+ 5 - 5
tools/coco_tools/json_ImgSta.py

@@ -8,11 +8,11 @@
 '''
 @File Description:
 # 统计json文件images信息,生成统计结果csv,同时生成图像shape、图像shape比例的二维分布图
-!python ./json_images_sta.py \
-    --json_path=./input/instances_val2017.json \
-    --csv_path=./img_sta/instances_val2017_images.csv \
-    --png_shape_path=./img_sta/instances_val2017_images_shape.png \
-    --png_shapeRate_path=./img_sta/instances_val2017_images_shapeRate.png
+python ./coco_tools/json_ImgSta.py \
+    --json_path=./annotations/instances_val2017.json \
+    --csv_path=./img_sta/images.csv \
+    --png_shape_path=./img_sta/images_shape.png \
+    --png_shapeRate_path=./img_sta/images_shapeRate.png
 '''
 
 import json

+ 3 - 2
tools/coco_tools/json_InfoShow.py

@@ -8,8 +8,9 @@
 '''
 @File Description:
 # 输出json文件基本信息
-!python ./json_infoShow.py \
-    --json_path=./input/instances_val2017.json
+python ./coco_tools/json_InfoShow.py \
+       --json_path=./annotations/instances_val2017.json \
+       --show_num 5
 '''
 
 import json

+ 4 - 4
tools/coco_tools/json_Merge.py

@@ -8,10 +8,10 @@
 '''
 @File Description:
 # 合并json文件,可以通过merge_keys控制合并的字段, 默认合并'images', 'annotations'字段
-!python ./json_merge.py \
-    --json1_path=./input/instances_train2017.json \
-    --json2_path=./input/instances_val2017.json \
-    --save_path=./output/instances_trainval2017.json
+python ./coco_tools/json_Merge.py \
+    --json1_path=./annotations/instances_train2017.json \
+    --json2_path=./annotations/instances_val2017.json \
+    --save_path=./instances_trainval2017.json
 '''
 
 import json

+ 4 - 4
tools/coco_tools/json_Split.py

@@ -8,10 +8,10 @@
 '''
 @File Description:
 # json数据集划分,可以通过val_split_rate、val_split_num控制划分比例或个数, keep_val_inTrain可以设定是否在train中保留val相关信息
-!python ./json_split.py \
-    --json_all_path=./input/instances_val2017.json \
-    --json_train_path=./output/instances_val2017_split1.json \
-    --json_val_path=./output/instances_val2017_split2.json
+python ./coco_tools/json_Split.py \
+    --json_all_path=./annotations/instances_val2017.json \
+    --json_train_path=./instances_val2017_train.json \
+    --json_val_path=./instances_val2017_val.json
 '''
 
 import json