MMdetection中对 multiscale技术的实现和使用

multiscale术语说明

首先看一下对 multiscale(multi-scale) 是指什么?

resizing images to different scales at each iteration.

核心代码实现:

mmdet/datasets/pipelines/transforms.py文件中的Resize 类实现中,其核心函数为两个:random_selectrandom_sample,分别在设置data.train.multiscale_modevaluerange模式时调用。

class Resize(object):
	...
	def _random_scale(self, results): # 成员函数
		...
		elif self.multiscale_mode == 'range':  
		 scale, scale_idx = self.random_sample(self.img_scale)  
		elif self.multiscale_mode == 'value':  
		 scale, scale_idx = self.random_select(self.img_scale)
		 ...

	def __call__(self, results): # 类被调用时默认执行函数 
		...
		self._resize_img(results)  
		self._resize_bboxes(results)  
		self._resize_masks(results)  
		self._resize_seg(results)  
		return results
	...

使用与调用:

The term of "multiscale training" is adopted in many papers, which indicates resizing images to different scales at each iteration.
You only need to modify the data.train.img_scale field in the config file.
For example, you can use a list of scales [(1333, 800), (1666, 1000)] so that each image will randomly select a scale between (1333, 800) and (1666, 1000). In our paper, we use the setting [(400, 1600), (1400, 1600)] which means the short edge are randomly sampled from 400~1400, and the long edge is fixed as 1600.
from About multiscale training · Issue #78 · open-mmlab/mmdetection

![[Pasted image 20220323173932.png]]
![[Pasted image 20220323173953.png]]

在 swin-transformer 中的configs/swin/mask_rcnn_swin_tiny_patch4_window7_mstrain_480-800_adamw_1x_coco.py文件中使用:

![[Pasted image 20220323185912.png]]

posted @ 2022-03-23 19:24  TechIsOnlyTool  阅读(443)  评论(0编辑  收藏  举报