File size: 12,083 Bytes
d681ba2
 
 
 
 
 
487476b
d681ba2
 
 
 
 
 
 
8c4f04a
 
487476b
 
d681ba2
46016bd
3cac608
46016bd
0cc736e
d681ba2
 
 
d56905a
 
1b717b8
 
 
82e63f8
 
71befc6
0cc736e
 
 
 
 
 
 
 
 
 
 
 
 
 
8a504ac
 
 
 
 
 
 
 
 
 
 
 
d681ba2
df27955
 
 
 
 
 
 
 
 
 
 
 
 
48707c1
 
 
 
 
 
 
 
 
 
 
 
 
46016bd
 
 
 
 
 
 
 
 
 
 
 
48707c1
82e63f8
 
551779e
71befc6
48707c1
71befc6
8aea897
48707c1
 
 
8aea897
71befc6
48707c1
71befc6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487476b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71befc6
b2b24ef
 
 
82e63f8
 
d681ba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3cac608
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
---
tags:
- text-to-image
- lora
- diffusers
- template:diffusion-lora
- Watermark-Remover
base_model: black-forest-labs/FLUX.1-Kontext-dev
instance_prompt: >-
  [photo content], remove any watermark text or logos from the image while
  preserving the background, texture, lighting, and overall realism. Ensure the
  edited areas blend seamlessly with surrounding details, leaving no visible
  traces of watermark removal.
license: apache-2.0
pipeline_tag: image-to-image
library_name: diffusers
language:
- en
---

![open-card](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/lw37AdVDixr8QE2kn1n32.png)

# **Kontext-Watermark-Remover**

<Gallery />

The Kontext-Watermark-Remover is an adapter for black-forest-lab's FLUX.1-Kontext-dev, designed to precisely remove watermarks and textual content from images while maintaining the original image quality and context. The model was trained on 150 image pairs (75 start images and 75 end images) to ensure accurate and artifact-free watermark removal.

> [!note]
[photo content], remove any watermark text or logos from the image while preserving the background, texture, lighting, and overall realism. Ensure the edited areas blend seamlessly with surrounding details, leaving no visible traces of watermark removal.

---

## **Sample Inferences : Demo**

<table style="width:100%; border-collapse:collapse;">
  <tr>
    <td style="width:50%; text-align:center;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/dp8EVqVH4WeKg6WkbbVMX.webp" 
           alt="watermark-the-milk-poster" style="width:100%; height:auto;"/>
    </td>
    <td style="width:50%; text-align:center;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/yju8FXDqOezu6gjOFEiUw.webp" 
           alt="watermark-the-milk-poster" style="width:100%; height:auto;"/>
    </td>
  </tr>
</table>

<table style="width:100%; border-collapse:collapse;">
  <tr>
    <td style="width:50%; text-align:center; vertical-align:middle;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/HSZO9JojEPuEXWmWHGXK2.png" 
           alt="22" style="width:100%; height:auto;"/>
    </td>
    <td style="width:50%; text-align:center; vertical-align:middle;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/iP4YB-lmnvMb8hvdnGaVY.webp" 
           alt="2222" style="width:100%; height:auto;"/>
    </td>
  </tr>
</table>

<table style="width:100%; border-collapse:collapse;">
  <tr>
    <td style="width:50%; text-align:center; vertical-align:middle;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/oANOI60kg5DcurcJFFtRO.png" 
           alt="image" style="width:100%; height:auto;"/>
    </td>
    <td style="width:50%; text-align:center; vertical-align:middle;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/mmmUTBMRpcdgfoPqZWlxF.webp" 
           alt="2234" style="width:100%; height:auto;"/>
    </td>
  </tr>
</table>

<table style="width:100%; border-collapse:collapse;">
  <tr>
    <td style="width:50%; text-align:center; vertical-align:middle;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/LIZZDkD74YOhsQswZ_baO.jpeg" 
           alt="signature-logo" style="width:100%; height:auto;"/>
    </td>
    <td style="width:50%; text-align:center; vertical-align:middle;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/RTa3OxGXI5FrNbtyG75E_.webp" 
           alt="555555555" style="width:100%; height:auto;"/>
    </td>
  </tr>
</table>

<table style="width:100%; border-collapse:collapse;">
  <tr>
    <td style="width:50%; text-align:center; vertical-align:middle;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/vX3rLx6gMzEJJu1pfERWD.jpeg" 
           alt="wmr-west-before1.2b600d3b" style="width:100%; height:auto;"/>
    </td>
    <td style="width:50%; text-align:center; vertical-align:middle;">
      <img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/86MrcB1Y9pOzTW16n-0-T.webp" 
           alt="555" style="width:100%; height:auto;"/>
    </td>
  </tr>
</table>

---

# **Quick start with diffusers🧨**

### **Required Packages**

```
!pip install diffusers torch gradio transformers
!pip install pillow gradio-imageslider huggingface_hub
!pip install sentencepiece spaces peft torchvision accelerate
```

## **Run Demo**

```py
import os
import gradio as gr
import numpy as np
import spaces
import torch
import random
from PIL import Image
from typing import Iterable

from diffusers import FluxKontextPipeline
from diffusers.utils import load_image
from huggingface_hub import hf_hub_download
from gradio_imageslider import ImageSlider

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# --- Main Model Initialization ---
MAX_SEED = np.iinfo(np.int32).max
pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to("cuda")

# --- Load New Adapter ---
pipe.load_lora_weights("prithivMLmods/Kontext-Watermark-Remover", weight_name="Kontext-Watermark-Remover.safetensors", adapter_name="watermark_remover")


@spaces.GPU
def infer(input_image, prompt, seed=42, randomize_seed=False, guidance_scale=2.5, steps=28, progress=gr.Progress(track_tqdm=True)):
    """
    Perform image editing, returning a pair for the ImageSlider.
    """
    if not input_image:
        raise gr.Error("Please upload an image for editing.")

    pipe.set_adapters(["watermark_remover"], adapter_weights=[1.0])

    if randomize_seed:
        seed = random.randint(0, MAX_SEED)
    
    original_image = input_image.copy().convert("RGB")
    
    image = pipe(
        image=original_image, 
        prompt=prompt,
        guidance_scale=guidance_scale,
        width = original_image.size[0],
        height = original_image.size[1],
        num_inference_steps=steps,
        generator=torch.Generator().manual_seed(seed),
    ).images[0]

    return (original_image, image), seed, gr.Button(visible=True)

css="""
#col-container {
    margin: 0 auto;
    max-width: 960px;
}
#main-title h1 {font-size: 2.1em !important;}
"""

with gr.Blocks(css=css) as demo:
    
    with gr.Column(elem_id="col-container"):
        gr.Markdown("# **Photo-Mate-i2i: Watermark Remover**", elem_id="main-title")
        gr.Markdown("Image manipulation with FLUX.1 Kontext. This demo focuses on watermark removal.")
        
        with gr.Row():
            with gr.Column():
                input_image = gr.Image(label="Upload Image with Watermark", type="pil", height="300")
                with gr.Row():
                    prompt = gr.Text(
                        label="Edit Prompt",
                        show_label=False,
                        max_lines=1,
                        placeholder="e.g., 'Remove the watermark'",
                        container=False,
                        value="[photo content], remove any watermark text or logos from the image while preserving the background, texture, lighting, and overall realism. Ensure the edited areas blend seamlessly with surrounding details, leaving no visible traces of watermark removal."
                    )
                    run_button = gr.Button("Run", variant="primary", scale=0)
                with gr.Accordion("Advanced Settings", open=False):
                    
                    seed = gr.Slider(
                        label="Seed",
                        minimum=0,
                        maximum=MAX_SEED,
                        step=1,
                        value=0,
                    )
                    
                    randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
                    
                    guidance_scale = gr.Slider(
                        label="Guidance Scale",
                        minimum=1,
                        maximum=10,
                        step=0.1,
                        value=2.5,
                    )       
                    
                    steps = gr.Slider(
                        label="Steps",
                        minimum=1,
                        maximum=30,
                        value=28,
                        step=1
                    )
                    
            with gr.Column():
                output_slider = ImageSlider(label="Before / After", show_label=False, interactive=False)
                reuse_button = gr.Button("Reuse this image", visible=False)
                
    gr.on(
        triggers=[run_button.click, prompt.submit],
        fn=infer,
        inputs=[input_image, prompt, seed, randomize_seed, guidance_scale, steps],
        outputs=[output_slider, seed, reuse_button]
    )
    
    reuse_button.click(
        fn=lambda images: images[1] if isinstance(images, (list, tuple)) and len(images) > 1 else images,
        inputs=[output_slider],
        outputs=[input_image]
    )

demo.launch(mcp_server=True, ssr_mode=False, show_error=True)
```

---

## Parameter Settings

| Setting                  | Value                    |
| ------------------------ | ------------------------ |
| Module Type              | Adapter                     |
| Base Model               | FLUX.1 Kontext Dev - fp8 |
| Trigger Words            | [photo content], remove any watermark text or logos from the image while preserving the background, texture, lighting, and overall realism. Ensure the edited areas blend seamlessly with surrounding details, leaving no visible traces of watermark removal. |
| Image Processing Repeats | 50                       |
| Epochs                   | 25                       |
| Save Every N Epochs      | 1                        |

    Labeling: florence-community/Florence-2-large-ft (natural language & English)
    
    Total Images Used for Training : 150 Image Pairs (75 Start, 75 End)

## Training Parameters

| Setting                     | Value     |
| --------------------------- | --------- |
| Seed                        | -         |
| Clip Skip                   | -         |
| Text Encoder LR             | 0.00001   |
| UNet LR                     | 0.00005   |
| LR Scheduler                | constant  |
| Optimizer                   | AdamW8bit |
| Network Dimension           | 64        |
| Network Alpha               | 32        |
| Gradient Accumulation Steps | -         |

## Label Parameters

| Setting         | Value |
| --------------- | ----- |
| Shuffle Caption | -     |
| Keep N Tokens   | -     |

## Advanced Parameters

| Setting                   | Value |
| ------------------------- | ----- |
| Noise Offset              | 0.03  |
| Multires Noise Discount   | 0.1   |
| Multires Noise Iterations | 10    |
| Conv Dimension            | -     |
| Conv Alpha                | -     |
| Batch Size                | -     |
| Steps   | 2900 & 400(warm up)  |
| Sampler | euler |

---

## **Sample Inferences : Inference Providers**

![Screenshot 2025-10-27 at 18-01-05 prithivMLmods_Kontext-Watermark-Remover · Hugging Face](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/-rIKEJMcUE1Lvap1vxBIR.png)

---

## Trigger words

You should use `[photo content]` to trigger the image generation.

You should use `remove any watermark text or logos from the image while preserving the background` to trigger the image generation.

You should use `texture` to trigger the image generation.

You should use `lighting` to trigger the image generation.

You should use `and overall realism. Ensure the edited areas blend seamlessly with surrounding details` to trigger the image generation.

You should use `leaving no visible traces of watermark removal.` to trigger the image generation.


## Download model


[Download](/prithivMLmods/Kontext-Watermark-Remover/tree/main) them in the Files & versions tab.