Skip to content

Commit a5816de

Browse files
authored
[ppyoloe-sod] add im_size to box_distribution (#7308)
1 parent c5ab55e commit a5816de

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

configs/smalldet/README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ Tower(59)
136136
`
137137

138138
</details>
139-
,原始数据集[下载链接](https://challenge.xviewdataset.org/download-links)
139+
140+
,原始数据集[下载链接](https://challenge.xviewdataset.org/)
140141

141142

142143
### 用户自定义数据集准备
@@ -289,10 +290,15 @@ CUDA_VISIBLE_DEVICES=0 python deploy/python/infer.py --model_dir=output_inferenc
289290
python tools/box_distribution.py --json_path ../../dataset/DOTA/annotations/train.json --out_img box_distribution.jpg
290291
```
291292
- `--json_path` :待统计数据集COCO 格式 annotation 的json文件路径
293+
- `--eval_size` :推理尺度(默认640)
294+
- `--small_sride` :模型最小步长(默认8)
292295
- `--out_img` :输出的统计分布图路径
293296

294297
以DOTA数据集的train数据集为例,统计结果打印如下:
295298
```bash
299+
Suggested reg_range[1] is 13
300+
Mean of all img_w is 2304.3981547196595
301+
Mean of all img_h is 2180.9354151880766
296302
Median of ratio_w is 0.03799439775910364
297303
Median of ratio_h is 0.04074914637387802
298304
all_img with box: 1409
@@ -301,8 +307,8 @@ Distribution saved as box_distribution.jpg
301307
```
302308

303309
**注意:**
304-
- 当原始数据集全部有标注框的图片中,**有1/2以上的图片标注框的平均宽高与原图宽高比例小于0.04时**,建议进行切图训练
305-
310+
- `Suggested reg_range[1]` 为数据集在优化后DFL算法中推荐的`reg_range`上限,即` reg_max+1`
311+
- 当原始数据集全部有标注框的图片中,**原图宽高均值大于1500且有1/2以上的图片标注框的平均宽高与原图宽高比例小于0.04时**,建议进行切图训练。
306312

307313
### SAHI切图
308314

tools/box_distribution.py

+12
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def get_ratio_infos(jsonfile, out_img, eval_size, small_stride):
5353
be_im_h = []
5454
ratio_w = []
5555
ratio_h = []
56+
im_wid,im_hei=[],[]
5657
for ann in tqdm(allannjson['annotations']):
5758
if ann['iscrowd']:
5859
continue
@@ -63,6 +64,8 @@ def get_ratio_infos(jsonfile, out_img, eval_size, small_stride):
6364
else:
6465
im_w = coco.imgs[be_im_id]['width']
6566
im_h = coco.imgs[be_im_id]['height']
67+
im_wid.append(im_w)
68+
im_hei.append(im_h)
6669
im_m_w = np.mean(be_im_w)
6770
im_m_h = np.mean(be_im_h)
6871
dis_w = im_m_w / im_w
@@ -72,9 +75,16 @@ def get_ratio_infos(jsonfile, out_img, eval_size, small_stride):
7275
be_im_id = ann['image_id']
7376
be_im_w = [w]
7477
be_im_h = [h]
78+
7579

7680
im_w = coco.imgs[be_im_id]['width']
7781
im_h = coco.imgs[be_im_id]['height']
82+
im_wid.append(im_w)
83+
im_hei.append(im_h)
84+
all_im_m_w = np.mean(im_wid)
85+
all_im_m_h = np.mean(im_hei)
86+
87+
7888
im_m_w = np.mean(be_im_w)
7989
im_m_h = np.mean(be_im_h)
8090
dis_w = im_m_w / im_w
@@ -100,6 +110,8 @@ def get_ratio_infos(jsonfile, out_img, eval_size, small_stride):
100110
ratio_w = [i * 1000 for i in ratio_w]
101111
ratio_h = [i * 1000 for i in ratio_h]
102112
print(f'Suggested reg_range[1] is {reg_max+1}' )
113+
print(f'Mean of all img_w is {all_im_m_w}')
114+
print(f'Mean of all img_h is {all_im_m_h}')
103115
print(f'Median of ratio_w is {mid_w}')
104116
print(f'Median of ratio_h is {mid_h}')
105117
print('all_img with box: ', len(ratio_h))

0 commit comments

Comments
 (0)