Closed Edwardwaw closed 3 years ago
cutmix 在ppdet 的Anchor Free 系列(ttfnet、FCOS)验证过,map 提高0.1~0.2。
请问在loss function中是否做了某种改变,比如在cutmix的原作者的code中生成target_a target_b 两种标签,并在loss函数在计算二者的加权和
if args.beta > 0 and r < args.cutmix_prob:
# generate mixed sample
lam = np.random.beta(args.beta, args.beta)
rand_index = torch.randperm(input.size()[0]).cuda()
target_a = target
target_b = target[rand_index]
bbx1, bby1, bbx2, bby2 = rand_bbox(input.size(), lam)
input[:, :, bbx1:bbx2, bby1:bby2] = input[rand_index, :, bbx1:bbx2, bby1:bby2]
# adjust lambda to exactly match pixel ratio
lam = 1 - ((bbx2 - bbx1) * (bby2 - bby1) / (input.size()[-1] * input.size()[-2]))
# compute output
output = model(input)
loss = criterion(output, target_a) * lam + criterion(output, target_b) * (1. - lam)
https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.4/ppdet/data/transform/operators.py#L1297 在这里可以看到,cutmix将两张图的image还有gt信息做了融合,其中gt_score是会按比例做加权,所以在计算loss的过程中没有体现
这里gt box的融合仅仅是把两张图的gt box叠加起来,并没有做任何其他处理,对于detection任务是否不妥?
class CutmixImage(BaseOperator): def init(self, alpha=1.5, beta=1.5): """ CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features, see https://https://arxiv.org/abs/1905.04899 Cutmix image and gt_bbbox/gt_score Args: alpha (float): alpha parameter of beta distribute beta (float): beta parameter of beta distribute """ super(CutmixImage, self).init() self.alpha = alpha self.beta = beta if self.alpha <= 0.0: raise ValueError("alpha shold be positive in {}".format(self)) if self.beta <= 0.0: raise ValueError("beta shold be positive in {}".format(self))
请问当前版本的repo中,cutmix的效果是否经过检验?直觉上来说该部分对gt score gt box的处理似乎有些不妥