未验证 提交 a5816de8 编写于 作者: P pk_hk 提交者: GitHub

[ppyoloe-sod] add im_size to box_distribution (#7308)

上级 c5ab55e3
......@@ -136,7 +136,8 @@ Tower(59)
`
</details>
,原始数据集[下载链接](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切图
......
......@@ -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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册