File size: 6,200 Bytes
d53f229 589597d ebca1d4 589597d ebca1d4 08b568f 589597d 43e5829 b42f6ca 589597d 08b568f 589597d eb33c72 ce32ed8 eb33c72 ce32ed8 eb33c72 ce32ed8 eb33c72 ce32ed8 eb33c72 589597d ce32ed8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
---
license: apache-2.0
datasets:
- qwertyforce/scenery_watermarks
language:
- en
base_model:
- google/siglip2-base-patch16-224
pipeline_tag: image-classification
library_name: transformers
tags:
- Image-Classification
- Watermark-Detection
- SigLIP2
---

# **Watermark-Detection-SigLIP2**
> **Watermark-Detection-SigLIP2** is a vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for **binary image classification**. It is trained to detect whether an image **contains a watermark or not**, using the **SiglipForImageClassification** architecture.
> [!note]
> Watermark detection works best with crisp and high-quality images. Noisy images are not recommended for validation.
> [!note]
*SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features* https://arxiv.org/pdf/2502.14786
```py
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
```

---
## **Label Space: 2 Classes**
The model classifies an image as either:
```
Class 0: "No Watermark"
Class 1: "Watermark"
```
---
## **Install dependencies**
```bash
pip install -q transformers torch pillow gradio
```
---
## **Inference Code**
```python
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch
# Load model and processor
model_name = "prithivMLmods/Watermark-Detection-SigLIP2" # Update this if using a different path
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
# Label mapping
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 Interface
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="Upload an image to detect whether it contains a watermark."
)
if __name__ == "__main__":
iface.launch()
```
---
## **Demo Inference**
> [!Warning]
> Watermark
<table>
<tr>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/sm062kFE7QJiLisTTjNwv.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/UFymm_tzVRmov6vn_cElE.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/bPzPAK-Mib8nFhHCkjD2B.png" width="300"/></td>
</tr>
<tr>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/4fP8SBIYofKEeDBU0klQ2.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/wD5M4YgyQGk9-QLFjMcn9.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/yg0q88-0S4k4FUS4-qGNw.png" width="300"/></td>
</tr>
<tr>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/WhRkeYw8-wIgldpaz0E4m.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/Uhb1zBxQV_5CWLoyTAMmD.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/7hnLD2b0f7B7edwgx_eOR.png" width="300"/></td>
</tr>
</table>
> [!Warning]
> No Watermark
<table>
<tr>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/edyFBIETs3Dosn1edpGZ8.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/3bRMcr2r0k00mMkthbYDW.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/eeMLQEg4r89f9owe8jSij.png" width="300"/></td>
</tr>
<tr>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/45jk4dvZk1wT3L7cprqql.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/mrkm0JXXgSQVXi0_d7EKH.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/f_5R7Inb8I-32hWJchkgj.png" width="300"/></td>
</tr>
<tr>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/qIUTSy8SuJEsRkYGd0L5d.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/DnlNo9lM4mBNUjlexKLVa.png" width="300"/></td>
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/bs4oyaapW8mi0lizOqWSf.png" width="300"/></td>
</tr>
</table>
---
## **Intended Use**
**Watermark-Detection-SigLIP2** is useful in scenarios such as:
- **Content Moderation** – Automatically detect watermarked content on image sharing platforms.
- **Dataset Cleaning** – Filter out watermarked images from training datasets.
- **Copyright Enforcement** – Monitor and flag usage of watermarked media.
- **Digital Forensics** – Support analysis of tampered or protected media assets.
|