Files
aigc-home/docs/hel-892/watermark-document-evidence/build_layer_editorial.py
T

111 lines
4.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"Review exact registry package, not an inferred Git revision."
import hashlib
import json
from pathlib import Path
OUT = Path(__file__).resolve().parent
REF = OUT.parent / "watermark-reference"
def main():
sources = []
def cite(file, lines, claim):
p = REF / ("layer__" + file.replace("/", "__"))
raw = p.read_bytes()
sources.append(
dict(
id="layer-registry-2.0.38",
repository=("https://github.com/chflame163/ComfyUI_LayerStyle_Advance"),
commit="unknown",
git_commit_binding="unknown",
file=file,
local_file="../watermark-reference/" + p.name,
url=("https://cdn.comfy.org/chflame163/ComfyUI_LayerStyle_Advance/2.0.38/node.zip"),
sha256=hashlib.sha256(raw).hexdigest(),
lines=lines,
claim=claim,
registry_version="2.0.38",
registry_release_id="db305def-250b-448d-88b6-e43acbeb03af",
)
)
for file, lines, claim in [
("__init__.py", [1, 49], "准确包按py/*.py合并注册"),
("py/watermark.py", [1, 126], "Add/Show准确注册、IMAGE接口、批次/灰度/YCbCr与恢复输出"),
("py/imagefunc.py", [1295, 1381], "水印尺寸公式、临时PNG、blind_watermark调用与异常回退"),
("py/imagefunc.py", [119, 149], "PIL/tensor归一化与量化"),
("py/imagefunc.py", [791, 805], "normalize_gray亮度拉伸"),
("py/imagefunc.py", [1053, 1086], "YCbCr分离/通道合并"),
("py/imagefunc.py", [1737, 1742], "RGBA恢复alpha"),
("pyproject.toml", [1, 16], "精确2.0.38身份、仓库、MIT许可与未固定版本blind-watermark依赖"),
(
"LICENSE",
[1, len((REF / "layer__LICENSE").read_text().splitlines())],
"准确包MIT许可全文",
),
]:
# Range bounded by exact file, not a nearby release.
n = len((REF / ("layer__" + file.replace("/", "__"))).read_text().splitlines())
lines[1] = min(lines[1], n)
cite(file, lines, claim)
flow = [
(
"盲水印准确来源为Registry comfyui_layerstyle_advance 2"
".0.38发行包(发布ID db305def-250b-448d-88b6-e43acbe"
"b03af),包pyproject确认仓库与版本;未提供Git完整commit绑定,com"
"mit明确unknown,不借其它LayerStyle或最新版。只以HTTP Range读"
"取目录与必要Python/许可文本,没有下载包内图片/字体/权重。"
),
(
"Add1固定实现按底图批次循环,水印批次不足复用最后一张(空水印批次不保证安全);wm_s"
"ize=int(sqrt(width×height×0.015625)×0.9),内容图缩"
"至wm_size方形L灰度;底图转YCbCr,在U通道嵌入后合回,原RGBA时恢复原alp"
"ha。极小/异常尺寸、空批次/实际媒体支持和效果未知,不执行算法。"
),
(
"包imagefunc写临时PNG,调用blind_watermark.WaterMark("
"password_img=1,password_wm=1),read_img/read_w"
"m后embed(compression_ratio=100)。依赖只写blind-wate"
"rmark未锁版本:不据其它版本补DWT/DCT算法、容量/尺寸条件或鲁棒性;目录/文件失"
"败分支并非已验证正常输出,未知明确保留。"
),
(
"Show8/16固定实现按输入图尺寸重算wm_size,取YCbCr的U通道,经Water"
"Mark.extract(wm_shape=(wm_size,wm_size))再灰度拉伸"
",缩至512×512、再normalize_gray、转RGB tensor。extrac"
"t异常代码先回退黑色64×64再后处理;看见预览不证明提取成功,当前未运行。"
),
]
add = (
"原[]零保存位置,只有image与watermark_image必需IMAGE输入,返回i"
"mage槽0;准确2.0.38代码缩方形灰度水印、嵌入YCbCr U通道、批次不足复用最后"
"水印,真实依赖/尺寸/效果未知。"
)
show = (
"原[]零保存位置,只有image必需IMAGE输入,返回waterma"
"rk_image槽0;准确2.0.38按尺寸提取U通道水印、512方形"
"RGB结果与异常回退,不证明成功。"
)
b = dict(
sources=sources,
flow=flow,
zero_effects={
"LayerUtility: AddBlindWaterMark": add,
"LayerUtility: ShowBlindWaterMark": show,
},
versions=[
(
"LayerStyle Advance按准确Registry2.0.38包固定,Git co"
"mmit绑定unknown;包MIT许可原文保留。blind-watermark依赖版本未"
"锁、算法内部/实际安装与鲁棒性未知。"
)
],
)
(OUT / "layer-editorial.json").write_text(json.dumps(b, ensure_ascii=False, indent=2) + "\n")
if __name__ == "__main__":
main()