CoolFace
Modelpublic

prithivMLmods/Kontext-Watermark-Remover

sourceHugging Faceapache-2.0updated 11mo agoView on Hugging Face
82likes1.1kdownloads
Model Card

open-card

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/LIZZDkD74YOhsQswZbaO.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

SettingValue
Module TypeAdapter
Base ModelFLUX.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 Repeats50
Epochs25
Save Every N Epochs1

Labeling: florence-community/Florence-2-large-ft (natural language & English)

Total Images Used for Training : 150 Image Pairs (75 Start, 75 End)

Training Parameters

SettingValue
Seed-
Clip Skip-
Text Encoder LR0.00001
UNet LR0.00005
LR Schedulerconstant
OptimizerAdamW8bit
Network Dimension64
Network Alpha32
Gradient Accumulation Steps-

Label Parameters

SettingValue
Shuffle Caption-
Keep N Tokens-

Advanced Parameters

SettingValue
Noise Offset0.03
Multires Noise Discount0.1
Multires Noise Iterations10
Conv Dimension-
Conv Alpha-
Batch Size-
Steps2900 & 400(warm up)
Samplereuler

Sample Inferences : Inference Providers

Screenshot 2025-10-27 at 18-01-05 prithivMLmods_Kontext-Watermark-Remover · Hugging Face


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 them in the Files & versions tab.