README.md 3.18 KB
Newer Older
Carl De Sousa Trias's avatar
Carl De Sousa Trias committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# MPAI-NNW v1.2 implementation 
## Case 2

This code refers to the implementation of the MPAI-NNW under MPAI-AIF, as described in https://mpai.community/wp-content/uploads/2023/10/Reference-Software-Neural-Network-Watermarking-V1.pdf.
All the code is based in Python.

**Implemented APIs**
1. MPAI_AIFS_GetAndParseArchive, unzip and parse json and AIMs.
2. MPAI_AIFM_AIM_{Start,Pause,Resume,Stop,GetStatus}, to process on AIM/AIW. 
3. MPAI_AIFM_Port_Input_{Write,Read,Reset}, to process on the port of the AIMs.

**Controller/User Agent**
1. Controller is deployed under the socket library (waiting request from _input.py_).
2. User Agent can trigger and run command by sending inputs.
3. _config.py_ shares some variables among the different files.

**Folders**
- **all_AIW** stores all the different AIW that are implemented 
  - NNWImp,NNWRob for the controller_NNW
- **resources** external elements for some use cases (uncorrelated images for ADI, context/question of the MQA, ...)
- **Attacks** contains all the specified attacks of MPAI-NNW under the PyTorch Framework.


**Specificity to MPAI-NNW**
1. _utils.py_ contains function link to the dataset/dataloader under the PyToch framework.
2. _UCHIDA.py_ / _ADI.py_ correspond to the Neural Network Watermarking technology under evaluation.
3. AIW.zip is composed of the corresponding .json and the AIMs as Python file.

## Installation
Code was designed and tested on an Ubuntu 20.04 operating system using anaconda 23.7.2 and Python 3.9.
An environment with all the necessary libraries can be created using:
```bash
conda create --name <env> --file requirements.txt
```

## Run
**Initialisation**
First the Controller should be initialized (the command '-W ignore' can be added to avoid warning message during execution):
```bash
conda activate <env>
python controller.py
Controller Initialized
```
To send commands to the controller as a user agent, 
a second terminal should be open, and run:
```bash
conda activate <env>
python input.py
input: <your command>
```

**Emulation of MPAI Store**

Emulate the folder of the computer as a website using the command:
```bash
python3 -m http.server
```
Then the command simulate the downloading of the AIW from a website:
```bash
conda activate <env>
python input.py
input: wget http://0.0.0.0:8000/[yourpath]/AIW.zip
```


### **List of command for controller_NNW**

This command will open a window for the selection of the AIW.zip folder:
```bash
(env) python input.py
input: getparse
```
This command will open set the Computational Cost flag ON:
```bash
(env) python input.py
input: ComputationalCost True
```
This command will open run the Robustness AIW with the **1** Modification and **{"P":0.5}** Parameters
```bash
(env) python input.py
input: run robustness 1 {"P":0.5}
```
This command will open run the Imperceptibility AIW with **vgg16** as watermarked AIM and trained on the **CIFAR10** dataset
```bash
(env) python input.py
input: run imperceptibility vgg16 cifar10
```

### Some warnings
1. The AIW should be named AIW.zip and contained the .json and the needed AIMs.
2. The code does not permit misspelling.

# Licence
94
[Licence](https://mpai.community/standards/mpai-nnw/framework-licence/) information are detailed in the MPAI website.