AI prompts
base on AI-Powered Watermark Remover using Florence-2 and LaMA Models: A Python application leveraging state-of-the-art deep learning models to effectively remove watermarks from images with a user-friendly PyQt6 interface. # WatermarkRemover-AI
**AI-Powered Watermark Removal Tool using Florence-2 and LaMA Models**
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)

Example of watermark removal with LaMa inpainting


## Overview
`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.
## Table of Contents
- [Features](#features)
- [Technical Overview](#technical-overview)
- [Installation](#installation)
- [Usage](#usage)
- [Preferred Way: Setup Script](#preferred-way-setup-script)
- [Manual Way](#manual-way)
- [Using the GUI](#using-the-gui)
- [Using the CLI](#using-the-cli)
- [Upgrade Notes](#upgrade-notes)
- [Alpha Masking](#alpha-masking)
- [Contributing](#contributing)
- [License](#license)
---
## Features
- **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).
---
## Technical Overview
### Florence-2 for Watermark Detection
- 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.
### LaMA for Inpainting
- The LaMA model seamlessly fills in watermark regions with context-aware content.
- Supports high-resolution inpainting by using cropping and resizing strategies.
### PyQt6 GUI
- User-friendly interface for selecting input/output paths, configuring settings, and tracking progress.
- Dark mode and customization options enhance the user experience.
---
## Installation
### Prerequisites
- Conda/Miniconda installed.
- CUDA (optional for GPU acceleration; the application runs well on CPUs too).
### Steps
1. **Clone the Repository:**
```bash
git clone https://github.com/D-Ogi/WatermarkRemover-AI.git
cd WatermarkRemover-AI
```
2. **Run the Setup Script:**
```bash
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.
3. **Download the LaMA Model:**
```bash
conda activate py312aiwatermark
iopaint download --model lama
```
The LaMA inpainting model files aren't included in the repository and must be downloaded separately (approximately 196MB).
5. **Fast-Track Options:**
- **To Use the CLI Immediately**: After running `setup.sh`, you can use the CLI directly without activating the environment manually:
```bash
./setup.sh input_path output_path [options]
```
Example:
```bash
./setup.sh ./input_images ./output_images --overwrite --transparent
```
- **To Activate the Environment Without Starting the Application**: Use:
```bash
conda activate py312aiwatermark
```
---
## Usage
### Preferred Way: Setup Script
1. **Run the Setup Script**:
```bash
bash setup.sh
```
- The GUI will launch automatically, and the environment will be ready for immediate CLI or GUI use.
- For CLI use, run:
```bash
./setup.sh input_path output_path [options]
```
Example:
```bash
./setup.sh ./input_images ./output_images --overwrite --transparent
```
### Manual Way
1. **Activate the Environment**:
```bash
conda activate py312aiwatermark
```
2. **Launch GUI or CLI**:
- **GUI**:
```bash
python remwmgui.py
```
- **CLI**:
```bash
python remwm.py input_path output_path [options]
```
### Using the GUI
1. **Launch the GUI**:
If not launched automatically, start it with:
```bash
python remwmgui.py
```
2. **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.
3. **Start Processing**:
- Click "Start" to begin processing.
- Monitor progress and logs in the GUI.
### Using the CLI
1. **Basic Command**:
```bash
python remwm.py input_path output_path
```
2. **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).
3. **Example**:
```bash
python remwm.py ./input_images ./output_images --overwrite --max-bbox-percent=15 --force-format=PNG
```
---
### Upgrade Notes
If you have previously used an older version of the repository or set up an incorrect Conda environment, follow these steps to upgrade:
1. **Update the Repository**:
```bash
git pull
```
2. **Remove the Old Environment**:
```bash
conda deactivate
conda env remove -n py312
```
3. **Run the Setup Script**:
```bash
bash setup.sh
```
This will recreate the correct environment (`py312aiwatermark`) and ensure all dependencies are up-to-date.
---
## Alpha Masking
We implemented alpha masking to allow selective manipulation of watermark regions without altering other parts of the image.
### Why Alpha Masking?
- **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.
---
## Contributing
Contributions are welcome! To contribute:
1. Fork the repository.
2. Create a new branch for your feature.
3. Submit a pull request detailing your changes.
---
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
", Assign "at most 3 tags" to the expected json: {"id":"13555","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"