返回模型
说明文档
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 适用于以下场景:
- 内容审核 - 自动检测图片分享平台上的带水印内容。
- 数据集清洗 - 从训练数据集中过滤掉带水印的图像。
- 版权保护 - 监控和标记带水印媒体的使用情况。
- 数字取证 - 支持对被篡改或受保护的媒体资产进行分析。
bdsqlsz/Watermark-Detection-SigLIP2-onnx
作者 bdsqlsz
image-classification
transformers
↓ 0
♥ 1
创建时间: 2025-05-14 07:17:39+00:00
更新时间: 2025-05-14 08:24:45+00:00
在 Hugging Face 上查看文件 (4)
.gitattributes
README.md
model.onnx
ONNX
preprocessor_config.json