Open-Source Watermark Detection and Removal – WatermarkRemover-AI

An open-source AI tool that remove watermarks without cloud services using Florence-2 detection and LaMA inpainting. CLI + GUI modes.

WatermarkRemover-AI is an open-source Python application that combines advanced AI models to detect and remove watermarks from images.

It leverages Microsoft’s Florence-2 for watermark detection and the LaMA model for inpainting to create natural-looking results.

Features

  • Dual Modes: You can process one image at a time or point it at a whole directory for batch jobs.
  • AI Detection: Uses Florence-2’s open-vocabulary detection. This means it’s not limited to specific, pre-trained watermark types; it tries to identify watermark-like objects.
  • AI Inpainting: Leverages the LaMA model to fill in the space where the watermark used to be, trying to match the surrounding context.
  • Custom Output: You can tweak things like the maximum size of detected watermarks (to avoid removing large logos mistakenly identified), set the removed area to transparent instead of inpainting, and force output to PNG, WEBP, or JPG.
  • Progress Updates: Shows you what’s happening in real-time, both in the GUI and CLI.
  • Dark Mode: The GUI respects your system’s dark mode setting.
  • GPU Support: If you have an NVIDIA GPU and CUDA set up, it can use it for faster processing. It runs fine on CPU too, just slower.

Use Cases

  • Cleaning Licensed Stock Photos: You bought a license but the provider only gives you the watermarked version initially, or maybe you downloaded previews and later licensed the high-res ones – this can help batch-remove the preview watermarks from the licensed images you now own rights to use cleanly. Always respect licensing terms.
  • Removing Camera Overlays: Some photos might have date/time stamps or camera model info burned in as a sort of watermark. This tool can often detect and remove those.
  • Preparing Datasets: If you’re working on computer vision projects and have datasets with source watermarks (assuming you have rights to use the images), this could help clean them up.
  • Restoring Old Scans: Sometimes scanned family photos might have scanner marks or digital artifacts that resemble watermarks; this might help clean those up.
  • Content Creation Prep: If you composite images and have source elements with minor watermarks (again, assuming proper rights), this can be a step in your workflow.

How To Use It

Prerequisites:

  • You need Conda or Miniconda installed. (If you don’t have it, grab Miniconda – it’s smaller).
  • CUDA is optional but recommended if you have a compatible NVIDIA GPU.

1. Clone the Git Repo:

    git clone https://github.com/D-Ogi/WatermarkRemover-AI.git
    cd WatermarkRemover-AI

    2. Run the Setup Script: The developer provided a handy script.

      bash setup.sh

      This script does the heavy lifting: creates a Conda environment named py312aiwatermark, installs dependencies (like PyTorch, Transformers, PyQt6), and usually launches the GUI right after. It’s the easiest way to get going.

      3. Download the LaMA Model: This is a crucial step that’s easy to miss. The inpainting model isn’t bundled. After the setup script runs (or if you manually activate the environment), run:

        # Make sure the environment is active first if setup.sh didn't leave it active
        conda activate py312aiwatermark
        # Now download the model
        iopaint download --model lama

        This downloads about 196MB of model files needed for the inpainting part.

        Usage:

        Preferred Way (Setup Script):

        • Just run bash setup.sh. The GUI should pop up.
        • For CLI use after setup, you can use the script as a wrapper: ./setup.sh path/to/input path/to/output [options] # Example: Process a directory, overwrite output, make transparent ./setup.sh ./images_in ./images_out --overwrite --transparent

        Manual Way:

        • Activate the environment: conda activate py312aiwatermark
        • Launch GUI: python remwmgui.py
        • Use CLI: python remwm.py path/to/input path/to/output [options]

        Using the GUI:

        1. Launch it (python remwmgui.py or via setup.sh).

        2. Select “Process Single Image” or “Process Directory”.

        3. Use the “Browse” buttons to set input/output paths.

        4. Check the options you need:

          • Overwrite: Allows overwriting files in the output directory (always on for single images).
          • Transparent: Makes the watermark area transparent (alpha channel) instead of inpainting.
          • Max BBox Size (%): Adjust this slider if it’s missing watermarks (try increasing) or removing things that aren’t watermarks (try decreasing). Default is 10%.
          • Output Format: Choose PNG, WEBP, JPG, or keep the original format.

          Click “Start”. Progress appears in the log area.

            Using the CLI:

            1. Basic command:

              python remwm.py ./input_folder ./output_folder

              2. Common options:

                • --overwrite: Allow overwriting output files.
                • --transparent: Use transparency instead of LaMA inpainting.
                • --max-bbox-percent=N: Set max watermark size percentage (e.g., --max-bbox-percent=15).
                • --force-format=FMT: Force output format (e.g., --force-format=PNG).

                3. Example:

                  python remwm.py image.jpg output.png --max-bbox-percent=5 --force-format=PNG

                  Pros

                  • Free & Open Source: No cost, and you can inspect or modify the code.
                  • Local Processing: Your images stay on your machine – big plus for privacy and security.
                  • Advanced AI Models: Uses specific, known models (Florence-2, LaMA) for detection and inpainting, which generally produce better results than simpler methods.
                  • CLI & GUI: Caters to different user preferences and workflows.
                  • Batch Processing: Saves a ton of time if you have many images.
                  • Customization: Options for bbox size, transparency, and output format provide useful control.
                  • Optional GPU Acceleration: Can speed things up significantly if you have the hardware.

                  Cons

                  • Setup Complexity: Requires Conda and Git. While the setup.sh helps, it might be a hurdle for non-developers.
                  • Resource Intensive: AI models, especially LaMA for inpainting, can be demanding on CPU/RAM, and much faster with a GPU.
                  • Detection Isn’t Perfect: Florence-2 is good, but open-vocabulary detection can sometimes miss watermarks or flag non-watermark areas.
                  • Inpainting Quality Varies: LaMA does context-aware filling, but complex backgrounds or large watermarks can still result in noticeable artifacts. It’s good, but not magic.

                  Related Resources

                  Frequently Asked Questions

                  Q: Do I absolutely need an NVIDIA GPU?
                  A: No. The tool runs on CPU. It will just be slower, especially the inpainting part. If you plan to process many large images, a CUDA-enabled GPU will make a noticeable difference.

                  Q: What if it’s not removing the watermark?
                  A: First, check if Florence-2 is detecting it. If not, try increasing the --max-bbox-percent value slightly (via GUI slider or CLI option). Maybe go from 10% to 15% or 20%. If the watermark is very faint or unusual, detection might fail.

                  Q: What’s the real difference between removing (--transparent off) and making transparent (--transparent on)?
                  A: Removing uses the LaMA model to try and intelligently fill the watermark area with content that matches the surroundings. Making transparent simply makes the detected watermark area see-through using an alpha channel (output must be PNG or WEBP to support this). The transparent option is useful if you want to manually process the area later or just visually confirm what was detected.

                  Q: Can WatermarkRemover-AI remove any type of watermark?
                  A: The tool works best with standard watermarks that occupy a reasonable portion of the image (under the default 10% threshold). Very large watermarks, complex patterns, or watermarks that blend extensively with the image content may yield less optimal results.

                  Q: Does using this tool raise copyright concerns?
                  A: Yes. The tool should only be used on images you own or have proper rights to modify. Removing watermarks from copyrighted content without permission violates copyright law in most jurisdictions.

                  Q: How does the maximum bounding box percentage setting affect results?
                  A: This setting controls the size threshold for watermark detection. Lower percentages target smaller watermarks and reduce false positives, while higher values can detect larger watermarks but might incorrectly process important image elements.

                  Q: Can I run this on images with multiple watermarks?
                  A: Yes. The detection system can identify multiple watermark instances in a single image, though processing time increases with the number of watermarks detected.

                  Leave a Reply

                  Your email address will not be published. Required fields are marked *

                  Get the latest & top AI tools sent directly to your email.

                  Subscribe now to explore the latest & top AI tools and resources, all in one convenient newsletter. No spam, we promise!