Skip to content

MPSFuzz/AI_TEST

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

245 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This code achieves an interface, receiving the POST and GET then scheduling several docker containers where adversarial samples are generated.

Now it implemented to Task 16, docker link and security-enhance modes have been implemented.

Usage

  • setting with ip and port in gunicorn.conf.py, as follows:
workers = 5

worker_class = "gevent"

bind = "127.0.0.1:5901" // ip and port

Caution

为方便日志保存,run.sh 中的运行逻辑有所修改

  • 运行 ./run.sh 来启动调度中心。此时调度中心进程将运行于后台,./run.sh 将立即返回。原先的控制台输出将保存在 log 文件夹下的 access_logerror_log 中。
./run.sh
log
├── access_log
└── error_log
  • 利用 stop.sh 停止调度中心进程。run.sh 会将调度中心进程的 pid 写入文件中,stop.sh 读取该 pid 并停止调度中心进程。
./stop.sh

Debug mode

//in the url blank:

curl -X POST http://127.0.0.1:5901/adver_gen \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "mission_id=123&test_model=Vgg16&test_weight=weightA&test_seed=seed1&test_method=FGSM&timeout=3600"  \
--noproxy 127.0.0.1     ***if you has set proxy, this option should be added***
curl -X POST http://127.0.0.1:5901/adver_gen_stop \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "mission_id=123" \
--noproxy 127.0.0.1
curl -X POST http://127.0.0.1:5901/adver_eval \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "mission_id=123&eval_metric=abc" \
--noproxy 127.0.0.1
curl -X POST http://127.0.0.1:5901/sec_enhance \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "enhance_id=777&test_model=Vgg16&mission_id=12" \
--noproxy 127.0.0.1

调试运行tips

现版本代码需要调试运行的话请将 interface_main.py中model6-model8中的诸如:

        model_dict = init_read_yaml_for_model_duplicate()

        docker_shell_run = model_dict[test_model].get('docker_container_run_shell')

        container_id, script_path = docker_shell_run.split(":", 1)

        shell_command = f"{script_path} {test_model} {test_weight} {test_seed} {test_method}"

        shell_path = f"{container_id}:{shell_command}"

        exec_docker_container_shell(shell_path)

这部分代码注释掉后(后端还未对接docker引擎)即可正常的调试运行。

若当前后端存在docker引擎的运行环境,即可使用对应的curl命令进行调试,注意参数--noproxy 127.0.0.1最好加上,不然可能会报错

调试运行之前注意yaml文件中各个路径等参数的配置,特别是诸如docker_id之类的,随环境变化而变化的部分,如:

weight_download_addr: 5334338a5dfe:/usr/weight.txt

注意这里的5334338a5dfe就要改成自己docker环境的docker_id

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 99.6%
  • Shell 0.4%