AI 工具

LiblibAI 社区模型许可:商用与肖像用途检查

使用社区 checkpoint/LoRA 前检查作者声明的商用、训练肖像、换脸与 NSFW 渠道限制。

BINBHO · 图文教程

使用社区 checkpoint/LoRA 前检查作者声明的商用、训练肖像、换脸与 NSFW 渠道限制。

先看清成品

  • 许可齐全可商用 → ok;缺声明/禁商用/禁训练 → BLOCK。
  • 2 项 pytest 通过。

合规提醒:社区模型许可各异,商用前读模型详情页。不使用侵权模型,不训练未经授权的人物或作品,不做未同意换脸。国内发布遵守 AI 生成内容标识与平台规则。API 积分与网页会员积分通常不通用。本文不编造价格。

运行说明:无正式 LIBLIB_ACCESS_KEY/SECRET。A/B 用 mock(校验 AccessKey 查询参数;HMAC 仍按官方算法生成)。C 为模型许可门禁。2026-10-23(Asia/Shanghai)pytest 通过。

做完之后你会得到什么?

成果 说明
model_license_guard.py 门禁
样例 JSON model/use
test_114c.py 测试

需要准备哪些环境?

项目 说明
Python 3.10+

关键事实

事实 来源
每个模型许可可能不同 产品重要说明
API 可商用模型集合与网页展示需自行核对 开放平台对比表
本 JSON 快照需人工从模型页抄录 重要

文件结构

114-liblib-ai-C-src/
├── model_license_guard.py
├── sample_model_ok.json
├── sample_use_ok.json
├── sample_model_bad.json
├── sample_use_bad.json
└── test_114c.py

第 1 步:门禁

#!/usr/bin/env python3
"""使用社区模型前检查许可字段(教学门禁)。

每个模型作者自定许可:商用、衍生、训练他人肖像等。脚本读模型详情快照 JSON。
"""
from __future__ import annotations
import argparse, json, sys
from pathlib import Path


def check(model: dict, use: dict) -> dict:
    reasons = []
    lic = (model.get("license") or {}).copy()
    if lic.get("allowCommercial") is False and use.get("commercial"):
        reasons.append("model forbids commercial use")
    if use.get("train_likeness") and not lic.get("allowTrainLikeness"):
        reasons.append("training likeness not allowed")
    if use.get("face_swap") and not lic.get("allowFaceSwap"):
        reasons.append("face swap not allowed")
    if model.get("nsfw_flag") and use.get("safe_for_work_channel"):
        reasons.append("NSFW model blocked for SFW channel")
    if not model.get("author_declared_license"):
        reasons.append("missing author_declared_license — read model page first")
    return {"ok": not reasons, "reasons": reasons, "model_id": model.get("id")}


def main(argv=None) -> int:
    ap = argparse.ArgumentParser(description=__doc__)
    ap.add_argument("model_json")
    ap.add_argument("use_json")
    args = ap.parse_args(argv)
    r = check(json.loads(Path(args.model_json).read_text()), json.loads(Path(args.use_json).read_text()))
    print(json.dumps(r, ensure_ascii=False, indent=2))
    return 0 if r["ok"] else 1


if __name__ == "__main__":
    raise SystemExit(main())

第 2 步:测试

import json, subprocess, sys
from pathlib import Path
HERE = Path(__file__).resolve().parent

def test_ok():
    r = subprocess.run([sys.executable, str(HERE/"model_license_guard.py"),
                        str(HERE/"sample_model_ok.json"), str(HERE/"sample_use_ok.json")],
                       capture_output=True, text=True)
    assert r.returncode == 0 and json.loads(r.stdout)["ok"]

def test_bad():
    r = subprocess.run([sys.executable, str(HERE/"model_license_guard.py"),
                        str(HERE/"sample_model_bad.json"), str(HERE/"sample_use_bad.json")],
                       capture_output=True, text=True)
    assert r.returncode == 1
    assert len(json.loads(r.stdout)["reasons"]) >= 2

第 3 步:运行

$ pytest 114c
..                                                                       [100%]
2 passed in 0.05s

怎么检查结果?

  • ok 样例 exit 0。
  • bad 样例 reasons ≥ 2。

调试示例

「热门模型大家商用」。 无效。以该版本详情页许可为准,抄进 JSON 再跑门禁。

常见问题

现象 原因 处理
LoRA 叠加 每个都查 取最严
自训 LoRA 仅用自有/授权素材 见训练须知
星流官方模型 看星流条款 与社区分开

模板规则

  • 无声明不用。
  • 禁换脸就禁。
  • SFW 渠道拒 NSFW 模。

项目资源

用途 地址
LiblibAI https://www.liblib.art
API 开放平台(官方) https://www.liblib.art/apis

模型能出图,不代表你能商用。