Skip to content

Commit c8678c3

Browse files
authored
Fix slice image deploy infer index (#7317)
* remove duplicate backbone variant, test=document_fix * fix slice_image deploy infer index
1 parent a5816de commit c8678c3

File tree

4 files changed

+11
-49
lines changed

4 files changed

+11
-49
lines changed

configs/smalldet/ppyoloe_crn_l_80e_sliced_visdrone_640_025_slice_infer.yml

+4-45
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,11 @@
11
_BASE_: [
2-
'./_base_/visdrone_sliced_640_025_detection.yml',
3-
'../runtime.yml',
4-
'../ppyoloe/_base_/optimizer_300e.yml',
5-
'../ppyoloe/_base_/ppyoloe_crn.yml',
6-
'../ppyoloe/_base_/ppyoloe_reader.yml',
2+
'ppyoloe_crn_l_80e_sliced_visdrone_640_025.yml',
73
]
8-
log_iter: 100
9-
snapshot_epoch: 10
10-
weights: output/ppyoloe_crn_l_80e_sliced_visdrone_640_025/model_final
4+
weights: https://paddledet.bj.bcebos.com/models/ppyoloe_crn_l_80e_sliced_visdrone_640_025.pdparams
115

12-
pretrain_weights: https://paddledet.bj.bcebos.com/models/ppyoloe_crn_l_300e_coco.pdparams
13-
depth_mult: 1.0
14-
width_mult: 1.0
156

16-
17-
TrainReader:
18-
batch_size: 8
19-
20-
EvalReader:
21-
batch_size: 1 # only support bs=1 when slice infer
22-
23-
TestReader:
24-
batch_size: 1
25-
fuse_normalize: True
26-
27-
28-
epoch: 80
29-
LearningRate:
30-
base_lr: 0.01
31-
schedulers:
32-
- !CosineDecay
33-
max_epochs: 96
34-
- !LinearWarmup
35-
start_factor: 0.
36-
epochs: 1
37-
38-
PPYOLOEHead:
39-
static_assigner_epoch: -1
40-
nms:
41-
name: MultiClassNMS
42-
nms_top_k: 10000
43-
keep_top_k: 500
44-
score_threshold: 0.01
45-
nms_threshold: 0.6
46-
47-
48-
# very slow, preferly eval with a determined weights(xx.pdparams)
49-
# if you want to eval during training, change SlicedCOCODataSet to COCODataSet and delete sliced_size/overlap_ratio
7+
# very slow, better to use the determined weight (xx. pdparams) to evaluate separately, rather than evaling during training
8+
# if you want to eval during training, change SlicedCOCODataSet to COCODataSet, then delete sliced_size and overlap_ratio
509
EvalDataset:
5110
!SlicedCOCODataSet
5211
image_dir: VisDrone2019-DET-val

deploy/python/infer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def predict_image_slice(self,
257257
overlap_width_ratio=overlap_ratio[1])
258258
sub_img_num = len(slice_image_result)
259259
merged_bboxs = []
260-
print('sub_img_num', sub_img_num)
260+
print('slice to {} sub_samples.', sub_img_num)
261261

262262
batch_image_list = [
263263
slice_image_result.images[_ind] for _ind in range(sub_img_num)
@@ -306,7 +306,7 @@ def predict_image_slice(self,
306306
st, ed = 0, result['boxes_num'][0] # start_index, end_index
307307
for _ind in range(sub_img_num):
308308
boxes_num = result['boxes_num'][_ind]
309-
ed = boxes_num
309+
ed = st + boxes_num
310310
shift_amount = slice_image_result.starting_pixels[_ind]
311311
result['boxes'][st:ed][:, 2:4] = result['boxes'][
312312
st:ed][:, 2:4] + shift_amount

ppdet/data/source/dataset.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ def set_slice_images(self,
254254
records.append(rec)
255255
ct_sub += sub_img_num
256256
ct += 1
257-
print('{} samples and slice to {} sub_samples'.format(ct, ct_sub))
257+
logger.info('{} samples and slice to {} sub_samples.'.format(ct,
258+
ct_sub))
258259
self.roidbs = records
259260

260261
def get_label_list(self):

ppdet/engine/trainer.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -746,9 +746,11 @@ def slice_predict(self,
746746
output_dir='output',
747747
save_results=False,
748748
visualize=True):
749+
if not os.path.exists(output_dir):
750+
os.makedirs(output_dir)
751+
749752
self.dataset.set_slice_images(images, slice_size, overlap_ratio)
750753
loader = create('TestReader')(self.dataset, 0)
751-
752754
imid2path = self.dataset.get_imid2path()
753755

754756
anno_file = self.dataset.get_anno()

0 commit comments

Comments
 (0)