@@ -85,12 +85,12 @@ def process_model_config(model_cfg: Config,
8585 cfg .test_pipeline [0 ].type = 'mmdet.LoadImageFromNDArray'
8686
8787 pipeline = cfg .test_pipeline
88-
89- for i , transform in enumerate ( pipeline ) :
90- # for static exporting
91- if input_shape is not None and transform .type == 'Resize' :
92- pipeline [i ].keep_ratio = False
93- pipeline [i ].scale = tuple (input_shape )
88+ # for static exporting
89+ if input_shape is not None :
90+ for i , transform in enumerate ( pipeline ):
91+ if transform .type in [ 'Resize' , 'mmdet.Resize' ] :
92+ pipeline [i ].keep_ratio = False
93+ pipeline [i ].scale = tuple (input_shape )
9494
9595 pipeline = [
9696 transform for transform in pipeline
@@ -209,15 +209,12 @@ def create_input(
209209 cfg = process_model_config (self .model_cfg , imgs , input_shape )
210210
211211 pipeline = cfg .test_pipeline
212+ # for static exporting
212213 if not dynamic_flag :
213- transform = pipeline [1 ]
214- if 'transforms' in transform :
215- transform_list = transform ['transforms' ]
216- for i , step in enumerate (transform_list ):
217- if step ['type' ] == 'Pad' and 'pad_to_square' in step \
218- and step ['pad_to_square' ]:
219- transform_list .pop (i )
220- break
214+ for i , trans in enumerate (pipeline ):
215+ if trans ['type' ] == 'Pad' and 'pad_to_square' in trans \
216+ and trans ['pad_to_square' ]:
217+ trans .pop (i )
221218 test_pipeline = Compose (pipeline )
222219
223220 data = []
@@ -261,6 +258,7 @@ def get_preprocess(self, *args, **kwargs) -> Dict:
261258 input_shape = get_input_shape (self .deploy_cfg )
262259 model_cfg = process_model_config (self .model_cfg , ['' ], input_shape )
263260 pipeline = model_cfg .test_pipeline
261+ pipeline = replace_RResize (pipeline )
264262 meta_keys = [
265263 'filename' , 'ori_filename' , 'ori_shape' , 'img_shape' , 'pad_shape' ,
266264 'scale_factor' , 'flip' , 'flip_direction' , 'img_norm_cfg' ,
0 commit comments