bdsqlsz/Watermark-Detection-SigLIP2-onnx
By bdsqlsz · ↓ 0 · ♥ 1 · Updated 2025-05-14
What's in this repo
This page lists the files in bdsqlsz/Watermark-Detection-SigLIP2-onnx, including model.onnx.
- 1 ONNX models (.onnx files)
- 4 files, including 1 .md, 1 .onnx, 1 .json
- Last updated 2025-05-14
ONNX files
| File | Size | Download |
|---|---|---|
| model.onnx | — | Download |
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
I'll fetch the README content from the HuggingFace page first.
Watermark-Detection-SigLIP2
Watermark-Detection-SigLIP2 是一个视觉语言编码器模型,基于 google/siglip2-base-patch16-224 微调,用于二分类图像分类。该模型经过训练,可以检测图像是否包含水印,采用 SiglipForImageClassification 架构。
水印检测在清晰高质量的图像上效果最佳。不建议使用噪点较大的图像进行验证。
SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features https://arxiv.org/pdf/2502.14786
Classification Report:
precision recall f1-score support
No Watermark 0.9290 0.9722 0.9501 12779
Watermark 0.9622 0.9048 0.9326 9983
accuracy 0.9427 22762
macro avg 0.9456 0.9385 0.9414 22762
weighted avg 0.9435 0.9427 0.9424 22762
标签空间:2 个类别
模型将图像分类为:
Class 0: "No Watermark" (无水印)
Class 1: "Watermark" (有水印)
安装依赖
pip install -q transformers torch pillow gradio
推理代码
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch
# 加载模型和处理器
model_name = "prithivMLmods/Watermark-Detection-SigLIP2" # 如果使用不同路径,请更新此处
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
# 标签映射
id2label = {
"0": "No Watermark",
"1": "Watermark"
}
def classify_watermark(image):
image = Image.fromarray(image).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
prediction = {
id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
}
return prediction
# Gradio 界面
iface = gr.Interface(
fn=classify_watermark,
inputs=gr.Image(type="numpy"),
outputs=gr.Label(num_top_classes=2, label="Watermark Detection"),
title="Watermark-Detection-SigLIP2",
description="上传图像以检测是否包含水印。"
)
if __name__ == "__main__":
iface.launch()
演示推理
水印









无水印









预期用途
Watermark-Detection-SigLIP2 适用于以下场景:
- 内容审核 - 自动检测图片分享平台上的带水印内容。
- 数据集清洗 - 从训练数据集中过滤掉带水印的图像。
- 版权保护 - 监控和标记带水印媒体的使用情况。
- 数字取证 - 支持对被篡改或受保护的媒体资产进行分析。
Model info
Created: 2025-05-14
Updated: 2025-05-14
View on Hugging Face