人脸识别开源网络笔记

一时失言乱红尘 2022-09-04 11:46 318阅读 0赞

https://github.com/HaoSir/ECCV-2020-Fair-Face-Recognition-challenge_2nd_place_solution-ustc-nelslip-

Spherical Confidence Learning for Face Recognition

人脸识别中的球形置信度学习

作者 | Shen Li、Jianqing Xu、Xiaqing Xu、Pengcheng Shen、Shaoxin Li、Bryan Hooi

单位 | 新加坡国立大学;腾讯优图;Aibee

论文 |

https://openaccess.thecvf.com/content/CVPR2021/papers/Li_Spherical_Confidence_Learning_for_Face_Recognition_CVPR_2021_paper.pdf

论文 | https://github.com/MathsShen/SCF/

备注 | CVPR 2021 oral

文章提出一个多任务学习框架:MTLFace,可以同时实现 AIFR 和 FAS。设计两个新的模块:AFD 将特征分解为年龄和身份相关的特征,ICM 实现身份层面的人脸年龄合成。在跨年龄段和一般基准数据集上进行的广泛的人脸识别实验证明了所提出的方法的优越性。

作者 | Zhizhong Huang, Junping Zhang, Hongming Shan

单位 | 复旦大学;

论文 | https://arxiv.org/abs/2103.01520

代码 | https://github.com/Hzzone/MTLFace

备注 | CVPR 2021 oral

786b62b89ef6181a969169d473bbb6f2.png

https://blog.csdn.net/moxibingdao/article/details/108722683

  1. class CurricularFace(nn.Module):
  2. r"""Implement of CurricularFace (https://arxiv.org/pdf/2004.00288.pdf):
  3. Args:
  4. in_features: size of each input sample
  5. out_features: size of each output sample
  6. device_id: the ID of GPU where the model will be trained by model parallel.
  7. if device_id=None, it will be trained on CPU without model parallel.
  8. m: margin
  9. s: scale of outputs
  10. """
  11. def __init__(self, in_features, out_features, m = 0.5, s = 64.):
  12. super(CurricularFace, self).__init__()
  13. self.in_features = in_features
  14. self.out_features = out_features
  15. self.m = m
  16. self.s = s
  17. self.cos_m = math.cos(m)
  18. self.sin_m = math.sin(m)
  19. self.threshold = math.cos(math.pi - m)
  20. self.mm = math.sin(math.pi - m) * m
  21. self.kernel = Parameter(torch.Tensor(in_features, out_features))
  22. self.register_buffer('t', torch.zeros(1))
  23. nn.init.normal_(self.kernel, std=0.01)
  24. def forward(self, embbedings, label):
  25. embbedings = l2_norm(embbedings, axis = 1)
  26. kernel_norm = l2_norm(self.kernel, axis = 0)
  27. cos_theta = torch.mm(embbedings, kernel_norm)
  28. cos_theta = cos_theta.clamp(-1, 1) # for numerical stability
  29. with torch.no_grad():
  30. origin_cos = cos_theta.clone()
  31. target_logit = cos_theta[torch.arange(0, embbedings.size(0)), label].view(-1, 1)
  32. sin_theta = torch.sqrt(1.0 - torch.pow(target_logit, 2))
  33. cos_theta_m = target_logit * self.cos_m - sin_theta * self.sin_m #cos(target+margin)
  34. mask = cos_theta > cos_theta_m
  35. final_target_logit = torch.where(target_logit > self.threshold, cos_theta_m, target_logit - self.mm)
  36. hard_example = cos_theta[mask]
  37. with torch.no_grad():
  38. self.t = target_logit.mean() * 0.01 + (1 - 0.01) * self.t
  39. cos_theta[mask] = hard_example * (self.t + hard_example)
  40. cos_theta.scatter_(1, label.view(-1, 1).long(), final_target_logit)
  41. output = cos_theta * self.s
  42. return output

发表评论

表情:
评论列表 (有 0 条评论,318人围观)

还没有评论,来说两句吧...

相关阅读

    相关 人脸识别笔记

    人脸识别笔记 参考资料: [人脸识别技术看这一篇就够了(附国内人脸识别20强公司)][20] [人脸识别的十个关键技术组成及原理][Link 1] [