BitcrushedHeart commited on
Commit
de04b81
·
verified ·
1 Parent(s): 443e46c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +147 -9
README.md CHANGED
@@ -1,11 +1,149 @@
1
  ---
2
- base_model:
3
- - Ultralytics/YOLO11
4
- pipeline_tag: object-detection
5
- tags:
6
- - watermark
7
- - yolo
8
- - yolo11
9
- - yolo11n
10
  license: agpl-3.0
11
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
 
 
 
 
 
 
 
2
  license: agpl-3.0
3
+ tags:
4
+ - object-detection
5
+ - yolo
6
+ - yolo11
7
+ - watermark-detection
8
+ - image-processing
9
+ - ultralytics
10
+ pipeline_tag: object-detection
11
+ ---
12
+
13
+ # BMD Watermark Detector — `bmd_watermark_n.pt`
14
+
15
+ A lightweight **YOLO11-nano** model fine-tuned for detecting watermarks in images. Trained from scratch on a custom dataset of real-world watermarked images, designed to power the smart-crop watermark removal pipeline in [DatasetStudio](https://github.com/BitcrushedHeart/DatasetStudio).
16
+
17
+ The `n` suffix denotes the **nano** variant — optimised for fast batch inference on large image datasets without sacrificing meaningful detection accuracy.
18
+
19
+ ---
20
+
21
+ ## Model Details
22
+
23
+ | Property | Value |
24
+ |---|---|
25
+ | **Architecture** | YOLO11n (nano) |
26
+ | **Task** | Object Detection |
27
+ | **Input** | RGB images (any resolution — resized to 640×640 internally) |
28
+ | **Output** | Bounding boxes (xyxy) + confidence scores |
29
+ | **Classes** | `0: watermark` |
30
+ | **License** | [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html) |
31
+
32
+ ---
33
+
34
+ ## Intended Use
35
+
36
+ This model is intended to **detect the location of watermarks** in images so that a downstream cropping step can remove them cleanly. It is well-suited for:
37
+
38
+ - Batch processing large image datasets to remove corner/edge watermarks
39
+ - Automated dataset cleaning pipelines
40
+ - Identifying watermark position (top-left, bottom-right corner, etc.)
41
+
42
+ > [!WARNING]
43
+ > This model is intended for **legitimate dataset cleaning** use cases (e.g. removing watermarks from your own content). Do not use it to strip copyright protections from images you do not have the rights to modify.
44
+
45
+ ---
46
+
47
+ ## Usage
48
+
49
+ ### Requirements
50
+
51
+ ```bash
52
+ pip install ultralytics pillow
53
+ ```
54
+
55
+ ### Basic Inference
56
+
57
+ ```python
58
+ from ultralytics import YOLO
59
+
60
+ model = YOLO("bmd_watermark_n.pt")
61
+
62
+ results = model("your_image.jpg", conf=0.25)
63
+ for r in results:
64
+ for box in r.boxes:
65
+ print(f"Watermark detected at {box.xyxy[0].tolist()} (conf: {float(box.conf[0]):.2f})")
66
+ ```
67
+
68
+ ### Batch Inference
69
+
70
+ ```python
71
+ from ultralytics import YOLO
72
+
73
+ model = YOLO("bmd_watermark_n.pt")
74
+
75
+ image_paths = ["img1.jpg", "img2.jpg", "img3.png"]
76
+ results = model(image_paths, conf=0.25, verbose=False)
77
+
78
+ for path, r in zip(image_paths, results):
79
+ if len(r.boxes) > 0:
80
+ print(f"{path}: watermark found")
81
+ else:
82
+ print(f"{path}: clean")
83
+ ```
84
+
85
+ ### Smart Crop (remove watermark by cropping)
86
+
87
+ ```python
88
+ from ultralytics import YOLO
89
+ from PIL import Image
90
+
91
+ def crop_out_watermark(img_path, model, conf=0.25, padding=0.1):
92
+ results = model(img_path, conf=conf, verbose=False)
93
+ r = results[0]
94
+ img_w, img_h = r.orig_shape[1], r.orig_shape[0]
95
+
96
+ if len(r.boxes) == 0:
97
+ return Image.open(img_path) # No watermark, return as-is
98
+
99
+ # Find largest detected box
100
+ best_box = max(r.boxes, key=lambda b: (b.xyxy[0][2]-b.xyxy[0][0]) * (b.xyxy[0][3]-b.xyxy[0][1]))
101
+ x1, y1, x2, y2 = best_box.xyxy[0].tolist()
102
+
103
+ # Add padding
104
+ pw = (x2 - x1) * padding
105
+ ph = (y2 - y1) * padding
106
+ x1, y1, x2, y2 = max(0,x1-pw), max(0,y1-ph), min(img_w,x2+pw), min(img_h,y2+ph)
107
+
108
+ # Crop to the largest region not containing the watermark
109
+ candidates = [
110
+ (0, 0, img_w, int(y1)), # above
111
+ (0, int(y2), img_w, img_h), # below
112
+ (0, 0, int(x1), img_h), # left
113
+ (int(x2), 0, img_w, img_h), # right
114
+ ]
115
+ best = max(candidates, key=lambda c: (c[2]-c[0]) * (c[3]-c[1]))
116
+
117
+ img = Image.open(img_path)
118
+ return img.crop(best)
119
+
120
+ model = YOLO("bmd_watermark_n.pt")
121
+ clean = crop_out_watermark("watermarked.jpg", model)
122
+ clean.save("clean.jpg")
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Training
128
+
129
+ - **Base architecture:** YOLO11n (Ultralytics)
130
+ - **Training data:** Custom dataset of watermarked images with manual bounding box annotations
131
+ - **Annotation format:** YOLO format (normalised `class x_center y_center width height`)
132
+ - **Hardware:** GPU-accelerated training
133
+ - **Recommended confidence threshold:** `0.25` for single-image preview, `0.5` for batch processing
134
+
135
+ ---
136
+
137
+ ## Limitations
138
+
139
+ - Optimised for **corner and edge watermarks** (bottom-right, bottom-left, top-right, top-left). Centered full-image watermarks (overlays) are out of scope.
140
+ - Performance may degrade on very small watermarks (< ~3% of image area) or heavily blended semi-transparent watermarks.
141
+ - The nano variant trades some accuracy for speed. For higher accuracy at the cost of inference time, consider training an `s` or `m` size variant.
142
+
143
+ ---
144
+
145
+ ## License
146
+
147
+ This model is released under the **[AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html)**, consistent with the Ultralytics YOLO11 framework used for training.
148
+
149
+ If you use this model in a commercial product or networked service, you must either comply with AGPL-3.0 (open-source your application) or obtain a separate commercial license from Ultralytics for the underlying framework.