|
9 months ago | |
---|---|---|
tests | 9 months ago | |
watermark_generate | 9 months ago | |
.gitignore | 9 months ago | |
MANIFEST.in | 9 months ago | |
README.md | 9 months ago | |
setup.py | 9 months ago |
master
分支只包含项目打包配置和密码标签获取,数据集嵌入黑盒水印源码pip install -r requirements.txt
.
├── 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 # 密码标签生成与验证工具,需要根据密码机实际提供接口进行修改,目前只有模拟实现
Base URLs:
POST /znwr/jit/ai/v1/log_setting
Body 请求参数
{
"level": "string",
"size": 0
}
名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
---|---|---|---|---|---|
body | body | object | 否 | none | |
» level | body | string | 是 | 输出日志级别 | debug、info、warning、error |
» size | body | number | 是 | 日志最大大小限制 | 单位KB |
返回示例
200 Response
{
"code": 0,
"msg": "string"
}
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | VerifyLabelResp |
POST /znwr/jit/ai/v1/crypto-label
Body 请求参数
{
"info": {
"owner": {
"name": "string",
"id": "string"
},
"model": {
"name": "string",
"id": "string",
"version": "string",
"date": "2019-08-24T14:15:22Z"
}
}
}
名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
---|---|---|---|---|---|
body | body | GenLabelForm | 否 | none |
返回示例
200 Response
{
"code": 0,
"msg": "string",
"label": "string",
"cert": "string"
}
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | GenLabelResp |
POST /znwr/jit/ai/v1/crypto-check
返回示例
200 Response
{
"code": 0,
"msg": "string"
}
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | VerifyLabelResp |
POST /znwr/jit/ai/v1/picture_embed
Body 请求参数
file: string
label: string
名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
---|---|---|---|---|---|
body | body | object | 否 | none | |
» file | body | string(binary) | 否 | 待嵌入的图像信息 | |
» label | body | string | 否 | 密码标签 |
返回示例
200 Response
{
"code": 0,
"msg": "string"
}
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | VerifyLabelResp |
POST /znwr/jit/ai/v1/picture_check
返回示例
200 Response
{
"code": 0,
"msg": "string"
}
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | VerifyLabelResp |
POST /znwr/jit/ai/v1/verify-label
Body 请求参数
{
"label": "string",
"info": "string",
"cert": "string"
}
名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
---|---|---|---|---|---|
body | body | VerifyLabelForm | 否 | none |
返回示例
200 Response
{
"code": 0,
"msg": "string"
}
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | VerifyLabelResp |
POST /znwr/jit/ai/v1/picture_extract
Body 请求参数
file: file://C:\Users\hikari\Desktop\test_embed.jpg
名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
---|---|---|---|---|---|
body | body | object | 否 | none | |
» file | body | string(binary) | 否 | none |
返回示例
200 Response
{
"code": 0,
"msg": "string",
"label": "string"
}
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | ExtractLabelResp |
{
"code": 0,
"msg": "string",
"label": "string"
}
名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
---|---|---|---|---|---|
code | integer | true | none | 错误码 | none |
msg | string | true | none | 错误信息 | none |
label | string | true | none | 密码标签 | none |
{
"code": 0,
"msg": "string"
}
名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
---|---|---|---|---|---|
code | integer | true | none | 错误码 | none |
msg | string | true | none | 错误信息 | none |
{
"code": 0,
"msg": "string"
}
名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
---|---|---|---|---|---|
code | integer | true | none | 错误码 | none |
msg | string | true | none | 错误信息 | none |
{
"label": "string",
"info": "string",
"cert": "string"
}
名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
---|---|---|---|---|---|
label | string | true | none | 密码标签 | none |
info | string | true | none | 模型信息 | none |
cert | string | true | none | 签名证书 | none |
{
"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格式 |
{
"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 |
from watermark_generate.tools.dataset_process import dataset_embed_label, process_dataset_label
from watermark_generate.tools.picture_watermark import extract
if __name__ == '__main__':
label = '012ABCDEF'
src_img_path = '../VOC2007/test/'
dst_img_path = '../VOC2007/test_wm'
label_path = '../VOC2007/test_labels'
# 图片嵌入密码标签
dataset_embed_label(label, src_img_path, dst_img_path)
# 数据集处理测试
process_dataset_label(dst_img_path, label_path, percentage=5)
# 水印提取测试
secret = extract('../VOC2007/test_wm/000044.jpg', secret_len=len(label))
print(label == secret)
python setup.py sdist
项目目录会生成dist
目录,其中watermark_generate-1.0.tar.gz
即为发布包
pip install watermark_codec-1.0.tar.gz