# 图片内容审核
**请求方式:** GET|POST
**接口地址:** https://api.hk0.cc/api/imgmod
**接口描述:** 图片内容安全审核,HTTP 同步返回,兼容腾讯云图片内容安全(IMS ImageModeration)响应结构,Suggestion 取值 Pass / Review / Block。
检测能力:
视觉侧本地 NSFW 模型(Marqo ViT-384)识别色情/裸露,输出 0-1 概率后按阈值判定;
文字侧 PP-OCRv4 抽取图内文字并联动文本审核引擎,覆盖微信号、扫码导流、联系方式、广告话术、涉政涉黄词;
二维码不解码,二维码旁的导流文字会被文字侧命中。
输入方式(四选一):
url 图片地址,http/https,单张不超过 10MB
image 图片 Base64,可带 data:image 前缀,建议 POST 提交(GET 会被 URL 长度限制)
file multipart 上传,字段名 file,单张不超过 10MB
images 批量检测,最多 4 张,JSON 数组、逗号分隔 URL 或对象数组,返回 Results 与最严汇总结论
参数:
engine visual 仅视觉 / text 仅文字 / hybrid(默认)视觉+文字
visual_mode fast(默认,整图+中心裁剪)/ thorough(追加 2x2 切片,召回更高,耗时约 +60%)
scene 文字审核场景 comment(默认)/ nickname / profile / article
block_threshold 视觉拦截阈值,默认 0.90
review_threshold 视觉复核阈值,默认 0.65,需不大于 block_threshold
custom_words 自定义词库,逗号分隔,命中项按 custom_action 处理
custom_action block(默认)/ review
regions 1 返回 OCR 行级坐标 OcrDetails
mask 1(默认)关键词与 OcrText 打码 / 0 保留原文
detail 1(默认)全量返回 / 0 精简,仅 Label、Suggestion、Score、Keywords
fresh 1 跳过缓存强制重算
ttl 缓存秒数 0-86400,默认 600,0 表示不写缓存
BizType 原样回传,默认 image_moderation
返回字段:
Response.Label Normal / Porn / Ad / Illegal / Polity / Terror
Response.SubLabel 细分标签,当前为空
Response.Suggestion Pass / Review / Block
Response.Score 风险分 0-100
Response.Keywords 命中关键词(默认打码)
Response.OcrText 图内文字
Response.DetailResults 分库明细:visual-nsfw 视觉色情、contact 联系方式、ad 广告导流、misc 其他敏感、custom-words 自定义词库
Response.OcrDetails regions=1 时返回,含 text、score、box [x1,y1,x2,y2],坐标基于分析尺寸(见 Extra.image.analyzed_size)
Response.Extra JSON 字符串:verdict、action_text、risk_text、category_text、visual_score、visual_crops、thresholds、image(format/bytes/md5/尺寸)、elapsed_ms、cached
错误码(HTTP 200 + Response.Error):
InvalidParameter 参数不合法
InvalidImageUrl 地址非法、解析失败或指向内网/保留地址
DownloadFailed 图片下载失败或超时
ImageTooLarge 超过 10MB
UnsupportedImageFormat 非图片或图片损坏
ServiceUnavailable 审核服务不可用
InternalError 服务内部异常
性能:视觉单次推理约 39ms,OCR 约 200-400ms;首次调用(下载+双引擎)约 450-900ms,同图同参 10 分钟内缓存命中约 170-260ms。
鉴黄说明:NSFW 为 0-1 概率二分类,≥0.90 拦截、≥0.65 复核,可识别裸露与硬色情;不做性感/擦边细粒度分级,涉政暴恐视觉类别未覆盖,靠 OCR 文字与词库兜底。
并发与容量:OCR 采用 4 实例池,单请求首调 0.4-0.9s,缓存命中 0.15-0.3s;建议单机 QPS 控制在 4-8,更高并发会排队、耗时线性上升。单次请求最多 4 张图片,建议 Base64 与文件上传走 POST。
u8c03u7528u65b9u5f0fuff08u8bf7u6c42u4f53u4e0au9650 16MBuff0cu5355u5f20u56feu7247u89e3u7801u540e 10MBuff09uff1a
1. GET u76f4u94feuff1a?url=https://example.com/a.jpguff08u63a8u8350uff0cu6700u7701u6d41u91cfuff09
2. POST JSONuff1a{"image": "<Base64 u6216 data:image/...;base64,...>"}uff0cu5927u56feu4e0e Base64 u5fc5u987bu7528u8fd9u79cdu65b9u5f0f
3. POST u8868u5355uff1aimage=<Base64>uff08application/x-www-form-urlencodeduff09
u6ce8u610fuff1au7f51u5173u4e0du652fu6301 multipart u76f4u63a5u4e0au4f20uff0cu4e8cu8fdbu5236u56feu7247u8bf7u5148u8f6c Base64uff1bBase64 u4e0du8981u653eu5728 GET query u91ccuff0cURL u8d85u8fc7 32KB u4f1au8fd4u56de 414 u63d0u793au6539u7528 POSTu3002
u7f13u5b58u7b56u7565uff1a
u7ed3u679cu9ed8u8ba4u7f13u5b58 600 u79d2uff0cttl u53c2u6570u53efu8bbe 0-86400uff080 u8868u793au4e0du5199u7f13u5b58uff09uff0cfresh=1 u8df3u8fc7u7f13u5b58u5f3au5236u91cdu65b0u68c0u6d4buff1bttl u540cu65f6u7ea6u675fu8bfbu53d6u6709u6548u671fuff0cu8c03u5c0fu540eu7acbu5373u751fu6548u3002
u7f13u5b58u4f4du4e8eu5185u5b58u76d8 /dev/shmuff0cu4e0au9650 20000 u6761u3001512MBuff0cu8d85u51fau540eu6309u6700u65e7u8bb0u5f55u6dd8u6c70u5230 70%uff1bu670du52a1u6bcf 60 u79d2u6e05u7406u8fc7u671fu9879uff0cu91cdu542fu65f6u4e5fu4f1au5148u6e05u7406u4e00u6b21uff0cu907fu514du957fu671fu8fd0u884cu5806u79efu3002
## 请求参数
| 参数名 | 可传值说明 | 传入位置 | 是否必填 | 示例值 | 默认值 | 参数说明 |
|--------|----------|----------|----------|--------|--------|----------|
| url | https://api.hk0.cc/imgs/imgmod-demo.png | query | 可选 | https://api.hk0.cc/imgs/imgmod-demo.png | (空字符串) | u56feu7247u5730u5740uff0chttp/httpsuff0cu4e0e image u4e8cu9009u4e00uff1bu5355u5f20u4e0du8d85u8fc7 10MBuff0cu652fu6301 302 u8df3u8f6cuff0cu5185u7f51u4e0eu4fddu7559u5730u5740u4f1au88abu62d2u7edd |
| image | | body | 可选 | (空字符串) | (空字符串) | u56feu7247 Base64uff0cu53efu5e26 data:image u524du7f00uff0cu4e0e url u4e8cu9009u4e00uff1bu5efau8bae POST JSON u63d0u4ea4uff0cu89e3u7801u540eu4e0du8d85u8fc7 10MBuff1bu4e0du8981u653eu5728 GET query u4e2d |
| engine | hybrid | query | 可选 | hybrid | hybrid | 检测引擎:hybrid 视觉+文字(默认);visual 仅视觉(最快);text 仅 OCR 文字审核 |
| scene | comment | query | 可选 | comment | comment | 图内文字审核场景:comment 评论(默认)、nickname 昵称、profile 简介、article 正文 |
| block_threshold | 0.90 | query | 可选 | 0.90 | 0.90 | 视觉拦截阈值 0-1,默认 0.90,越高越宽松;须不小于 review_threshold |
| review_threshold | 0.65 | query | 可选 | 0.65 | 0.65 | 视觉复核阈值 0-1,默认 0.65;须不大于 block_threshold |
| BizType | image_moderation | query | 可选 | image_moderation | image_moderation | 业务类型标识,原样回传,默认 image_moderation |
| images | | body | 可选 | ["https://api.hk0.cc/imgs/imgmod-demo.png"] | (空字符串) | u6279u91cfu56feu7247uff0cJSON u6570u7ec4 / u9017u53f7u5206u9694 URL / u5bf9u8c61u6570u7ec4uff08u5bf9u8c61u5185u7528 url u6216 imageuff09uff0cu6700u591a 4 u5f20uff1bu8fd4u56de Results u6570u7ec4u4e0eu6700u4e25u6c47u603bu7ed3u8bba |
| visual_mode | fast | query | 可选 | fast | fast | 视觉检测模式:fast 整图+中心裁剪(默认);thorough 追加 2x2 切片,召回更高,耗时约 +60% |
| detail | 1 | query | 可选 | 1 | 1 | 1 返回全量结果(默认);0 精简返回,仅 Label、Suggestion、Score、Keywords |
| regions | 0 | query | 可选 | 0 | 0 | 1 时返回 OcrDetails,包含图内文字行级坐标与置信度 |
| mask | 1 | query | 可选 | 1 | 1 | 1 关键词与自定义词打码(默认);0 时 OcrText 不打码(文字审核引擎命中词本身仍为脱敏结果) |
| fresh | 0 | query | 可选 | 0 | 0 | 1 跳过缓存强制重新检测 |
| ttl | 600 | query | 可选 | 600 | 600 | u7ed3u679cu7f13u5b58u79d2u6570uff0c0-86400uff0cu9ed8u8ba4 600uff1b0 u8868u793au4e0du5199u7f13u5b58uff0cu540cu65f6 ttl u4f1au9650u5236u5df2u6709u7f13u5b58u7684u8bfbu53d6u6709u6548u671f |
| custom_words | | query | 可选 | 扫码,免费领取 | (空字符串) | 自定义词库,逗号分隔,命中图内 OCR 文字即按 custom_action 处理 |
| custom_action | block | query | 可选 | block | block | 自定义词库命中后的处置:block 拦截(默认)/ review 复核 |
## 返回示例
```json
{
"Response": {
"Label": "Ad",
"SubLabel": "",
"Suggestion": "Review",
"Keywords": [
"微**********",
"Q********",
"加**",
"扫***",
"q*",
"联**"
],
"Score": 65,
"OcrText": "加微信abc_12345领取福利\n联系电话138-0000-0000\n扫码进群每日更新资源\nWeChat: test1234 QQ: 10001",
"DetailResults": [
{
"Label": "Porn",
"SubLabel": "",
"Suggestion": "Pass",
"Keywords": [],
"Score": 21,
"LibId": "visual-nsfw",
"LibName": "图像色情识别"
},
{
"Label": "Ad",
"SubLabel": "",
"Suggestion": "Review",
"Keywords": [
"微**********",
"Q********"
],
"Score": 50,
"LibId": "contact",
"LibName": "联系方式"
},
{
"Label": "Ad",
"SubLabel": "",
"Suggestion": "Review",
"Keywords": [
"加**",
"扫***",
"q*"
],
"Score": 45,
"LibId": "ad",
"LibName": "广告导流"
},
{
"Label": "Illegal",
"SubLabel": "",
"Suggestion": "Review",
"Keywords": [
"联**"
],
"Score": 35,
"LibId": "misc",
"LibName": "其他敏感"
}
],
"BizType": "image_moderation",
"Extra": "{\"verdict\": \"疑似\", \"action\": \"review\", \"action_text\": \"人工复核\", \"risk_level\": \"medium\", \"risk_text\": \"中风险\", \"category_text\": \"广告导流\", \"scene\": \"comment\", \"engine\": \"hybrid\", \"visual_mode\": \"fast\", \"visual_score\": 0.2083, \"visual_crops\": [{\"crop\": \"full\", \"score\": 0.2083}, {\"crop\": \"center\", \"score\": 0.0963}], \"ocr_lines\": 4, \"custom_words_hit\": [], \"thresholds\": {\"block\": 0.9, \"review\": 0.65}, \"image\": {\"source\": \"https://api.hk0.cc/imgs/imgmod-demo.png\", \"format\": \"PNG\", \"bytes\": 34541, \"origin_size\": [900, 420], \"analyzed_size\": [900, 420], \"md5\": \"c95b732a387a731120dfa9ad19d2e1aa\"}, \"elapsed_ms\": 512, \"cached\": false}",
"OcrDetails": [
{
"text": "加微信abc_12345领取福利",
"score": 0.9989,
"box": [
43,
46,
468,
80
]
},
{
"text": "联系电话138-0000-0000",
"score": 0.9994,
"box": [
41,
117,
428,
150
]
},
{
"text": "扫码进群每日更新资源",
"score": 0.9997,
"box": [
39,
183,
391,
221
]
},
{
"text": "WeChat: test1234 QQ: 10001",
"score": 0.9915,
"box": [
40,
255,
490,
295
]
}
],
"RequestId": "72ad38c876f64cab8b679a4971331265",
"elapsed_ms": 686
}
}
```