AI-Powered Watermark Removal Tool using Florence-2 and LaMA Models
Example of watermark removal with LaMa inpainting
WatermarkRemover-AI
is a cutting-edge application that leverages AI models for precise watermark detection and seamless removal. It uses Florence-2 from Microsoft for watermark identification and LaMA for inpainting to fill in the removed regions naturally. The software offers both a command-line interface (CLI) and a PyQt6-based graphical user interface (GUI), making it accessible to both casual and advanced users.
- Dual Modes: Process individual images or entire directories of images.
- Advanced Watermark Detection: Utilizes Florence-2's open-vocabulary detection for accurate watermark identification.
- Seamless Inpainting: Employs LaMA for high-quality, context-aware inpainting.
- Customizable Output:
- Configure maximum bounding box size for watermark detection.
- Set transparency for watermark regions.
- Force specific output formats (PNG, WEBP, JPG).
- Progress Tracking: Real-time progress updates in both GUI and CLI modes.
- Dark Mode Support: GUI automatically adapts to system dark mode settings.
- Efficient Resource Management: Optimized for GPU acceleration using CUDA (optional).
- Florence-2 detects watermarks using open-vocabulary object detection.
- Bounding boxes are filtered to ensure that only small regions (configurable by the user) are processed.
- The LaMA model seamlessly fills in watermark regions with context-aware content.
- Supports high-resolution inpainting by using cropping and resizing strategies.
- User-friendly interface for selecting input/output paths, configuring settings, and tracking progress.
- Dark mode and customization options enhance the user experience.
- Conda/Miniconda installed.
- CUDA (optional for GPU acceleration; the application runs well on CPUs too).
-
Clone the Repository:
git clone https://github.com/D-Ogi/WatermarkRemover-AI.git cd WatermarkRemover-AI
-
Run the Setup Script:
bash setup.sh
The
setup.sh
script automatically sets up the environment, installs dependencies, and launches the GUI application. It also provides convenient options for CLI usage. -
Fast-Track Options:
- To Use the CLI Immediately: After running
setup.sh
, you can use the CLI directly without activating the environment manually:Example:./setup.sh input_path output_path [options]
./setup.sh ./input_images ./output_images --overwrite --transparent
- To Activate the Environment Without Starting the Application: Use:
conda activate py312aiwatermark
- To Use the CLI Immediately: After running
- Run the Setup Script:
bash setup.sh
- The GUI will launch automatically, and the environment will be ready for immediate CLI or GUI use.
- For CLI use, run:
Example:
./setup.sh input_path output_path [options]
./setup.sh ./input_images ./output_images --overwrite --transparent
- Activate the Environment:
conda activate py312aiwatermark
- Launch GUI or CLI:
- GUI:
python remwmgui.py
- CLI:
python remwm.py input_path output_path [options]
- GUI:
-
Launch the GUI: If not launched automatically, start it with:
python remwmgui.py
-
Configure Settings:
- Mode: Select "Process Single Image" or "Process Directory".
- Paths: Browse and set the input/output directories.
- Options:
- Enable overwriting of existing files (directory processing only, single image processing always overwrites)
- Enable transparency for watermark regions.
- Adjust the maximum bounding box size for watermark detection.
- Output Format: Choose between PNG, WEBP, JPG, or retain the original format.
-
Start Processing:
- Click "Start" to begin processing.
- Monitor progress and logs in the GUI.
-
Basic Command:
python remwm.py input_path output_path
-
Options:
--overwrite
: Overwrite existing files.--transparent
: Make watermark regions transparent instead of removing them.--max-bbox-percent
: Set the maximum bounding box size for watermark detection (default: 10%).--force-format
: Force output format (PNG, WEBP, or JPG).
-
Example:
python remwm.py ./input_images ./output_images --overwrite --max-bbox-percent=15 --force-format=PNG
We implemented alpha masking to allow selective manipulation of watermark regions without altering other parts of the image.
- Precision: Enable box-targeted watermark removal by isolating specific regions.
- Flexibility: By controlling opacity in alpha layers, we can achieve a range of effects by complete removal to transparency.
- Minimal Impact: This method ensures that areas outside the watermark remain untouched, preserving image quality.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature.
- Submit a pull request detailing your changes.
This project is licensed under the MIT License. See the LICENSE file for details.