|
@@ -1,49 +1,475 @@
|
|
# 密码标签获取,数据集嵌入黑盒水印源码及打包项目
|
|
# 密码标签获取,数据集嵌入黑盒水印源码及打包项目
|
|
## 功能列表
|
|
## 功能列表
|
|
-- [ ] 密码标签生成
|
|
|
|
-- [ ] 密码标签自检(测试)
|
|
|
|
-- [ ] 图像嵌入密码标签
|
|
|
|
-- [ ] 图像处理功能自检
|
|
|
|
-- [ ] 日志模板
|
|
|
|
-- [ ] 日志记录
|
|
|
|
|
|
+- [x] 密码标签生成
|
|
|
|
+- [x] 密码标签自检(测试)
|
|
|
|
+- [x] 密码标签验证
|
|
|
|
+- [x] 图像嵌入密码标签
|
|
|
|
+- [x] 图像提取密码标签
|
|
|
|
+- [x] 图像处理功能自检
|
|
|
|
+- [x] 日志模板
|
|
|
|
+- [x] 日志记录
|
|
|
|
|
|
## 分支说明
|
|
## 分支说明
|
|
- `master`分支只包含项目打包配置和密码标签获取,数据集嵌入黑盒水印源码
|
|
- `master`分支只包含项目打包配置和密码标签获取,数据集嵌入黑盒水印源码
|
|
-- `test`分支在`master`分支基础上添加了测试模型、训练代码、验证代码
|
|
|
|
|
|
|
|
## 安装依赖
|
|
## 安装依赖
|
|
```shell
|
|
```shell
|
|
pip install -r requirements.txt
|
|
pip install -r requirements.txt
|
|
-pip install -U flask-marshmallow
|
|
|
|
```
|
|
```
|
|
## 文件组成
|
|
## 文件组成
|
|
```text
|
|
```text
|
|
|
|
+.
|
|
|
|
+├── MANIFEST.in # 打包过滤文件
|
|
|
|
+├── README.md # 描述文件
|
|
|
|
+├── setup.py # 打包配置文件
|
|
|
|
+├── tests # 测试目录
|
|
|
|
+│ └── test_dataset_process.py # 测试数据集处理
|
|
|
|
+└── watermark_generate # 水印生成源码
|
|
|
|
+ ├── __init__.py
|
|
|
|
+ ├── blind_watermark # 图片嵌入盲水印源码
|
|
|
|
+ │ ├── __init__.py
|
|
|
|
+ │ ├── att.py
|
|
|
|
+ │ ├── blind_watermark.py
|
|
|
|
+ │ ├── bwm_core.py
|
|
|
|
+ │ ├── cli_tools.py
|
|
|
|
+ │ ├── pool.py
|
|
|
|
+ │ └── recover.py
|
|
|
|
+ ├── controller # 对外提供的http接口
|
|
|
|
+ │ ├── __init__.py
|
|
|
|
+ │ ├── dataset_controller.py # 数据集处理接口,包括图片嵌入水印处理、图片提取水印、水印功能自检
|
|
|
|
+ │ ├── log_controller.py # 日志控制接口,支持控制日志级别,控制日志输出大小
|
|
|
|
+ │ └── secret_controller.py # 密码标签生成接口,包括密码标签生成、密码标签验证、密码标签功能自检
|
|
|
|
+ ├── domain # 对外提供http接口的参数与响应
|
|
|
|
+ │ ├── __init__.py
|
|
|
|
+ │ ├── dataset_domain.py
|
|
|
|
+ │ └── secret_domain.py
|
|
|
|
+ ├── requirements.txt # 项目依赖文件,安装依赖使用
|
|
|
|
+ ├── resource # 静态资源文件夹
|
|
|
|
+ │ └── test.jpg # 用于图片水印功能自检的测试图片,可根据需求更改
|
|
|
|
+ ├── run.py # 服务运行脚本
|
|
|
|
+ └── tools #工具脚本目录
|
|
|
|
+ ├── __init__.py
|
|
|
|
+ ├── dataset_process.py # 数据集处理脚本
|
|
|
|
+ ├── logger_tool.py # 日志工具脚本
|
|
|
|
+ ├── picture_watermark.py # 图片水印嵌入提取工具
|
|
|
|
+ └── secret_func.py # 密码标签生成与验证工具,需要根据密码机实际提供接口进行修改,目前只有模拟实现
|
|
|
|
|
|
```
|
|
```
|
|
-## 使用方式
|
|
|
|
-- 密码标签生成
|
|
|
|
|
|
+## AI水印黑盒水印HTTP接口
|
|
|
|
|
|
-```python
|
|
|
|
|
|
+Base URLs:
|
|
|
|
|
|
|
|
+* <a href="http://127.0.0.1:5000">开发环境: http://127.0.0.1:5000</a>
|
|
|
|
+
|
|
|
|
+# Authentication
|
|
|
|
+
|
|
|
|
+## POST 日志调整接口
|
|
|
|
+
|
|
|
|
+POST /znwr/jit/ai/v1/log_setting
|
|
|
|
+
|
|
|
|
+> Body 请求参数
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "level": "string",
|
|
|
|
+ "size": 0
|
|
|
|
+}
|
|
```
|
|
```
|
|
|
|
|
|
-- 密码标签自检
|
|
|
|
-```python
|
|
|
|
|
|
+### 请求参数
|
|
|
|
+
|
|
|
|
+|名称|位置|类型|必选|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|body|body|object| 否 ||none|
|
|
|
|
+|» level|body|string| 是 | 输出日志级别|debug、info、warning、error|
|
|
|
|
+|» size|body|number| 是 | 日志最大大小限制|单位KB|
|
|
|
|
+
|
|
|
|
+> 返回示例
|
|
|
|
+
|
|
|
|
+> 200 Response
|
|
|
|
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string"
|
|
|
|
+}
|
|
```
|
|
```
|
|
-- 图像嵌入密码标签
|
|
|
|
-```text
|
|
|
|
|
|
|
|
|
|
+### 返回结果
|
|
|
|
+
|
|
|
|
+|状态码|状态码含义|说明|数据模型|
|
|
|
|
+|---|---|---|---|
|
|
|
|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|[VerifyLabelResp](#schemaverifylabelresp)|
|
|
|
|
+
|
|
|
|
+# 模型密码标签生成模块
|
|
|
|
+
|
|
|
|
+## POST 密码标签生成
|
|
|
|
+
|
|
|
|
+POST /znwr/jit/ai/v1/crypto-label
|
|
|
|
+
|
|
|
|
+> Body 请求参数
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "info": {
|
|
|
|
+ "owner": {
|
|
|
|
+ "name": "string",
|
|
|
|
+ "id": "string"
|
|
|
|
+ },
|
|
|
|
+ "model": {
|
|
|
|
+ "name": "string",
|
|
|
|
+ "id": "string",
|
|
|
|
+ "version": "string",
|
|
|
|
+ "date": "2019-08-24T14:15:22Z"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
```
|
|
```
|
|
-- 图像处理功能自检
|
|
|
|
-```text
|
|
|
|
|
|
|
|
|
|
+### 请求参数
|
|
|
|
+
|
|
|
|
+|名称|位置|类型|必选|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|body|body|[GenLabelForm](#schemagenlabelform)| 否 ||none|
|
|
|
|
+
|
|
|
|
+> 返回示例
|
|
|
|
+
|
|
|
|
+> 200 Response
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string",
|
|
|
|
+ "label": "string",
|
|
|
|
+ "cert": "string"
|
|
|
|
+}
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 返回结果
|
|
|
|
+
|
|
|
|
+|状态码|状态码含义|说明|数据模型|
|
|
|
|
+|---|---|---|---|
|
|
|
|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|[GenLabelResp](#schemagenlabelresp)|
|
|
|
|
+
|
|
|
|
+## POST 密码标签功能自检
|
|
|
|
+
|
|
|
|
+POST /znwr/jit/ai/v1/crypto-check
|
|
|
|
+
|
|
|
|
+> 返回示例
|
|
|
|
+
|
|
|
|
+> 200 Response
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string"
|
|
|
|
+}
|
|
```
|
|
```
|
|
|
|
+
|
|
|
|
+### 返回结果
|
|
|
|
+
|
|
|
|
+|状态码|状态码含义|说明|数据模型|
|
|
|
|
+|---|---|---|---|
|
|
|
|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|[VerifyLabelResp](#schemaverifylabelresp)|
|
|
|
|
+
|
|
|
|
+## POST 密码标签嵌入图像
|
|
|
|
+
|
|
|
|
+POST /znwr/jit/ai/v1/picture_embed
|
|
|
|
+
|
|
|
|
+> Body 请求参数
|
|
|
|
+
|
|
|
|
+```yaml
|
|
|
|
+file: string
|
|
|
|
+label: string
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 请求参数
|
|
|
|
+
|
|
|
|
+|名称|位置|类型|必选|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|body|body|object| 否 ||none|
|
|
|
|
+|» file|body|string(binary)| 否 ||待嵌入的图像信息|
|
|
|
|
+|» label|body|string| 否 ||密码标签|
|
|
|
|
+
|
|
|
|
+> 返回示例
|
|
|
|
+
|
|
|
|
+> 200 Response
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string"
|
|
|
|
+}
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 返回结果
|
|
|
|
+
|
|
|
|
+|状态码|状态码含义|说明|数据模型|
|
|
|
|
+|---|---|---|---|
|
|
|
|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|[VerifyLabelResp](#schemaverifylabelresp)|
|
|
|
|
+
|
|
|
|
+## POST 图像处理功能自检
|
|
|
|
+
|
|
|
|
+POST /znwr/jit/ai/v1/picture_check
|
|
|
|
+
|
|
|
|
+> 返回示例
|
|
|
|
+
|
|
|
|
+> 200 Response
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string"
|
|
|
|
+}
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 返回结果
|
|
|
|
+
|
|
|
|
+|状态码|状态码含义|说明|数据模型|
|
|
|
|
+|---|---|---|---|
|
|
|
|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|[VerifyLabelResp](#schemaverifylabelresp)|
|
|
|
|
+
|
|
|
|
+# 模型密码标签验证模块
|
|
|
|
+
|
|
|
|
+## POST 密码标签验证
|
|
|
|
+
|
|
|
|
+POST /znwr/jit/ai/v1/verify-label
|
|
|
|
+
|
|
|
|
+> Body 请求参数
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "label": "string",
|
|
|
|
+ "info": "string",
|
|
|
|
+ "cert": "string"
|
|
|
|
+}
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 请求参数
|
|
|
|
+
|
|
|
|
+|名称|位置|类型|必选|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|body|body|[VerifyLabelForm](#schemaverifylabelform)| 否 ||none|
|
|
|
|
+
|
|
|
|
+> 返回示例
|
|
|
|
+
|
|
|
|
+> 200 Response
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string"
|
|
|
|
+}
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 返回结果
|
|
|
|
+
|
|
|
|
+|状态码|状态码含义|说明|数据模型|
|
|
|
|
+|---|---|---|---|
|
|
|
|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|[VerifyLabelResp](#schemaverifylabelresp)|
|
|
|
|
+
|
|
|
|
+## POST 图片提取密码标签
|
|
|
|
+
|
|
|
|
+POST /znwr/jit/ai/v1/picture_extract
|
|
|
|
+
|
|
|
|
+> Body 请求参数
|
|
|
|
+
|
|
|
|
+```yaml
|
|
|
|
+file: file://C:\Users\hikari\Desktop\test_embed.jpg
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 请求参数
|
|
|
|
+
|
|
|
|
+|名称|位置|类型|必选|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|body|body|object| 否 ||none|
|
|
|
|
+|» file|body|string(binary)| 否 ||none|
|
|
|
|
+
|
|
|
|
+> 返回示例
|
|
|
|
+
|
|
|
|
+> 200 Response
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string",
|
|
|
|
+ "label": "string"
|
|
|
|
+}
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 返回结果
|
|
|
|
+
|
|
|
|
+|状态码|状态码含义|说明|数据模型|
|
|
|
|
+|---|---|---|---|
|
|
|
|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|[ExtractLabelResp](#schemaextractlabelresp)|
|
|
|
|
+
|
|
|
|
+# 数据模型
|
|
|
|
+
|
|
|
|
+<h2 id="tocS_ExtractLabelResp">ExtractLabelResp</h2>
|
|
|
|
+
|
|
|
|
+<a id="schemaextractlabelresp"></a>
|
|
|
|
+<a id="schema_ExtractLabelResp"></a>
|
|
|
|
+<a id="tocSextractlabelresp"></a>
|
|
|
|
+<a id="tocsextractlabelresp"></a>
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string",
|
|
|
|
+ "label": "string"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 属性
|
|
|
|
+
|
|
|
|
+|名称|类型|必选|约束|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|code|integer|true|none|错误码|none|
|
|
|
|
+|msg|string|true|none|错误信息|none|
|
|
|
|
+|label|string|true|none|密码标签|none|
|
|
|
|
+
|
|
|
|
+<h2 id="tocS_RespStatus">RespStatus</h2>
|
|
|
|
+
|
|
|
|
+<a id="schemarespstatus"></a>
|
|
|
|
+<a id="schema_RespStatus"></a>
|
|
|
|
+<a id="tocSrespstatus"></a>
|
|
|
|
+<a id="tocsrespstatus"></a>
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 属性
|
|
|
|
+
|
|
|
|
+|名称|类型|必选|约束|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|code|integer|true|none|错误码|none|
|
|
|
|
+|msg|string|true|none|错误信息|none|
|
|
|
|
+
|
|
|
|
+<h2 id="tocS_VerifyLabelResp">VerifyLabelResp</h2>
|
|
|
|
+
|
|
|
|
+<a id="schemaverifylabelresp"></a>
|
|
|
|
+<a id="schema_VerifyLabelResp"></a>
|
|
|
|
+<a id="tocSverifylabelresp"></a>
|
|
|
|
+<a id="tocsverifylabelresp"></a>
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 属性
|
|
|
|
+
|
|
|
|
+|名称|类型|必选|约束|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|code|integer|true|none|错误码|none|
|
|
|
|
+|msg|string|true|none|错误信息|none|
|
|
|
|
+
|
|
|
|
+<h2 id="tocS_VerifyLabelForm">VerifyLabelForm</h2>
|
|
|
|
+
|
|
|
|
+<a id="schemaverifylabelform"></a>
|
|
|
|
+<a id="schema_VerifyLabelForm"></a>
|
|
|
|
+<a id="tocSverifylabelform"></a>
|
|
|
|
+<a id="tocsverifylabelform"></a>
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "label": "string",
|
|
|
|
+ "info": "string",
|
|
|
|
+ "cert": "string"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 属性
|
|
|
|
+
|
|
|
|
+|名称|类型|必选|约束|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|label|string|true|none|密码标签|none|
|
|
|
|
+|info|string|true|none|模型信息|none|
|
|
|
|
+|cert|string|true|none|签名证书|none|
|
|
|
|
+
|
|
|
|
+<h2 id="tocS_GenLabelResp">GenLabelResp</h2>
|
|
|
|
+
|
|
|
|
+<a id="schemagenlabelresp"></a>
|
|
|
|
+<a id="schema_GenLabelResp"></a>
|
|
|
|
+<a id="tocSgenlabelresp"></a>
|
|
|
|
+<a id="tocsgenlabelresp"></a>
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "code": 0,
|
|
|
|
+ "msg": "string",
|
|
|
|
+ "label": "string",
|
|
|
|
+ "cert": "string"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 属性
|
|
|
|
+
|
|
|
|
+|名称|类型|必选|约束|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|code|integer|true|none|错误码|none|
|
|
|
|
+|msg|string|true|none|错误信息|none|
|
|
|
|
+|label|string|true|none|生成标签|base64格式|
|
|
|
|
+|cert|string|true|none|签名证书|base64格式|
|
|
|
|
+
|
|
|
|
+<h2 id="tocS_GenLabelForm">GenLabelForm</h2>
|
|
|
|
+
|
|
|
|
+<a id="schemagenlabelform"></a>
|
|
|
|
+<a id="schema_GenLabelForm"></a>
|
|
|
|
+<a id="tocSgenlabelform"></a>
|
|
|
|
+<a id="tocsgenlabelform"></a>
|
|
|
|
+
|
|
|
|
+```json
|
|
|
|
+{
|
|
|
|
+ "info": {
|
|
|
|
+ "owner": {
|
|
|
|
+ "name": "string",
|
|
|
|
+ "id": "string"
|
|
|
|
+ },
|
|
|
|
+ "model": {
|
|
|
|
+ "name": "string",
|
|
|
|
+ "id": "string",
|
|
|
|
+ "version": "string",
|
|
|
|
+ "date": "2019-08-24T14:15:22Z"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+### 属性
|
|
|
|
+
|
|
|
|
+|名称|类型|必选|约束|中文名|说明|
|
|
|
|
+|---|---|---|---|---|---|
|
|
|
|
+|info|object|true|none|生成标签信息|none|
|
|
|
|
+|» owner|object|true|none|模型所有者信息|none|
|
|
|
|
+|»» name|string|true|none|所有者|none|
|
|
|
|
+|»» id|string|true|none|id|none|
|
|
|
|
+|» model|object|true|none|模型信息|none|
|
|
|
|
+|»» name|string|true|none|模型名|none|
|
|
|
|
+|»» id|string|true|none|模型id|none|
|
|
|
|
+|»» version|string|true|none|模型版本|none|
|
|
|
|
+|»» date|string(date-time)|true|none|创建日期|none|
|
|
|
|
+
|
|
|
|
+
|
|
## 模块打包
|
|
## 模块打包
|
|
```shell
|
|
```shell
|
|
python setup.py sdist
|
|
python setup.py sdist
|
|
```
|
|
```
|
|
-项目目录会生成`dist`目录,其中`watermark_codec-1.0.tar.gz`即为发布包
|
|
|
|
|
|
+项目目录会生成`dist`目录,其中`watermark_generate-1.0.tar.gz`即为发布包
|
|
## 安装模块
|
|
## 安装模块
|
|
```shell
|
|
```shell
|
|
pip install watermark_codec-1.0.tar.gz
|
|
pip install watermark_codec-1.0.tar.gz
|