|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- # 人脸识别物理对抗攻击
-
-
-
- ##描述
- 本项目是对人脸识别模型的物理对抗攻击,通过生成对抗口罩,使人脸佩戴后实现目标攻击和非目标攻击,并应用于mindspore平台。
-
-
-
- ##模型结构
- 采用华为mindspore官方训练的FaceRecognition模型
- https://www.mindspore.cn/resources/hub/details?MindSpore/1.7/facerecognition_ms1mv2
-
-
-
-
- ##环境要求
- mindspore=1.7,硬件平台为GPU。
-
-
-
- ##脚本说明
- ├── readme.md
- ├── opencv_photo
- │ ├── adv_input //对抗图像
- │ ├── input //输入图像
- │ └── target //目标图像
- ├── outputs //训练后的图像
- ├── FaceRecognition //模型设置
- ├── AFR.py //训练脚本
- ├── camera.py //opencv图像采集
- │── example_non-target_attack.py //无目标攻击训练
- │── example_target_attack.py //目标攻击训练
- │── loss_design.py //训练优化设置
- └── test.py //评估攻击效果
-
-
- ##模型调用
- 方法一:
-
- #基于mindspore_hub库调用FaceRecognition模型
-
- import mindspore_hub as mshub
- from mindspore import context
-
- def get_net():
- context.set_context(mode=context.GRAPH_MODE,
- device_target="GPU",
- device_id=0)
-
- model = "mindspore/1.7/facerecognition_ms1mv2"
- network = mshub.load(model)
- network.set_train(False)
- return network
-
- 方法二:
-
- 利用 MindSpore代码仓中的https://gitee.com/mindspore/models/blob/master/research/cv/FaceRecognition/eval.py的get_model函数加载模型
-
- ##训练过程
- 目标攻击:
-
- $ cd face_adversarial_attack/example/
- $ python example_target_attack.py
-
- 非目标攻击:
-
- $ cd face_adversarial_attack/example/
- $ python example_non-target_attack.py
-
-
-
-
- ##默认训练参数
- optimizer=adam, learning rate=0.01, weight_decay=0.0001, epoch=2000
-
-
- ##评估过程
- 评估方法一:
-
- AFR.Attack.test()
-
- 评估方法二:
-
- $ cd face_adversarial_attack/example/
- $ python test.py
|