diff --git a/configs/smalldet/README.md b/configs/smalldet/README.md index 79a92385ec10f27f5eadbeef044785236962bc8c..a5babf569193ac43a4c5896eeba46433b0efbe50 100644 --- a/configs/smalldet/README.md +++ b/configs/smalldet/README.md @@ -136,7 +136,8 @@ Tower(59) ` -,原始数据集[下载链接](https://challenge.xviewdataset.org/download-links)。 + +,原始数据集[下载链接](https://challenge.xviewdataset.org/)。 ### 用户自定义数据集准备 @@ -289,10 +290,15 @@ CUDA_VISIBLE_DEVICES=0 python deploy/python/infer.py --model_dir=output_inferenc python tools/box_distribution.py --json_path ../../dataset/DOTA/annotations/train.json --out_img box_distribution.jpg ``` - `--json_path` :待统计数据集COCO 格式 annotation 的json文件路径 +- `--eval_size` :推理尺度(默认640) +- `--small_sride` :模型最小步长(默认8) - `--out_img` :输出的统计分布图路径 以DOTA数据集的train数据集为例,统计结果打印如下: ```bash +Suggested reg_range[1] is 13 +Mean of all img_w is 2304.3981547196595 +Mean of all img_h is 2180.9354151880766 Median of ratio_w is 0.03799439775910364 Median of ratio_h is 0.04074914637387802 all_img with box: 1409 @@ -301,8 +307,8 @@ Distribution saved as box_distribution.jpg ``` **注意:** -- 当原始数据集全部有标注框的图片中,**有1/2以上的图片标注框的平均宽高与原图宽高比例小于0.04时**,建议进行切图训练。 - +- `Suggested reg_range[1]` 为数据集在优化后DFL算法中推荐的`reg_range`上限,即` reg_max+1`。 +- 当原始数据集全部有标注框的图片中,**原图宽高均值大于1500且有1/2以上的图片标注框的平均宽高与原图宽高比例小于0.04时**,建议进行切图训练。 ### SAHI切图 diff --git a/tools/box_distribution.py b/tools/box_distribution.py index 974936b67d8f5f4fa56b09ea2a2392fb274f86cb..f7979ecc125f4f35f7256b6219707d04218210af 100644 --- a/tools/box_distribution.py +++ b/tools/box_distribution.py @@ -53,6 +53,7 @@ def get_ratio_infos(jsonfile, out_img, eval_size, small_stride): be_im_h = [] ratio_w = [] ratio_h = [] + im_wid,im_hei=[],[] for ann in tqdm(allannjson['annotations']): if ann['iscrowd']: continue @@ -63,6 +64,8 @@ def get_ratio_infos(jsonfile, out_img, eval_size, small_stride): else: im_w = coco.imgs[be_im_id]['width'] im_h = coco.imgs[be_im_id]['height'] + im_wid.append(im_w) + im_hei.append(im_h) im_m_w = np.mean(be_im_w) im_m_h = np.mean(be_im_h) dis_w = im_m_w / im_w @@ -72,9 +75,16 @@ def get_ratio_infos(jsonfile, out_img, eval_size, small_stride): be_im_id = ann['image_id'] be_im_w = [w] be_im_h = [h] + im_w = coco.imgs[be_im_id]['width'] im_h = coco.imgs[be_im_id]['height'] + im_wid.append(im_w) + im_hei.append(im_h) + all_im_m_w = np.mean(im_wid) + all_im_m_h = np.mean(im_hei) + + im_m_w = np.mean(be_im_w) im_m_h = np.mean(be_im_h) dis_w = im_m_w / im_w @@ -100,6 +110,8 @@ def get_ratio_infos(jsonfile, out_img, eval_size, small_stride): ratio_w = [i * 1000 for i in ratio_w] ratio_h = [i * 1000 for i in ratio_h] print(f'Suggested reg_range[1] is {reg_max+1}' ) + print(f'Mean of all img_w is {all_im_m_w}') + print(f'Mean of all img_h is {all_im_m_h}') print(f'Median of ratio_w is {mid_w}') print(f'Median of ratio_h is {mid_h}') print('all_img with box: ', len(ratio_h))