rishabh commited on
Commit ·
4ef3556
1
Parent(s): 4225e4e
doen the changes
Browse files
README.md
CHANGED
|
@@ -12,23 +12,25 @@ tags:
|
|
| 12 |
- Image-Classification
|
| 13 |
- Watermark-Detection
|
| 14 |
- SigLIP2
|
| 15 |
-
|
| 16 |
---
|
| 17 |
|
|
|
|
|
|
|
| 18 |

|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
>
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
> Watermark detection works best with crisp and high-quality images. Noisy images are not recommended for validation.
|
| 26 |
|
| 27 |
-
|
| 28 |
-
*SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features* https://arxiv.org/pdf/2502.14786
|
| 29 |
|
| 30 |
-
```
|
| 31 |
-
Classification Report:
|
| 32 |
precision recall f1-score support
|
| 33 |
|
| 34 |
No Watermark 0.9290 0.9722 0.9501 12779
|
|
@@ -37,134 +39,3 @@ No Watermark 0.9290 0.9722 0.9501 12779
|
|
| 37 |
accuracy 0.9427 22762
|
| 38 |
macro avg 0.9456 0.9385 0.9414 22762
|
| 39 |
weighted avg 0.9435 0.9427 0.9424 22762
|
| 40 |
-
```
|
| 41 |
-
|
| 42 |
-

|
| 43 |
-
|
| 44 |
-
---
|
| 45 |
-
|
| 46 |
-
## **Label Space: 2 Classes**
|
| 47 |
-
|
| 48 |
-
The model classifies an image as either:
|
| 49 |
-
|
| 50 |
-
```
|
| 51 |
-
Class 0: "No Watermark"
|
| 52 |
-
Class 1: "Watermark"
|
| 53 |
-
```
|
| 54 |
-
|
| 55 |
-
---
|
| 56 |
-
|
| 57 |
-
## **Install dependencies**
|
| 58 |
-
|
| 59 |
-
```bash
|
| 60 |
-
pip install -q transformers torch pillow gradio
|
| 61 |
-
```
|
| 62 |
-
|
| 63 |
-
---
|
| 64 |
-
|
| 65 |
-
## **Inference Code**
|
| 66 |
-
|
| 67 |
-
```python
|
| 68 |
-
import gradio as gr
|
| 69 |
-
from transformers import AutoImageProcessor, SiglipForImageClassification
|
| 70 |
-
from PIL import Image
|
| 71 |
-
import torch
|
| 72 |
-
|
| 73 |
-
# Load model and processor
|
| 74 |
-
model_name = "prithivMLmods/Watermark-Detection-SigLIP2" # Update this if using a different path
|
| 75 |
-
model = SiglipForImageClassification.from_pretrained(model_name)
|
| 76 |
-
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 77 |
-
|
| 78 |
-
# Label mapping
|
| 79 |
-
id2label = {
|
| 80 |
-
"0": "No Watermark",
|
| 81 |
-
"1": "Watermark"
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
def classify_watermark(image):
|
| 85 |
-
image = Image.fromarray(image).convert("RGB")
|
| 86 |
-
inputs = processor(images=image, return_tensors="pt")
|
| 87 |
-
|
| 88 |
-
with torch.no_grad():
|
| 89 |
-
outputs = model(**inputs)
|
| 90 |
-
logits = outputs.logits
|
| 91 |
-
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
| 92 |
-
|
| 93 |
-
prediction = {
|
| 94 |
-
id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
return prediction
|
| 98 |
-
|
| 99 |
-
# Gradio Interface
|
| 100 |
-
iface = gr.Interface(
|
| 101 |
-
fn=classify_watermark,
|
| 102 |
-
inputs=gr.Image(type="numpy"),
|
| 103 |
-
outputs=gr.Label(num_top_classes=2, label="Watermark Detection"),
|
| 104 |
-
title="Watermark-Detection-SigLIP2",
|
| 105 |
-
description="Upload an image to detect whether it contains a watermark."
|
| 106 |
-
)
|
| 107 |
-
|
| 108 |
-
if __name__ == "__main__":
|
| 109 |
-
iface.launch()
|
| 110 |
-
```
|
| 111 |
-
|
| 112 |
-
---
|
| 113 |
-
|
| 114 |
-
## **Demo Inference**
|
| 115 |
-
|
| 116 |
-
> [!Warning]
|
| 117 |
-
> Watermark
|
| 118 |
-
|
| 119 |
-
<table>
|
| 120 |
-
<tr>
|
| 121 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/sm062kFE7QJiLisTTjNwv.png" width="300"/></td>
|
| 122 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/UFymm_tzVRmov6vn_cElE.png" width="300"/></td>
|
| 123 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/bPzPAK-Mib8nFhHCkjD2B.png" width="300"/></td>
|
| 124 |
-
</tr>
|
| 125 |
-
<tr>
|
| 126 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/4fP8SBIYofKEeDBU0klQ2.png" width="300"/></td>
|
| 127 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/wD5M4YgyQGk9-QLFjMcn9.png" width="300"/></td>
|
| 128 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/yg0q88-0S4k4FUS4-qGNw.png" width="300"/></td>
|
| 129 |
-
</tr>
|
| 130 |
-
<tr>
|
| 131 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/WhRkeYw8-wIgldpaz0E4m.png" width="300"/></td>
|
| 132 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/Uhb1zBxQV_5CWLoyTAMmD.png" width="300"/></td>
|
| 133 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/7hnLD2b0f7B7edwgx_eOR.png" width="300"/></td>
|
| 134 |
-
</tr>
|
| 135 |
-
</table>
|
| 136 |
-
|
| 137 |
-
> [!Warning]
|
| 138 |
-
> No Watermark
|
| 139 |
-
|
| 140 |
-
<table>
|
| 141 |
-
<tr>
|
| 142 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/edyFBIETs3Dosn1edpGZ8.png" width="300"/></td>
|
| 143 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/3bRMcr2r0k00mMkthbYDW.png" width="300"/></td>
|
| 144 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/eeMLQEg4r89f9owe8jSij.png" width="300"/></td>
|
| 145 |
-
</tr>
|
| 146 |
-
<tr>
|
| 147 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/45jk4dvZk1wT3L7cprqql.png" width="300"/></td>
|
| 148 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/mrkm0JXXgSQVXi0_d7EKH.png" width="300"/></td>
|
| 149 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/f_5R7Inb8I-32hWJchkgj.png" width="300"/></td>
|
| 150 |
-
</tr>
|
| 151 |
-
<tr>
|
| 152 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/qIUTSy8SuJEsRkYGd0L5d.png" width="300"/></td>
|
| 153 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/DnlNo9lM4mBNUjlexKLVa.png" width="300"/></td>
|
| 154 |
-
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/bs4oyaapW8mi0lizOqWSf.png" width="300"/></td>
|
| 155 |
-
</tr>
|
| 156 |
-
</table>
|
| 157 |
-
|
| 158 |
-
---
|
| 159 |
-
|
| 160 |
-
## **Intended Use**
|
| 161 |
-
|
| 162 |
-
**Watermark-Detection-SigLIP2** is useful in scenarios such as:
|
| 163 |
-
|
| 164 |
-
- **Content Moderation** – Automatically detect watermarked content on image sharing platforms.
|
| 165 |
-
- **Dataset Cleaning** – Filter out watermarked images from training datasets.
|
| 166 |
-
- **Copyright Enforcement** – Monitor and flag usage of watermarked media.
|
| 167 |
-
- **Digital Forensics** – Support analysis of tampered or protected media assets.
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
| 12 |
- Image-Classification
|
| 13 |
- Watermark-Detection
|
| 14 |
- SigLIP2
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# **Watermark-Detection-SigLIP2**
|
| 18 |
+
|
| 19 |

|
| 20 |
|
| 21 |
+
**Watermark-Detection-SigLIP2** is a vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for **binary image classification**.
|
| 22 |
+
It detects whether an image **contains a watermark or not**, using the `SiglipForImageClassification` architecture.
|
| 23 |
+
|
| 24 |
+
> ⚠️ Note: Watermark detection works best with high-quality, crisp images. Avoid noisy inputs.
|
| 25 |
|
| 26 |
+
> 📄 Paper: *SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features*
|
| 27 |
+
> https://arxiv.org/pdf/2502.14786
|
| 28 |
|
| 29 |
+
---
|
|
|
|
| 30 |
|
| 31 |
+
## 📊 Classification Report
|
|
|
|
| 32 |
|
| 33 |
+
```text
|
|
|
|
| 34 |
precision recall f1-score support
|
| 35 |
|
| 36 |
No Watermark 0.9290 0.9722 0.9501 12779
|
|
|
|
| 39 |
accuracy 0.9427 22762
|
| 40 |
macro avg 0.9456 0.9385 0.9414 22762
|
| 41 |
weighted avg 0.9435 0.9427 0.9424 22762
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|