From c8678c3b4836d5c43772cedaaf6dbdea3d001978 Mon Sep 17 00:00:00 2001 From: Feng Ni Date: Mon, 14 Nov 2022 12:14:02 +0800 Subject: [PATCH] Fix slice image deploy infer index (#7317) * remove duplicate backbone variant, test=document_fix * fix slice_image deploy infer index --- ...0e_sliced_visdrone_640_025_slice_infer.yml | 49 ++----------------- deploy/python/infer.py | 4 +- ppdet/data/source/dataset.py | 3 +- ppdet/engine/trainer.py | 4 +- 4 files changed, 11 insertions(+), 49 deletions(-) diff --git a/configs/smalldet/ppyoloe_crn_l_80e_sliced_visdrone_640_025_slice_infer.yml b/configs/smalldet/ppyoloe_crn_l_80e_sliced_visdrone_640_025_slice_infer.yml index 5464c9550..91e45ff54 100644 --- a/configs/smalldet/ppyoloe_crn_l_80e_sliced_visdrone_640_025_slice_infer.yml +++ b/configs/smalldet/ppyoloe_crn_l_80e_sliced_visdrone_640_025_slice_infer.yml @@ -1,52 +1,11 @@ _BASE_: [ - './_base_/visdrone_sliced_640_025_detection.yml', - '../runtime.yml', - '../ppyoloe/_base_/optimizer_300e.yml', - '../ppyoloe/_base_/ppyoloe_crn.yml', - '../ppyoloe/_base_/ppyoloe_reader.yml', + 'ppyoloe_crn_l_80e_sliced_visdrone_640_025.yml', ] -log_iter: 100 -snapshot_epoch: 10 -weights: output/ppyoloe_crn_l_80e_sliced_visdrone_640_025/model_final +weights: https://paddledet.bj.bcebos.com/models/ppyoloe_crn_l_80e_sliced_visdrone_640_025.pdparams -pretrain_weights: https://paddledet.bj.bcebos.com/models/ppyoloe_crn_l_300e_coco.pdparams -depth_mult: 1.0 -width_mult: 1.0 - -TrainReader: - batch_size: 8 - -EvalReader: - batch_size: 1 # only support bs=1 when slice infer - -TestReader: - batch_size: 1 - fuse_normalize: True - - -epoch: 80 -LearningRate: - base_lr: 0.01 - schedulers: - - !CosineDecay - max_epochs: 96 - - !LinearWarmup - start_factor: 0. - epochs: 1 - -PPYOLOEHead: - static_assigner_epoch: -1 - nms: - name: MultiClassNMS - nms_top_k: 10000 - keep_top_k: 500 - score_threshold: 0.01 - nms_threshold: 0.6 - - -# very slow, preferly eval with a determined weights(xx.pdparams) -# if you want to eval during training, change SlicedCOCODataSet to COCODataSet and delete sliced_size/overlap_ratio +# very slow, better to use the determined weight (xx. pdparams) to evaluate separately, rather than evaling during training +# if you want to eval during training, change SlicedCOCODataSet to COCODataSet, then delete sliced_size and overlap_ratio EvalDataset: !SlicedCOCODataSet image_dir: VisDrone2019-DET-val diff --git a/deploy/python/infer.py b/deploy/python/infer.py index ed28fee63..81daa1dbd 100644 --- a/deploy/python/infer.py +++ b/deploy/python/infer.py @@ -257,7 +257,7 @@ class Detector(object): overlap_width_ratio=overlap_ratio[1]) sub_img_num = len(slice_image_result) merged_bboxs = [] - print('sub_img_num', sub_img_num) + print('slice to {} sub_samples.', sub_img_num) batch_image_list = [ slice_image_result.images[_ind] for _ind in range(sub_img_num) @@ -306,7 +306,7 @@ class Detector(object): st, ed = 0, result['boxes_num'][0] # start_index, end_index for _ind in range(sub_img_num): boxes_num = result['boxes_num'][_ind] - ed = boxes_num + ed = st + boxes_num shift_amount = slice_image_result.starting_pixels[_ind] result['boxes'][st:ed][:, 2:4] = result['boxes'][ st:ed][:, 2:4] + shift_amount diff --git a/ppdet/data/source/dataset.py b/ppdet/data/source/dataset.py index 2eeaf6e70..d378b4da5 100644 --- a/ppdet/data/source/dataset.py +++ b/ppdet/data/source/dataset.py @@ -254,7 +254,8 @@ class ImageFolder(DetDataset): records.append(rec) ct_sub += sub_img_num ct += 1 - print('{} samples and slice to {} sub_samples'.format(ct, ct_sub)) + logger.info('{} samples and slice to {} sub_samples.'.format(ct, + ct_sub)) self.roidbs = records def get_label_list(self): diff --git a/ppdet/engine/trainer.py b/ppdet/engine/trainer.py index 855c57b03..7c061cea5 100644 --- a/ppdet/engine/trainer.py +++ b/ppdet/engine/trainer.py @@ -746,9 +746,11 @@ class Trainer(object): output_dir='output', save_results=False, visualize=True): + if not os.path.exists(output_dir): + os.makedirs(output_dir) + self.dataset.set_slice_images(images, slice_size, overlap_ratio) loader = create('TestReader')(self.dataset, 0) - imid2path = self.dataset.get_imid2path() anno_file = self.dataset.get_anno() -- GitLab