AdvBox 0.4发布 | 支持零编码黑盒攻击,上线新版电子教程,新增支持PyTorch、MxNet

2018-12-12 14:14:0610098人阅读

AdvBox是一款由百度安全实验室研发,在百度大范围使用的AI模型安全工具箱,目前原生支持PaddlePaddle、PyTorch、Caffe2、MxNet、Keras以及TensorFlow平台,方便广大开发者和安全工程师可以使用自己熟悉的框架。

对抗样本是深度学习领域的一个重要问题,比如在图像上叠加肉眼难以识别的修改,就可以欺骗主流的深度学习图像模型,产生分类错误,指鹿为马,或者无中生有。这些问题对于特定领域(比如无人车、人脸识别)会产生严重的后果,尤为重要。百度安全实验室研发了AdvBox,它能够为安全工程师研究模型的安全性提供极大的便利,免去重复造轮子的精力与时间消耗。AdvBox可以高效地使用最新的生成方法构造对抗样本数据集用于对抗样本的特征统计、攻击全新的AI应用,加固业务AI模型,为模型安全性研究和AI应用提供重要的支持。AdvBox今天发布0.4版本,支持零编码黑盒攻击,上线新版电子教程,支持PyTorch、MxNet,项目地址为:https://github.com/baidu/AdvBox


What’s New


编码黑盒攻


AdvBox在0.4版本之前,需要用户具有Python开发能力。为了进一步降低使用门槛,AdvBox从0.4版本开始,支持零编码黑盒攻击,用户使用命令行工具即可对深度学习模型进行黑盒攻击。AdvBox通过支持GraphPipe,屏蔽了底层使用的深度学习平台,用户可以零编码,仅通过几个命令就可以对PaddlePaddle、PyTorch、Caffe2、MxNet、CNTK、ScikitLearn以及TensorFlow平台生成的模型文件进行黑盒攻击。

1.jpg

以Tensorflow为例,Tensorflow提供了丰富预训练模型,假设攻击常见的图像分类模型squeezenet。首先在docker环境下启动基于GraphPipe的预测服务,GraphPipe环境已经完全封装在docker镜像,不用单独安装。

docker run -it --rm \

      -e https_proxy=${https_proxy} \

      -p 9000:9000 \

      sleepsonthefloor/graphpipe-tf:cpu \

      --model=https://oracle.github.io/graphpipe/models/squeezenet.pb \

      --listen=0.0.0.0:9000


如果网速有限,可以先把squeezenet.pb下载,使用本地模式启动。

docker run -it --rm \

      -e https_proxy=${https_proxy} \

      -v "$PWD:/models/"  \

      -p 9000:9000 \

      sleepsonthefloor/graphpipe-tf:cpu \

      --model=/models/squeezenet.pb \

      --listen=0.0.0.0:9000


然后启动攻击脚本,使用默认参数即可,仅需指定攻击的url。目前提供的黑盒攻击算法为LocalSearch。

python advbox_tools.py -uhttp://your ip:9000

经过迭代攻击后,展现攻击结果如下图所示,具体运行时间依赖于网速,强烈建议在本机上起docker服务,可以大大提升攻击速度。

localsearch.py[line:293] INFOtry 3 times  selected pixel indices:[ 023 24 25 26]

localsearch.py[line:308] INFOadv_label=504 adv_label_pro=0.00148941285443

localsearch.py[line:293] INFOtry 4 times  selected pixel indices:[ 022 23 24 25]

localsearch.py[line:308] INFOadv_label=463 adv_label_pro=0.00127408828121

attack success,original_label=504, adversarial_label=463

Save file :adversary_image.jpg

LocalSearchAttack attack done.Cost time 100.435777187s

2.jpg

ONNX为例,目前PaddlePaddle、PyTorch、Caffe2、MxNet、CNTK、ScikitLearn均支持把模型保存成ONNX格式。对于ONNX格式的文件,使用类似的命令启动docker环境即可。

docker run -it --rm \

      -e https_proxy=${https_proxy} \

      -p 9000:9000 \

      sleepsonthefloor/graphpipe-onnx:cpu \

     --value-inputs=https://oracle.github.io/graphpipe/models/squeezenet.value_inputs.json\

     --model=https://oracle.github.io/graphpipe/models/squeezenet.onnx \

      --listen=0.0.0.0:9000


advbox_tools.py提供了丰富的配置参数,其中LocalSearch算法相关参数的设置可以参考论文[1]

Usage: advbox_tools.py[options]  

Options:

  -h, --help            show this help message and exit

  -u URL, --url=URL     graphpipe url [default:http://127.0.0.1:9000]

  -m M, --model=M       Deep learning frame [default: onnx];must be in

                        [onnx,tersorflow]

  -R R, --rounds=R      An upper bound on the number ofiterations [default:

                        200]

  -p P, --p-parameter=P

                        Perturbation parameterthat controls the pixel

                        sensitivity estimation[default: 0.3]

  -r R, --r-parameter=R

                        Perturbation parameterthat controls the cyclic

                        perturbation;must be in[0, 2]

  -d D, --d-parameter=D

                        The half side length ofthe neighborhood square

                        [default: 5]

  -t T, --t-parameter=T

                        The number of pixelsperturbed at each round [default:

                        5]

  -i INPUT_FILE, --input-file=INPUT_FILE

                        Original image file[default: mug227.png]

  -o OUTPUT_FILE, --output-file=OUTPUT_FILE

                        Adversary image file[default: adversary_image.jpg]

  -c C, --channel_axis=C

                        Channel_axis [default:0] ;must be in 0,1,2,3



支持PyTorch、MxNet


AdvBox从0.4版开始支持PyTorch、MxNet,目前原生支持PaddlePaddle、PyTorch、Caffe2、MxNet、Keras以及TensorFlow平台,方便广大开发者和安全工程师可以使用自己熟悉的框架。


新版教程上线


AdvBox从0.4版开始,支持使用Jupyter Notebook格式的ebook教程,便于用户快速掌握。

3.jpg

结语


AdvBox今天发布0.4版本,支持零编码黑盒攻击,即使是不熟悉任何深度学习框架的用户也可以使用命令行工具对指定的深度学习模型生成对抗样本。上线新版电子教程,通过Jupyter Notebook更加详细的介绍如何使用AdvBox,进一步降低了使用门槛。新增支持了PyTorch、MxNet,便于使用PyTorch、MxNet的用户快速便捷的生成对抗样本。


参考文献:[1] Narodytska N , Kasiviswanathan S P . Simple Black-Box Adversarial Perturbations for Deep Networks[J]. 2016.



0
现金券
0
兑换券
立即领取
领取成功